<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brian&#039;s Blog &#187; Scripting</title>
	<atom:link href="http://briped.net/tag/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://briped.net</link>
	<description>Blogging when bored...</description>
	<lastBuildDate>Sun, 08 Jan 2012 17:50:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Status Press Widget</title>
		<link>http://briped.net/2009/12/23/status-press-widget/</link>
		<comments>http://briped.net/2009/12/23/status-press-widget/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 23:38:24 +0000</pubDate>
		<dc:creator>Brian Schmidt Pedersen</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://briped.net/?p=296</guid>
		<description><![CDATA[I&#8217;ve been playing around a bit with Status Press Widget by Brian D. Goad. I found that the data it fetched also showed the nick-/username which I think is kinda redundant so I modified the plugin a bit to let me manage it from the admin interface. While at it I also modified so URL&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around a bit with <a href="http://www.briandgoad.com/blog/downloads/status-press-widget/">Status Press Widget</a> by <a href="http://www.briandgoad.com/blog">Brian D. Goad</a>.</p>
<p>I found that the data it fetched also showed the nick-/username which I think is kinda redundant so I modified the plugin a bit to let me manage it from the admin interface. While at it I also modified so URL&#8217;s are made clickable and cleaned up the code a bit.</p>
<p>Here&#8217;s the modified status-press-widget.php file:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">/*<br />
Plugin Name: Status Press Widget<br />
Plugin URI: http://www.briandgoad.com/blog/status-press-widget/<br />
Description: Adds a Widget to display your Facebook/Twitter/Last.FM/Pownce status in your sidebar.<br />
Version: 1.14<br />
Author: Brian D. Goad<br />
Author URI: http://www.briandgoad.com/blog<br />
*/</span><br />
<span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; Copyright 2008 &nbsp;Brian D. Goad &nbsp;(email : bdgoad@gmail.com)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; Adam Walker Cleaveland &amp; &nbsp;C. Scott Andreas,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Authors of the original Status Press Plugin<br />
<br />
&nbsp; &nbsp; This program is free software; you can redistribute it and/or modify<br />
&nbsp; &nbsp; it under the terms of the GNU General Public License as published by<br />
&nbsp; &nbsp; the Free Software Foundation; either version 2 of the License, or<br />
&nbsp; &nbsp; (at your option) any later version.<br />
<br />
&nbsp; &nbsp; This program is distributed in the hope that it will be useful,<br />
&nbsp; &nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
&nbsp; &nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. &nbsp;See the<br />
&nbsp; &nbsp; GNU General Public License for more details.<br />
<br />
&nbsp; &nbsp; You should have received a copy of the GNU General Public License<br />
&nbsp; &nbsp; along with this program; if not, write to the Free Software<br />
&nbsp; &nbsp; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA &nbsp;02111-1307 &nbsp;USA<br />
*/</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;htmlspecialchars_decode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <a href="http://www.php.net/htmlspecialchars_decode"><span style="color: #990000;">htmlspecialchars_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span><span style="color: #000088;">$style</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">ENT_COMPAT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$translation</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_flip"><span style="color: #990000;">array_flip</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/get_html_translation_table"><span style="color: #990000;">get_html_translation_table</span></a><span style="color: #009900;">&#40;</span>HTML_SPECIALCHARS<span style="color: #339933;">,</span><span style="color: #000088;">$style</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$style</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$translation</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'&amp;#039;'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'\''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/strtr"><span style="color: #990000;">strtr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span><span style="color: #000088;">$translation</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> SPWidget <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Set Defaults</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$default_options</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'social'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'url'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'num'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;1&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'status_mods'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'show_time'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'time_mods'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$o</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> SPWidget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Begin By Checking to See if Widget Can Exist</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'register_sidebar_widget'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_status_press'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$widget_ops</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'classname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'widget_status_press'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Add a Social Status to your sidebar'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$control_ops</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'height'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">350</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'id_base'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'status_press'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Status Press'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$registered</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Register Widgets</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$o</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$o</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;status_press-<span style="color: #006699; font-weight: bold;">$o</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$registered</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wp_register_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$widget_ops</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$o</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wp_register_widget_control<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'control'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$control_ops</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$o</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$registered</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wp_register_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status_press-1'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$widget_ops</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wp_register_widget_control<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status_press-1'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'control'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$control_ops</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> widget<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$widget_args</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Retrieve Any Arguments</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/extract"><span style="color: #990000;">extract</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_numeric"><span style="color: #990000;">is_numeric</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget_args</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$widget_args</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$widget_args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$widget_args</span> <span style="color: #339933;">=</span> wp_parse_args<span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget_args</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/extract"><span style="color: #990000;">extract</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget_args</span><span style="color: #339933;">,</span> EXTR_SKIP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Get Options Saved in Control</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options_all</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_status_press'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options_all</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$number</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">o</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options_all</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$number</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Set Temp Values (in case they have changed)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">o</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">o</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">o</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'num'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_NOQUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$status_mods</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/htmlspecialchars_decode"><span style="color: #990000;">htmlspecialchars_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">o</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'status_mods'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$show_time</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">o</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$show_nick</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">o</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_nick'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$time_mods</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/htmlspecialchars_decode"><span style="color: #990000;">htmlspecialchars_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">o</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'time_mods'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Begin Status Press Functions</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">require_once</span> <span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> WPINC <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/rss.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Status Press'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;p&gt;You Must Supply the URL to your Facebook Status RSS Feed &lt;/p&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Adjust cache setting</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/defined"><span style="color: #990000;">defined</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MAGPIE_CACHE_AGE'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MAGPIE_CACHE_AGE'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// five minutes</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rss</span> <span style="color: #339933;">=</span> fetch_rss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rss</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">channel</span><span style="color: #009900;">&#91;</span>title<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_slice"><span style="color: #990000;">array_slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Get Status Text</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span>title<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Removes the nick in front of status text and makes any URL's into clickable links.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$show_nick</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">,</span> <a href="http://www.php.net/stripos"><span style="color: #990000;">stripos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">':'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> make_clickable<span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;p &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$status_mods</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$status</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$show_time</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get the date + time of the last update from the RSS feed.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$pubdate</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span>pubdate<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Convert this string to a time.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$pubdate</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strtotime"><span style="color: #990000;">strtotime</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pubdate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Calculate how long it's been since the status was updated.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$difference</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$today</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$pubdate</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Display how long it's been since the last update.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;&lt;p &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$time_mods</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&gt;(Updated &quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Show days if it's been more than a day.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">86400</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">86400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">86400</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' day, '</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' days, '</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$difference</span> <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">86400</span> <span style="color: #339933;">*</span> <a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">86400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Show hours if it's been more than an hour.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">3600</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">3600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">3600</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' hour, '</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' hours, '</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$difference</span> <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">3600</span> <span style="color: #339933;">*</span> <a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">3600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Show minutes if it's been more than a minute.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$difference</span> <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' minute, '</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' minutes ago)'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Status Press&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$disp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;p&gt;Status Press Error: Something bad happened! &lt;br /&gt; Here are the variables you entered: &lt;ul&gt;&lt;li&gt; Title:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/li&gt;&lt;li&gt;URL:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/li&gt;&lt;li&gt;Number:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$num</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/li&gt;&lt;li&gt;RSS: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$rss</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Call Widget</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_widget</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_title</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$after_title</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$disp</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Display Widget Content ?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$after_widget</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> control<span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget_args</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_registered_widgets</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; static <span style="color: #000088;">$updated</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_numeric"><span style="color: #990000;">is_numeric</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget_args</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$widget_args</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$widget_args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$widget_args</span> <span style="color: #339933;">=</span> wp_parse_args<span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget_args</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/extract"><span style="color: #990000;">extract</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$widget_args</span><span style="color: #339933;">,</span> EXTR_SKIP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options_all</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_status_press'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options_all</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options_all</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$updated</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sidebar'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sidebar</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sidebar'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sidebars_widgets</span> <span style="color: #339933;">=</span> wp_get_sidebars_widgets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sidebars_widgets</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$sidebar</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this_sidebar</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$sidebars_widgets</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$sidebar</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this_sidebar</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this_sidebar</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$_widget_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_status_press'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$wp_registered_widgets</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$_widget_id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'callback'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_registered_widgets</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$_widget_id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'params'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$widget_number</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_registered_widgets</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$_widget_id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'params'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;status_press-<span style="color: #006699; font-weight: bold;">$widget_number</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'widget-id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options_all</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$widget_number</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#41;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'status_press'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$widget_number</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$posted</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options_all</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$widget_number</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'social'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'social'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sanitize_url<span style="color: #009900;">&#40;</span><a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_nick'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_nick'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'num'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/intval"><span style="color: #990000;">intval</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'num'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'status_mods'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'status_mods'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_time'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_time'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'time_mods'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posted</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'time_mods'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options_all</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$widget_number</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_status_press'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options_all</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$updated</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$number</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$wpnm</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'%i%'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$values</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_options</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_status_press'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options_all</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$wpnm</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$number</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$values</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options_all</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$number</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Show Admin Screen</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p style=&quot;text-align:left;&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for=&quot;status_press-title&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title (Leave Blank to Pull Title From Feed):'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input style=&quot;width: 200px;&quot; id=&quot;status_press-title&quot; name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][title]&quot; type=&quot;text&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;script language=&quot;javascript&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function rss(social) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actSocial = social.value;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var txtUrl = document.getElementById(&quot;status_press-url[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function getUserName(actSocial) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var name = prompt(&quot;Please input your &quot; + actSocial + &quot; username here:&quot;, &quot;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } while (name == &quot;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (name!=null &amp;&amp; name!=&quot;&quot;) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return name;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; social.selectedIndex = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (actSocial) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case &quot;Facebook&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; okFB = confirm('Please ensure that you are already logged in to Facebook.');<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (okFB) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert('On the following page, please find the My Status RSS feed and copy it into the box below.');<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.open(&quot;http://www.facebook.com/minifeed.php?filter=11&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case &quot;Twitter&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name = getUserName(actSocial);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (name != null) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; txtUrl.value = &quot;http://twitter.com/statuses/user_timeline/&quot; + name + &quot;.rss&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case &quot;Last.FM&quot;:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name = getUserName(actSocial);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (name != null) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; txtUrl.value = &quot;http://ws.audioscrobbler.com/1.0/user/&quot; + name + &quot;/recenttracks.rss&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function showHide(that, element) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e = document.getElementById(element);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (that.checked) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.style.visibility = &quot;visible&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.style.visibility = &quot;hidden&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //showHide(document.getElementById(&quot;status_press-show_time[<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot;), &quot;status_press-time_mods[<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/script&gt;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p style=&quot;text-align:left;&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;span style=&quot;vertical-align: bottom;&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Social Status Network: &nbsp;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/span&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;select name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][social]&quot; id=&quot;status_press-social&quot; onchange=&quot;rss(this)&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value=&quot;&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'social'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;&lt;/option&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value=&quot;Facebook&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'social'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Facebook&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Facebook'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/option&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value=&quot;Twitter&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'social'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Twitter&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Twitter'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/option&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option value=&quot;Last.FM&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'social'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Last.FM&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Last.FM'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/option&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for=&quot;status_press-url[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Status URL Feed:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input style=&quot;width: 230px;&quot; id=&quot;status_press-url[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot; name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][url]&quot; type=&quot;text&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_nick'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_nick'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' checked=&quot;checked&quot;'</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for=&quot;status_press-show_nick&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Show nick-/username: '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;checkbox&quot; class=&quot;checkbox&quot; id=&quot;status_press-show_nick[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot; name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][show_nick]&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_nick'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p style=&quot;text-align:left;&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for=&quot;status_press-num&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Number of Status Feeds to Display &lt;br/&gt;(Use &quot;0&quot; to display All):'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input style=&quot;width: 20px;&quot; id=&quot;status_press-num&quot; name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][num]&quot; type=&quot;text&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'num'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_NOQUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p style=&quot;text-align:left;&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for=&quot;status_press-status_mods&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Stylizing Modifications for Status Tags&lt;br/&gt;(i.e. id=&quot;status_press&quot;, etc):'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input style=&quot;width: 230px;&quot; id=&quot;status_press-status_mods&quot; name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][status_mods]&quot; type=&quot;text&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'status_mods'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_time'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_time'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' checked=&quot;checked&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for=&quot;status_press-show_time&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Show Time Since Status Update: '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;checkbox&quot; class=&quot;checkbox&quot; id=&quot;status_press-show_time[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot; name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][show_time]&quot; onClick=&quot;showHide(this, \'status_press-time_mods[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]\')&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show_time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p style=&quot;text-align:left;&quot; id=&quot;status_press-time_mods[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label for=&quot;status_press-time_mods[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Stylizing Modifications for Time Since Tags &lt;br/&gt;(i.e. id=&quot;status-time&quot;, etc):'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'status-press-widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input style=&quot;width: 230px;&quot; id=&quot;status_press-time_mods[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>]&quot; name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][time_mods]&quot; type=&quot;text&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/htmlspecialchars"><span style="color: #990000;">htmlspecialchars</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'time_mods'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;hidden&quot; id=&quot;status_press-submit&quot; name=&quot;status_press[<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpnm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>][submit]&quot; value=&quot;1&quot; /&gt;<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000088;">$spw</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SPWidget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//Initialize Widget on Run</span><br />
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widgets_init'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$spw</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'init'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://briped.net/2009/12/23/status-press-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mirc.php for GeSHi</title>
		<link>http://briped.net/2007/12/12/mircphp-for-geshi/</link>
		<comments>http://briped.net/2007/12/12/mircphp-for-geshi/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 21:32:10 +0000</pubDate>
		<dc:creator>Brian Schmidt Pedersen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[mIRC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[GeSHi]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://briped.net/2007/12/12/mircphp-for-geshi/</guid>
		<description><![CDATA[Seems there were a minor issue with the mirc.php file from GeSHi causing all code entries set to be parsed as mIRC scripts to stop with an error. Fixed (or rather made a dirty hack) it so my mIRC scripts once again could be highlighted &#60;?php /************************************************************************************* * mirc.php * ----- * Author: Alberto 'Birckin' [...]]]></description>
			<content:encoded><![CDATA[<p>Seems there were a minor issue with the mirc.php file from GeSHi causing all code entries set to be parsed as mIRC scripts to stop with an error. Fixed (or rather made a dirty hack) it so my mIRC scripts once again could be highlighted <img src='http://briped.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">/*************************************************************************************<br />
* mirc.php<br />
* -----<br />
* Author: Alberto 'Birckin' de Areba (Birckin@hotmail.com)<br />
* Copyright: (c) 2006 Alberto de Areba<br />
* Release Version: 1.0.7.20<br />
* Date Started: 2006/05/29<br />
*<br />
* mIRC Scripting language file for GeSHi.<br />
*<br />
* CHANGES<br />
* -------<br />
* 2006/05/29 (1.0.0)<br />
* &nbsp; - &nbsp;First Release<br />
*<br />
* 2007/12/12 (1.0.1) - Brian Schmidt Pedersen<br />
* &nbsp; - &nbsp;Removed the forward slash from all mIRC keywords, since in actual<br />
* &nbsp; &nbsp; &nbsp; mIRC scripts, they're often written without the slash.<br />
* &nbsp; - &nbsp;Entry 6 (timer parsing) under REGEXPS caused GeSHi to halt with an error<br />
* &nbsp; &nbsp; &nbsp; simple solution was to remove the slash(es)<br />
*<br />
*************************************************************************************<br />
*<br />
* &nbsp; &nbsp; This file is part of GeSHi.<br />
*<br />
* &nbsp; GeSHi is free software; you can redistribute it and/or modify<br />
* &nbsp; it under the terms of the GNU General Public License as published by<br />
* &nbsp; the Free Software Foundation; either version 2 of the License, or<br />
* &nbsp; (at your option) any later version.<br />
*<br />
* &nbsp; GeSHi is distributed in the hope that it will be useful,<br />
* &nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
* &nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. &nbsp;See the<br />
* &nbsp; GNU General Public License for more details.<br />
*<br />
* &nbsp; You should have received a copy of the GNU General Public License<br />
* &nbsp; along with GeSHi; if not, write to the Free Software<br />
* &nbsp; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA &nbsp;02111-1307 &nbsp;USA<br />
*<br />
************************************************************************************/</span><br />
<br />
<span style="color: #000088;">$language_data</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'LANG_NAME'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'mIRC Scripting'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'COMMENT_SINGLE'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">';'</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'COMMENT_MULTI'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'CASE_KEYWORDS'</span> <span style="color: #339933;">=&gt;</span> GESHI_CAPS_NO_CHANGE<span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'QUOTEMARKS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'ESCAPE_CHAR'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'KEYWORDS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'alias'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dialog'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'if'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'elseif'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'else'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'while'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'goto'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'action'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ajinvite'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'alias'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'aline'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'amsg'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ame'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'anick'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'aop'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'auser'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'avoice'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'auto'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'autojoin'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'away'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'background'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'ban'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'beep'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'channel'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'clear'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'clearall'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'clipboard'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'close'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'closemsg'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'color'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'copy'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'creq'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ctcp'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ctcpreply'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'ctcps'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dcc'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dde'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ddeserver'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'debug'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'describe'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'disable'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'disconnect'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dlevel'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dll'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dns'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'dqwindow'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ebeeps'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'echo'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'editbox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'emailaddr'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'enable'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'exit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'filter'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'findtext'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'finger'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'flash'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'flood'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'flush'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'flushini'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'font'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fsend'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fserve'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fullname'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ghide'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gload'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gmove'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'gopts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gplay'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gpoint'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gqreq'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'groups'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gshow'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gsize'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'gstop'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gtalk'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gunload'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'guser'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'halt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'haltdef'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'help'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'hop'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ignore'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'inc'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'invite'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'join'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'kick'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'linesep'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'links'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'list'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'load'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'loadbuf'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localinfo'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'log'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'me'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'mdi'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mkdir'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mnick'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mode'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'msg'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'names'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'nick'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'noop'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'notice'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'notify'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'omsg'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'onotice'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'part'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'partall'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pdcc'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'perform'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ping'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'play'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pop'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'protect'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pvoice'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'qmsg'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'qme'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'query'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'queryrn'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'quit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'raw'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'remini'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'remote'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'remove'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rename'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'renwin'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'resetidle'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rlevel'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rmdir'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'run'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ruser'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'save'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'savebuf'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'save'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'saveini'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'say'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'server'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'set'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'showmirc'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sline'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sound'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'speak'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'splay'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'sreq'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'strip'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'time'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'timers'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'timestamp'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'titlebar'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'tnick'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tokenize'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'topic'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ulist'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'unload'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'updatenl'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'uwho'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'var'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'window'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'winhelp'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'write'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'writeini'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'who'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'whois'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'whowas'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'SYMBOLS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'('</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">')'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'{'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'}'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'['</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">']'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'|'</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'CASE_SENSITIVE'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GESHI_COMMENTS <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'STYLES'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'KEYWORDS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #994444;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #000000; font-weight: bold;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #990000; font-weight: bold;'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'COMMENTS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #808080; font-style: italic;'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'ESCAPE_CHAR'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'BRACKETS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #FF0000;'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'STRINGS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'NUMBERS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'METHODS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'SYMBOLS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #FF0000;'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'REGEXPS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #000099;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #990000;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #888800;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #888800;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">4</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #000099;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">5</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #000099;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">6</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'color: #990000; font-weight: bold;'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'SCRIPT'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'URLS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">4</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'OOLANG'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'OBJECT_SPLITTERS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'REGEXPS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'\$[^$][^ ,\(\)]*'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(%|&amp;).+?[^ ,\)]*'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(#|@).+?[^ ,\)]*'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'-[a-z\d]+'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">4</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(on|ctcp) (!|@|&amp;)?(\d|\*):[a-zA-Z]+:'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; 4 =&gt; array(<br />
&nbsp; &nbsp; &nbsp; &nbsp; GESHI_SEARCH =&gt; '((on|ctcp) (!|@|&amp;)?(\d|\*):(Action|Active|Agent|AppActive|Ban|Chat|Close|Connect|Ctcp|CtcpReply|DccServer|DeHelp|DeOp|DeVoice|Dialog|Dns|Error|Exit|FileRcvd|FileSent|GetFail|Help|Hotlink|Input|Invite|Join|KeyDown|KeyUp|Kick|Load|Logon|MidiEnd|Mode|Mp3End|Nick|NoSound|Notice|Notify|Op|Open|Part|Ping|Pong|PlayEnd|Quit|Raw|RawMode|SendFail|Serv|ServerMode|ServerOp|Signal|Snotice|Start|Text|Topic|UnBan|Unload|Unotify|User|Mode|Voice|Wallops|WaveEnd):)',<br />
&nbsp; &nbsp; &nbsp; &nbsp; GESHI_REPLACE =&gt; '\\1',<br />
&nbsp; &nbsp; &nbsp; &nbsp; GESHI_MODIFIERS =&gt; 'i',<br />
&nbsp; &nbsp; &nbsp; &nbsp; GESHI_BEFORE =&gt; '',<br />
&nbsp; &nbsp; &nbsp; &nbsp; GESHI_AFTER =&gt; ''<br />
&nbsp; &nbsp; &nbsp; &nbsp; ),<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">5</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'raw (\d|\*):'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">6</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'timer(?!s\b)[0-9a-zA-Z_]+'</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'STRICT_MODE_APPLIES'</span> <span style="color: #339933;">=&gt;</span> GESHI_NEVER<span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'SCRIPT_DELIMITERS'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'HIGHLIGHT_STRICT_BLOCK'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://briped.net/2007/12/12/mircphp-for-geshi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>calc.tcl</title>
		<link>http://briped.net/2007/06/20/calctcl/</link>
		<comments>http://briped.net/2007/06/20/calctcl/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 09:22:42 +0000</pubDate>
		<dc:creator>Brian Schmidt Pedersen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[TCL]]></category>
		<category><![CDATA[Eggdrop]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://briped.net/2007/06/20/calctcl/</guid>
		<description><![CDATA[#### calc.tcl v1.0.1 ########################################################### ################################################################################ ## Written by: &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;## ## &#160; KuNgFo0 &#160;(http://www.eggfaq.com/). &#160; &#160; &#160; &#160; &#160; &#160; &#160;## ## &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container tcl default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="tcl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#### calc.tcl v1.0.1 ###########################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## Written by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; KuNgFo0 &nbsp;(http://www.eggfaq.com/). &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Modified by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; Brian Schmidt aka. brianMan. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;">#### Readme / Help #############################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## This script is ripped from KuNgFoO's ib.tcl v3.19 (infobot) script. &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Script that can calculate just about anything ;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Usage: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; To have the .calc[ulate] commands available on a channel you need to set ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; the channel flag +calculator from the console/partyline . &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; ``.chanset #channel +calculator´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Channel Commands (available only if channel is +convert): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; .calc[ulate] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## Example: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; ``.calc 15*20+3´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;">#### Changelog #################################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## v1.0.1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## * Minor code cleanup &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## v1.0.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## + Initial release. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## * Changed the default trigger ``botname, calc[ulate]´´ to ``.calc[ulate]´´ ##</span><br />
<span style="color: #808080; font-style: italic;">## + Added the possibility to control which channels could use the commands &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; with the channel flag ``+/-calculator´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
bind pub - .calc pub_calc<br />
bind pub - .calculate pub_calc<br />
bind msg - calc msg_calc<br />
bind msg - calculate msg_calc<br />
<br />
setudef flag calculator<br />
<br />
<span style="color: #808080; font-style: italic;"># You shouldn't change these, however you may add additional variables</span><br />
<span style="color: #808080; font-style: italic;"># These are used via %varname in the 'calculate' command</span><br />
<span style="color: #808080; font-style: italic;"># Example: Mybot, calculate %pi / 2</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> calc_const<span style="color: black;">&#40;</span>pi<span style="color: black;">&#41;</span> <span style="color: #ff4500;">3.14159265358979323846</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># PI</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> calc_const<span style="color: black;">&#40;</span>e<span style="color: black;">&#41;</span> &nbsp;<span style="color: #ff4500;">2.7182818284590452354</span> &nbsp;<span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># E</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> calc_const<span style="color: black;">&#40;</span>n<span style="color: black;">&#41;</span> &nbsp;6.0221367e23 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Avogadro's number [1/mol]</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> calc_const<span style="color: black;">&#40;</span>R<span style="color: black;">&#41;</span> &nbsp;<span style="color: #ff4500;">8.314510</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Universal gas constant [J/(mol*K)]</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> calc_const<span style="color: black;">&#40;</span>k<span style="color: black;">&#41;</span> &nbsp;1.380658e-23 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Boltzmann's constant [J/K]</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> calc_const<span style="color: black;">&#40;</span>G<span style="color: black;">&#41;</span> &nbsp;6.67259e-11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Universal gravitational constant [N*m^2/kg^2]</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> calc_const<span style="color: black;">&#40;</span>h<span style="color: black;">&#41;</span> &nbsp;6.62606891e-34 &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Planck's constant [J*s]</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> calc_const<span style="color: black;">&#40;</span>c<span style="color: black;">&#41;</span> &nbsp;2.99792458e8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Speed of light [m/s]</span><br />
<br />
<span style="color: #808080; font-style: italic;"># No more editing required</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> xrange <span style="color: black;">&#123;</span>xr xr1 xr2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">join</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lrange</span> <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$xr</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$xr1</span> <span style="color: #ff3333;">$xr2</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> xindex <span style="color: black;">&#123;</span>xr xr1<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">join</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lrange</span> <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$xr</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$xr1</span> <span style="color: #ff3333;">$xr1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> calc_fixdata <span style="color: black;">&#123;</span>arg output<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> botnick<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> index <span style="color: #ff3333;">$output</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;#&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all -nocase <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output</span><span style="color: #483d8b;">'s} $arg &quot;your&quot; arg<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; regsub -all -nocase {$botnick'</span>s<span style="color: black;">&#125;</span> <span style="color: #ff3333;">$arg</span> <span style="color: #483d8b;">&quot;my&quot;</span> arg<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$arg</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> calc_msg <span style="color: black;">&#123;</span>targets arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> target <span style="color: #ff3333;">$targets</span> <span style="color: black;">&#123;</span> puthelp <span style="color: #483d8b;">&quot;PRIVMSG $target :[calc_fixdata $arg $target]&quot;</span> <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> calc_fixtopic <span style="color: black;">&#123;</span>arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>\\\<span style="color: black;">&#123;</span>\<span style="color: black;">&#125;</span>\<span style="color: black;">&#91;</span>\<span style="color: black;">&#93;</span>\<span style="color: #483d8b;">&quot;]} $arg {} &nbsp; arg ; # Bad characters<br />
&nbsp; &nbsp; regsub -all {(<span style="color: #000099; font-weight: bold;">\s</span>)+} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arg {<span style="color: #000099; font-weight: bold;">\1</span>} arg ; # Double whitespace<br />
&nbsp; &nbsp; regsub -all {^<span style="color: #000099; font-weight: bold;">\s</span>*|<span style="color: #000099; font-weight: bold;">\s</span>*$} &nbsp; &nbsp; &nbsp;$arg {} &nbsp; arg ; # Whitespace at ends<br />
&nbsp; &nbsp; return $arg<br />
}<br />
<br />
# Begin 'calc' code<br />
proc calc_fixexpr {exp} {<br />
&nbsp; &nbsp; global calc_const<br />
&nbsp; &nbsp; set exp [calc_fixtopic $exp]<br />
&nbsp; &nbsp; foreach i [array names calc_const] {<br />
&nbsp; &nbsp; &nbsp; &nbsp; regsub -all &quot;</span>\<span style="color: #66cc66;">%</span><span style="color: #ff3333;">$i</span><span style="color: #483d8b;">&quot; $exp $calc_const($i) exp<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; return $exp<br />
}<br />
# End 'calc' code<br />
<br />
# Begin Public binds code<br />
proc msg_calc {nick uhost hand arg} {<br />
&nbsp; &nbsp; global botnick<br />
&nbsp; &nbsp; pub_calc $nick $uhost $hand &quot;</span><span style="color: #483d8b;">&quot; $arg<br />
}<br />
<br />
proc pub_calc {nick uhost hand chan arg} {<br />
&nbsp; &nbsp; global botnick calc_flag<br />
&nbsp; &nbsp; if {(![isbotnick $nick]) &amp;&amp; (![matchattr $hand +b])} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; if {(![string match &quot;</span><span style="color: #ff3333;">$chan</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: #483d8b;">&quot;]) &amp;&amp; (![channel get $chan calculator])} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0 ; # If command comes from a channel, and that channel doesn't have +calculator then ignore<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; set isuser [expr {[matchattr $hand - $chan] || [matchattr $hand -]}] ; # Note that $chan might be &quot;</span><span style="color: #483d8b;">&quot;, so we must handle both cases<br />
&nbsp; &nbsp; &nbsp; &nbsp; if {([validchan $chan]) &amp;&amp; ($isuser)} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set output1 $chan ; # The bot sends the text to the channel for users<br />
&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set output1 $nick ; # Non-users get privmsg'd<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if {[set i [string last &quot;</span><span style="color: #66cc66;">&gt;</span><span style="color: #483d8b;">&quot; $arg]] == -1} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set output2 $output1 ; # By default, output2 (~stdout~) goes to output1 (~stderr~)<br />
&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Output has been redirected<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if {(!$isuser) || ([set output2 [string trim [string range $arg [expr $i + 1] end] &quot;</span> <span style="color: #483d8b;">&quot;]] == &quot;</span><span style="color: #483d8b;">&quot;)} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set output2 $output1 ; # Error (User doesn't have access, or output was &quot;</span><span style="color: #483d8b;">&quot;), so we go back to the default<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set arg [string trim [string range $arg 0 [expr $i - 1]] &quot;</span> <span style="color: #483d8b;">&quot;]<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; set remainder [xrange $arg 0 end]<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if {$remainder == &quot;</span><span style="color: #483d8b;">&quot;} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; calc_msg $output1 &quot;</span><span style="color: #ff7700;font-weight:bold;">error</span> parsing sentence<span style="color: #483d8b;">&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; } elseif {[catch {expr [calc_fixexpr $remainder]} output]} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; calc_msg $output1 &quot;</span><span style="color: #ff7700;font-weight:bold;">error</span> calculating <span style="color: #483d8b;">'$remainder'</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$output</span><span style="color: black;">&#41;</span><span style="color: #483d8b;">&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; calc_msg $output2 &quot;</span><span style="color: #ff3333;">$remainder</span> = <span style="color: #ff3333;">$output</span><span style="color: #483d8b;">&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
}<br />
# End Public binds code<br />
<br />
# Init stuff<br />
if {[catch {package require Tcl 8.2} error]} {<br />
&nbsp; &nbsp; putlog &quot;</span><span style="color: #ff7700;font-weight:bold;">error</span> TCL v8.2 or higher is required to run this script<span style="color: #483d8b;">&quot;<br />
&nbsp; &nbsp; return 0<br />
}<br />
<br />
putlog &quot;</span><span style="color: #66cc66;">***</span> LOADED: calc.tcl<span style="color: #483d8b;">&quot;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://briped.net/2007/06/20/calctcl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>convert.tcl</title>
		<link>http://briped.net/2007/06/20/converttcl/</link>
		<comments>http://briped.net/2007/06/20/converttcl/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 09:22:00 +0000</pubDate>
		<dc:creator>Brian Schmidt Pedersen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[TCL]]></category>
		<category><![CDATA[Eggdrop]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://briped.net/2007/06/20/converttcl/</guid>
		<description><![CDATA[#### convert.tcl v1.0.1 ######################################################## ################################################################################ ## Written by: &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;## ## &#160; KuNgFo0 &#160;(http://www.eggfaq.com/). &#160; &#160; &#160; &#160; &#160; &#160; &#160;## ## &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container tcl default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="tcl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#### convert.tcl v1.0.1 ########################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## Written by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; KuNgFo0 &nbsp;(http://www.eggfaq.com/). &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Modified by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; Brian Schmidt aka. brianMan. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;">#### Readme / Help #############################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## This script is ripped from KuNgFoO's ib.tcl v3.19 (infobot) script. &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## The script converts between a number of various units, for more speficic &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## information on which untis you should please refer to the source of this &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## script. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Usage: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; To have the .conv[ert] commands available on a channel you need to set &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; the channel flag +convert from the console/partyline . &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; ``.chanset #channel +convert´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Channel Commands (available only if channel is +convert): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; .conv[ert] &nbsp; to &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## Example: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; ``.conv 20 C to F´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; Converts 20 degrees Celcius to it's Fahrenheit equivilant. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;">#### Changelog #################################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## v1.0.1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## * Minor code cleanup &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## v1.0.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## + Initial release. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## * Changed the default trigger ``botname, conv[ert]´´ to ``.con[vert]´´ &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## + Added the possibility to control which channels could use the commands &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; with the channel flag ``+/-convert´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
bind pub - .conv pub_conv<br />
bind pub - .convert pub_conv<br />
bind msg - conv msg_conv<br />
bind msg - convert msg_conv<br />
<br />
<span style="color: #808080; font-style: italic;"># Set the name of the channelflag used to tell whether the convert command is</span><br />
<span style="color: #808080; font-style: italic;"># enabled or not for that specific channel.</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_channel_flag <span style="color: #483d8b;">&quot;convert&quot;</span><br />
<br />
setudef flag <span style="color: #ff3333;">$conv_channel_flag</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as the exec command to run the 'units' command from the shell</span><br />
<span style="color: #808080; font-style: italic;"># Note: Not all systems will have this installed</span><br />
<span style="color: #808080; font-style: italic;"># Set to &quot;&quot; to disable</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_units_exec <span style="color: #483d8b;">&quot;units -v&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Conversion formulas - each array is for its own dimension (length, volume, etc).</span><br />
<span style="color: #808080; font-style: italic;"># Each unit is converted to a standard type by multiplying the value by the factors</span><br />
<span style="color: #808080; font-style: italic;"># below. &nbsp;It is then converted from the standard type to any other unit by</span><br />
<span style="color: #808080; font-style: italic;"># dividing the factors. &nbsp;The standard unit used must be the same for everything in</span><br />
<span style="color: #808080; font-style: italic;"># each dimension, and can be anything as long as they are the same. &nbsp;I used the root</span><br />
<span style="color: #808080; font-style: italic;"># metric units for most things (meters, liters, grams, etc).</span><br />
<span style="color: #808080; font-style: italic;"># Note: All strings are matched as regular expressions</span><br />
<span style="color: #808080; font-style: italic;"># * Prefix with (?c) for units that should be case sensitive</span><br />
<span style="color: #808080; font-style: italic;"># * Prefix with (.*?) for metric units</span><br />
<span style="color: #808080; font-style: italic;"># * Append (?:s) for units with an optional plural ending, etc</span><br />
<span style="color: #808080; font-style: italic;"># * Only use multiplication and division in the formulas, no addition or subtraction</span><br />
<span style="color: #808080; font-style: italic;"># * It's a very good idea to have all the formulas return values in decimal form</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp; (&quot;1&quot; doesn't matter, though)</span><br />
<span style="color: #808080; font-style: italic;"># Syntax:</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp;name abbreviation factor</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_unit<span style="color: black;">&#40;</span>length<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>meter<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>m <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; inch<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:es<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">in</span> &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: #ff4500;">2.54</span> / <span style="color: #ff4500;">100</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; foot|feet &nbsp; &nbsp; &nbsp; &nbsp;ft &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: #ff4500;">2.54</span> / <span style="color: #ff4500;">100</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">12</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; mile<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; mi &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: #ff4500;">2.54</span> / <span style="color: #ff4500;">100</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">12</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">5280</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_unit<span style="color: black;">&#40;</span>volume<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>liter<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>L <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; pint<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; pt &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: #ff4500;">3.785</span> / <span style="color: #ff4500;">8</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; quart<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp;qt &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: #ff4500;">3.785</span> / <span style="color: #ff4500;">4</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; gallon<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; gal &nbsp; &nbsp;<span style="color: #ff4500;">3.785</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_unit<span style="color: black;">&#40;</span>weight<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>gram<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>g <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; ounce<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; oz &nbsp; &nbsp; <span style="color: #ff4500;">28.35</span><br />
&nbsp; &nbsp; pound<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; lbs &nbsp; &nbsp;<span style="color: #ff4500;">453.59</span><br />
&nbsp; &nbsp; ton<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; T &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: #ff4500;">453.59</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">2000</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_unit<span style="color: black;">&#40;</span>work<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>joule<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>J &nbsp; &nbsp; &nbsp;<span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>watt-<span style="color: #66cc66;">?</span>second<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp;<span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>w-<span style="color: #66cc66;">?</span>s &nbsp; <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>watt-<span style="color: #66cc66;">?</span>hour<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp;<span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>w-<span style="color: #66cc66;">?</span>hrs <span style="color: #ff4500;">3600.0</span><br />
&nbsp; &nbsp; britishthermalunit<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> btu &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff4500;">1055.056</span><br />
&nbsp; &nbsp; calorie<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cal &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff4500;">4.1868</span><br />
&nbsp; &nbsp; foot-<span style="color: #66cc66;">?</span>pound<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp;ft-<span style="color: #66cc66;">?</span>lbs &nbsp; &nbsp; <span style="color: #ff4500;">1.356</span><br />
&nbsp; &nbsp; electron-<span style="color: #66cc66;">?</span>volt<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; eV &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1.6021917E-19<br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_unit<span style="color: black;">&#40;</span>power<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>watt<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>w <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; volt-<span style="color: #66cc66;">?</span>amp<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> va &nbsp; &nbsp; <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; horsepower &nbsp; &nbsp; &nbsp;hp &nbsp; &nbsp; <span style="color: #ff4500;">746</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_unit<span style="color: black;">&#40;</span><span style="color: #008000;">time</span><span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>second<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>s<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:ec<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; minute<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp;min<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff4500;">60.0</span><br />
&nbsp; &nbsp; hour<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp;h<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:r<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: #ff4500;">60.0</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">60</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; day<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: #ff4500;">60.0</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">24</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; week<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp;wk<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: #ff4500;">60.0</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">24</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">7</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; year<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp;yr<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: #ff4500;">60.0</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">24</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">365</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; decade<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: #ff4500;">60.0</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">24</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">365</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">10</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; century|centuries <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: #ff4500;">60.0</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">24</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">365</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">100</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_unit<span style="color: black;">&#40;</span><span style="color: #008000;">binary</span><span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; option metric <span style="color: #ff4500;">2</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>byte<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>b <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; <span style="color: black;">&#40;</span>.<span style="color: #66cc66;">*?</span><span style="color: black;">&#41;</span>bit<span style="color: black;">&#40;</span><span style="color: #66cc66;">?</span>:s<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span> &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: #ff4500;">1.0</span> / <span style="color: #ff4500;">8</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Misc conversion formulas - these are types that cannot</span><br />
<span style="color: #808080; font-style: italic;"># be converted by regular multiplication/division of factors.</span><br />
<span style="color: #808080; font-style: italic;"># The principle is the same as the formulas above, however</span><br />
<span style="color: #808080; font-style: italic;"># the arrays are broken down into *_from and *_to variables.</span><br />
<span style="color: #808080; font-style: italic;"># Note: $value is used as the value being converted.</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_misc_from<span style="color: black;">&#40;</span>num<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; option metric <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; integer|int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;%d&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; long &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;%u&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; decimal|dec|float|double <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;%f&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; octal|oct &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;%o&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; hexadecimal|hex &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;%x&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">binary</span>|bin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>bin2int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; ip &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>ip2long <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; rgb &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>rgb2int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_misc_to<span style="color: black;">&#40;</span>num<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; option metric <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; integer|int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%d&quot;</span> <span style="color: black;">&#91;</span>conv_int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; long &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%u&quot;</span> <span style="color: black;">&#91;</span>conv_int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; decimal|dec|float|double <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%f&quot;</span> <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; octal|oct &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%o&quot;</span> <span style="color: black;">&#91;</span>conv_int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; hexadecimal|hex &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%X&quot;</span> <span style="color: black;">&#91;</span>conv_int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">binary</span>|bin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>int2bin <span style="color: black;">&#91;</span>conv_int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; ip &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>long2ip <span style="color: black;">&#91;</span>conv_int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; rgb &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>int2rgb <span style="color: black;">&#91;</span>conv_int <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_misc_from<span style="color: black;">&#40;</span>temperature<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; option metric <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; fahrenheit &nbsp; &nbsp; &nbsp; &nbsp; F <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$value</span> - <span style="color: #ff4500;">32</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">5</span> / <span style="color: #ff4500;">9.0</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; kelvin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; K <span style="color: black;">&#123;</span><span style="color: #ff3333;">$value</span> - <span style="color: #ff4500;">273.15</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; celsius|centigrade C <span style="color: black;">&#123;</span><span style="color: #ff3333;">$value</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_misc_to<span style="color: black;">&#40;</span>temperature<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; option metric <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; fahrenheit &nbsp; &nbsp; &nbsp; &nbsp; F <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">9</span> / <span style="color: #ff4500;">5.0</span> <span style="color: #66cc66;">*</span> <span style="color: #ff3333;">$value</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">32</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; kelvin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; K <span style="color: black;">&#123;</span><span style="color: #ff3333;">$value</span> + <span style="color: #ff4500;">273.15</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; celsius|centigrade C <span style="color: black;">&#123;</span><span style="color: #ff3333;">$value</span><span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Conversion strings to specificially ignore (that conflict with expr)</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_ignore <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; e abs acos asin<br />
&nbsp; &nbsp; atan atan2 ceil<br />
&nbsp; &nbsp; cos cosh double<br />
&nbsp; &nbsp; exp floor fmod<br />
&nbsp; &nbsp; hypot int log<br />
&nbsp; &nbsp; log10 pow rand<br />
&nbsp; &nbsp; round sin sinh<br />
&nbsp; &nbsp; sqrt srand tan<br />
&nbsp; &nbsp; tanh<br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Metric conversion factors</span><br />
<span style="color: #808080; font-style: italic;"># Note: Abbreviations are case sensitive here</span><br />
<span style="color: #808080; font-style: italic;"># Syntax:</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp;mame abbreviation factor</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> conv_metric <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; Yotta Y &nbsp;<span style="color: #ff4500;">24</span><br />
&nbsp; &nbsp; Zetta Z &nbsp;<span style="color: #ff4500;">21</span><br />
&nbsp; &nbsp; Exa &nbsp; E &nbsp;<span style="color: #ff4500;">18</span><br />
&nbsp; &nbsp; Peta &nbsp;P &nbsp;<span style="color: #ff4500;">15</span><br />
&nbsp; &nbsp; Tera &nbsp;T &nbsp;<span style="color: #ff4500;">12</span><br />
&nbsp; &nbsp; Giga &nbsp;G &nbsp;<span style="color: #ff4500;">9</span><br />
&nbsp; &nbsp; Mega &nbsp;M &nbsp;<span style="color: #ff4500;">6</span><br />
&nbsp; &nbsp; Kilo &nbsp;k &nbsp;<span style="color: #ff4500;">3</span><br />
&nbsp; &nbsp; Hecto h &nbsp;<span style="color: #ff4500;">2</span><br />
&nbsp; &nbsp; Deca &nbsp;dk <span style="color: #ff4500;">1</span><br />
<br />
&nbsp; &nbsp; Deci &nbsp;d &nbsp;-<span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; Centi c &nbsp;-<span style="color: #ff4500;">2</span><br />
&nbsp; &nbsp; Milli m &nbsp;-<span style="color: #ff4500;">3</span><br />
&nbsp; &nbsp; Micro µ &nbsp;-<span style="color: #ff4500;">6</span><br />
&nbsp; &nbsp; Nano &nbsp;n &nbsp;-<span style="color: #ff4500;">9</span><br />
&nbsp; &nbsp; Pico &nbsp;p &nbsp;-<span style="color: #ff4500;">12</span><br />
&nbsp; &nbsp; Femto f &nbsp;-<span style="color: #ff4500;">15</span><br />
&nbsp; &nbsp; Atto &nbsp;a &nbsp;-<span style="color: #ff4500;">18</span><br />
&nbsp; &nbsp; Zepto z &nbsp;-<span style="color: #ff4500;">21</span><br />
&nbsp; &nbsp; Yocto y &nbsp;-<span style="color: #ff4500;">24</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> xrange <span style="color: black;">&#123;</span>xr xr1 xr2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">join</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lrange</span> <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$xr</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$xr1</span> <span style="color: #ff3333;">$xr2</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> anymatch <span style="color: black;">&#123;</span>string1 string2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> <span style="color: #008000;">string</span> <span style="color: #ff3333;">$string2</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">lsearch</span> -exact <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: #ff3333;">$string1</span><span style="color: black;">&#93;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: #ff3333;">$string</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_fixtopic <span style="color: black;">&#123;</span>arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>\\\<span style="color: black;">&#123;</span>\<span style="color: black;">&#125;</span>\<span style="color: black;">&#91;</span>\<span style="color: black;">&#93;</span>\<span style="color: #483d8b;">&quot;]} $arg {} &nbsp; arg ; # Bad characters<br />
&nbsp; &nbsp; regsub -all {(<span style="color: #000099; font-weight: bold;">\s</span>)+} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arg {<span style="color: #000099; font-weight: bold;">\1</span>} arg ; # Double whitespace<br />
&nbsp; &nbsp; regsub -all {^<span style="color: #000099; font-weight: bold;">\s</span>*|<span style="color: #000099; font-weight: bold;">\s</span>*$} &nbsp; &nbsp; &nbsp;$arg {} &nbsp; arg ; # Whitespace at ends<br />
&nbsp; &nbsp; return $arg<br />
}<br />
<br />
proc conv_fixdata {arg output} {<br />
&nbsp; &nbsp; global botnick<br />
&nbsp; &nbsp; if {[string index $output 0] != &quot;</span><span style="color: #808080; font-style: italic;">#&quot;} {</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all -nocase <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output</span><span style="color: #483d8b;">'s} $arg &quot;your&quot; arg<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; regsub -all -nocase {$botnick'</span>s<span style="color: black;">&#125;</span> <span style="color: #ff3333;">$arg</span> <span style="color: #483d8b;">&quot;my&quot;</span> arg<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$arg</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_msg <span style="color: black;">&#123;</span>targets arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> target <span style="color: #ff3333;">$targets</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; puthelp <span style="color: #483d8b;">&quot;PRIVMSG $target :[conv_fixdata $arg $target]&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_fixexpr <span style="color: black;">&#123;</span>exp<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> ib_const<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> exp <span style="color: black;">&#91;</span>conv_fixtopic <span style="color: #ff3333;">$exp</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> i <span style="color: black;">&#91;</span>array names ib_const<span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\%</span>$i&quot;</span> <span style="color: #ff3333;">$exp</span> <span style="color: #ff3333;">$ib_const</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$i</span><span style="color: black;">&#41;</span> exp<br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$exp</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Begin conversion code</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> int2bin <span style="color: black;">&#123;</span>int<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%s.%s.%s.%s&quot;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span>byte2bin <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$int</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">24</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span>byte2bin <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$int</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">16</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span>byte2bin <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$int</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span> &nbsp;<span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span>byte2bin <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$int</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> byte2bin <span style="color: black;">&#123;</span>byte<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> result <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#123;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$i</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">8</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #008000;">incr</span> i<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">append</span> result <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$byte</span> <span style="color: #66cc66;">&amp;</span> <span style="color: #ff4500;">128</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">7</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> byte <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$byte</span> <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$result</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> bin2int <span style="color: black;">&#123;</span>bin<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> result <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#123;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$i</span> <span style="color: #66cc66;">&lt;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> length <span style="color: #ff3333;">$bin</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #008000;">incr</span> i<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> digit <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> index <span style="color: #ff3333;">$bin</span> <span style="color: #ff3333;">$i</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> == <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: #ff3333;">$digit</span> == <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> result <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$result</span> <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">1</span> | <span style="color: #ff3333;">$digit</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$digit</span> == <span style="color: #483d8b;">&quot;.&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#ignore</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> result <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$result</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> ip2long <span style="color: black;">&#123;</span>ip<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$ip</span> <span style="color: #483d8b;">&quot;%d.%d.%d.%d&quot;</span> a b c d<span style="color: black;">&#93;</span> == <span style="color: #ff4500;">4</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> i <span style="color: #483d8b;">&quot;$a $b $c $d&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$i</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">255</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: #ff3333;">$i</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> long <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$a</span> <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">24</span> | <span style="color: #ff3333;">$b</span> <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">16</span> | <span style="color: #ff3333;">$c</span> <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">8</span> | <span style="color: #ff3333;">$d</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$long</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> long <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> pow<span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">32</span><span style="color: black;">&#41;</span> + <span style="color: #ff3333;">$long</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$long</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> long2ip <span style="color: black;">&#123;</span>long<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%d.%d.%d.%d&quot;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$long</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">24</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$long</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">16</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$long</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span> &nbsp;<span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$long</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> rgb2int <span style="color: black;">&#123;</span>rgb<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$rgb</span> <span style="color: #483d8b;">&quot;%d.%d.%d&quot;</span> red green blue<span style="color: black;">&#93;</span> == <span style="color: #ff4500;">3</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span> <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$red</span> <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">16</span> | <span style="color: #ff3333;">$green</span> <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">8</span> | <span style="color: #ff3333;">$blue</span> <span style="color: #66cc66;">&lt;&lt;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: black;">&#125;</span> \<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span> <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> int2rgb <span style="color: black;">&#123;</span>long<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%d.%d.%d&quot;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$long</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">16</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$long</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span> &nbsp;<span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span> \<br />
&nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$long</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&amp;</span> 0xff<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># expr's abs() and int() can't handle large unsigned integers,</span><br />
<span style="color: #808080; font-style: italic;"># these functions are just to get around this</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_int <span style="color: black;">&#123;</span>value<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;.&quot;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_abs <span style="color: black;">&#123;</span>value<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trimleft <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;-&quot;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_absint <span style="color: black;">&#123;</span>value<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span>conv_int <span style="color: black;">&#91;</span>conv_abs <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_units <span style="color: black;">&#123;</span>value type1 type2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> conv_units_exec<br />
&nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all <span style="color: black;">&#123;</span><span style="color: #483d8b;">'} [conv_fixtopic $type1] {} type1<br />
&nbsp; &nbsp; regsub -all {'</span><span style="color: black;">&#125;</span> <span style="color: black;">&#91;</span>conv_fixtopic <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> type2<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #008000;">exec</span> bash -c <span style="color: #483d8b;">&quot;$conv_units_exec '$value $type1' '$type2'&quot;</span><span style="color: black;">&#125;</span> output<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> line <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$output</span> \n<span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">regexp</span> -- <span style="color: black;">&#123;</span>^\s<span style="color: #66cc66;">*</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>^=<span style="color: black;">&#93;</span>+=.+<span style="color: black;">&#41;</span><span style="color: #66cc66;">$</span><span style="color: black;">&#125;</span> <span style="color: #ff3333;">$line</span> tmp result<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$result</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #483d8b;">&quot;unknown response from units command&quot;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_scan <span style="color: black;">&#123;</span>var_formula var_unit index<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> conv_ignore conv_unit<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">upvar</span> <span style="color: #ff4500;">1</span> <span style="color: #ff3333;">$var_formula</span> formula <span style="color: #ff3333;">$var_unit</span> unit<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #008000;">string</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>a-z<span style="color: black;">&#93;</span>+<span style="color: black;">&#40;</span>-<span style="color: black;">&#91;</span>a-z<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">regexp</span> -nocase -start <span style="color: #ff3333;">$index</span> -- <span style="color: #ff3333;">$string</span> <span style="color: #ff3333;">$formula</span> a unit<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">lsearch</span> -exact <span style="color: #ff3333;">$conv_ignore</span> <span style="color: #ff3333;">$unit</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Ignore this unit and search for the next unit</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">regexp</span> -nocase -start <span style="color: #ff3333;">$index</span> -indices <span style="color: #ff3333;">$string</span> -- <span style="color: #ff3333;">$formula</span> a index<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span>conv_scan <span style="color: #483d8b;">&quot;formula&quot;</span> <span style="color: #483d8b;">&quot;unit&quot;</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$index</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Found unit, return ok</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># No more units found</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># $var will be either unit, misc_from, or misc_to</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv <span style="color: black;">&#123;</span>value unit var lists<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> conv_<span style="color: #ff3333;">$var</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">upvar</span> <span style="color: #ff4500;">1</span> <span style="color: #008000;">list</span> uplist<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> exists uplist<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> uplist <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> type <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$var</span> == <span style="color: #483d8b;">&quot;unit&quot;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: #ff3333;">$var</span> == <span style="color: #483d8b;">&quot;misc_from&quot;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">?</span> <span style="color: #483d8b;">&quot;*&quot;</span> : <span style="color: #483d8b;">&quot;/&quot;</span><span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># First we check full names, then abbreviations</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> <span style="color: #ff7700;font-weight:bold;">method</span> <span style="color: black;">&#123;</span>name abbv<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> <span style="color: #008000;">list</span> <span style="color: #ff3333;">$lists</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Default options</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> option_absint <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> option_metric <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> <span style="color: black;">&#123;</span>name abbv formula<span style="color: black;">&#125;</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> conv_<span style="color: #ff3333;">$var</span>\<span style="color: black;">&#40;</span><span style="color: #ff3333;">$list</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$name</span> == <span style="color: #483d8b;">&quot;option&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> option_<span style="color: #ff3333;">$abbv</span> <span style="color: #ff3333;">$formula</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">regexp</span> -nocase -- <span style="color: #483d8b;">&quot;^([set $method])<span style="color: #000099; font-weight: bold;">\$</span>&quot;</span> <span style="color: #ff3333;">$unit</span> a b prefix<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> uplist <span style="color: #ff3333;">$list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$formula</span><span style="color: black;">&#125;</span> value<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: #ff3333;">$value</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #483d8b;">&quot;evaluating expression for '$unit'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$option_absint</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> value <span style="color: black;">&#91;</span>conv_absint <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$option_metric</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$prefix</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#91;</span>conv_metric <span style="color: #ff3333;">$prefix</span> <span style="color: #ff3333;">$method</span> <span style="color: #ff3333;">$option_metric</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$type</span> <span style="color: #ff3333;">$value</span><span style="color: black;">&#125;</span> value<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #483d8b;">&quot;evaluating metric conversion for '$unit'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$value</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #483d8b;">&quot;unknown conversion type '$unit'&quot;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># $method will be either &quot;name&quot; or &quot;abbv&quot;</span><br />
<span style="color: #808080; font-style: italic;"># $option will be either 1 or 2</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> conv_metric <span style="color: black;">&#123;</span>prefix <span style="color: #ff7700;font-weight:bold;">method</span> option<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> conv_metric<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> <span style="color: black;">&#123;</span>name abbv factor<span style="color: black;">&#125;</span> <span style="color: #ff3333;">$conv_metric</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$method</span> == <span style="color: #483d8b;">&quot;name&quot;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> equal -nocase <span style="color: #ff3333;">$name</span> <span style="color: #ff3333;">$prefix</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$method</span> == <span style="color: #483d8b;">&quot;abbv&quot;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> equal <span style="color: #ff3333;">$abbv</span> <span style="color: #ff3333;">$prefix</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$option</span> == <span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> pow<span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span>, <span style="color: #ff3333;">$factor</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Regular metric</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$option</span> == <span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> pow<span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span>, <span style="color: black;">&#40;</span><span style="color: #ff3333;">$factor</span> / <span style="color: #ff4500;">3</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Binary conversion</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #483d8b;">&quot;unknown metric prefix&quot;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #808080; font-style: italic;"># End conversion code</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Begin Public binds code</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> msg_conv <span style="color: black;">&#123;</span>nick uhost hand arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> botnick<br />
&nbsp; &nbsp; pub_conv <span style="color: #ff3333;">$nick</span> <span style="color: #ff3333;">$uhost</span> <span style="color: #ff3333;">$hand</span> <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #ff3333;">$arg</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> pub_conv <span style="color: black;">&#123;</span>nick uhost hand chan arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> botnick value <span style="color: #ff7700;font-weight:bold;">global</span> conv_channel_flag<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> conv_units_exec conv_unit conv_misc_from conv_misc_to<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span>isbotnick <span style="color: #ff3333;">$nick</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span>matchattr <span style="color: #ff3333;">$hand</span> +b<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> match <span style="color: #483d8b;">&quot;$chan&quot;</span> <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span>channel get <span style="color: #ff3333;">$chan</span> <span style="color: #ff3333;">$conv_channel_flag</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># If command comes from a channel, and that channel doesn't have +convert then ignore</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> isuser <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>matchattr <span style="color: #ff3333;">$hand</span> - <span style="color: #ff3333;">$chan</span><span style="color: black;">&#93;</span> || <span style="color: black;">&#91;</span>matchattr <span style="color: #ff3333;">$hand</span> -<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Note that $chan might be &quot;&quot;, so we must handle both cases</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>validchan <span style="color: #ff3333;">$chan</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> output1 <span style="color: #ff3333;">$chan</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># The bot sends the text to the channel for users</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> output1 <span style="color: #ff3333;">$nick</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Non-users get privmsg'd</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> last <span style="color: #483d8b;">&quot;&gt;&quot;</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> == -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> output2 <span style="color: #ff3333;">$output1</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># By default, output2 (~stdout~) goes to output1 (~stderr~)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Output has been redirected</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> output2 <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trim <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> range <span style="color: #ff3333;">$arg</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> end<span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> output2 <span style="color: #ff3333;">$output1</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Error (User doesn't have access, or output was &quot;&quot;), so we go back to the default</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> arg <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trim <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> range <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">0</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> - <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> remainder <span style="color: black;">&#91;</span>xrange <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">0</span> end<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$remainder</span> <span style="color: #483d8b;">&quot;%s from %s to %s&quot;</span> value type1 type2<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>anymatch <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$value</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span>from to<span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$remainder</span> <span style="color: #483d8b;">&quot;%s from %s %s&quot;</span> &nbsp; &nbsp;value type1 type2<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>anymatch <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$value</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span>from to<span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$remainder</span> <span style="color: #483d8b;">&quot;%s %s to %s&quot;</span> &nbsp; &nbsp; &nbsp;value type1 type2<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>anymatch <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$value</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span>from to<span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$remainder</span> <span style="color: #483d8b;">&quot;%s %s %s&quot;</span> &nbsp; &nbsp; &nbsp; &nbsp; value type1 type2<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>anymatch <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$value</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span>from to<span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> exists value<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>unset value<span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> || <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$remainder</span> <span style="color: #483d8b;">&quot;from %s to %s&quot;</span> &nbsp; &nbsp;type1 type2<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>anymatch <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span>from to<span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$remainder</span> <span style="color: #483d8b;">&quot;from %s %s&quot;</span> &nbsp; &nbsp; &nbsp; type1 type2<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>anymatch <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span>from to<span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$remainder</span> <span style="color: #483d8b;">&quot;%s to %s&quot;</span> &nbsp; &nbsp; &nbsp; &nbsp; type1 type2<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>anymatch <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span>from to<span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$remainder</span> <span style="color: #483d8b;">&quot;%s %s&quot;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;type1 type2<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>anymatch <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span>from to<span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error parsing sentence&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> exists value<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> value <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span>conv <span style="color: #ff3333;">$value</span> &nbsp; &nbsp; &nbsp; <span style="color: #ff3333;">$type1</span> <span style="color: #483d8b;">&quot;misc_from&quot;</span> <span style="color: black;">&#91;</span>array names conv_misc_from<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> type1_value<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span>conv <span style="color: #ff3333;">$type1_value</span> <span style="color: #ff3333;">$type2</span> <span style="color: #483d8b;">&quot;misc_to&quot;</span> &nbsp; <span style="color: #ff3333;">$list</span><span style="color: black;">&#125;</span> type2_value<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error $type2_value&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;$value $type1 = $type2_value $type2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$conv_units_exec</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span>conv_units <span style="color: #ff3333;">$value</span> <span style="color: #ff3333;">$type1</span> <span style="color: #ff3333;">$type2</span><span style="color: black;">&#125;</span> output<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output2</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> type1_formula <span style="color: #ff3333;">$type1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> type2_formula <span style="color: #ff3333;">$type2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> found <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>conv_scan <span style="color: #483d8b;">&quot;type1_formula&quot;</span> <span style="color: #483d8b;">&quot;type1_unit&quot;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span>conv_scan <span style="color: #483d8b;">&quot;type2_formula&quot;</span> <span style="color: #483d8b;">&quot;type2_unit&quot;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error unmatched type '$type1_unit'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span>conv <span style="color: #ff4500;">1</span> <span style="color: #ff3333;">$type1_unit</span> <span style="color: #483d8b;">&quot;unit&quot;</span> <span style="color: black;">&#91;</span>array names conv_unit<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> type1_value<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error $type1_value&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">regsub</span> -nocase <span style="color: #ff3333;">$type1_unit</span> <span style="color: #ff3333;">$type1_formula</span> <span style="color: #ff3333;">$type1_value</span> type1_formula<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error decompiling expression '$type1_unit'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span>conv <span style="color: #ff4500;">1</span> <span style="color: #ff3333;">$type2_unit</span> <span style="color: #483d8b;">&quot;unit&quot;</span> <span style="color: #ff3333;">$list</span><span style="color: black;">&#125;</span> type2_value<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error $type2_value&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">regsub</span> -nocase <span style="color: #ff3333;">$type2_unit</span> <span style="color: #ff3333;">$type2_formula</span> <span style="color: #ff3333;">$type2_value</span> type2_formula<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error decompiling expression '$type2_unit'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> found<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">continue</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>conv_scan <span style="color: #483d8b;">&quot;type2_formula&quot;</span> <span style="color: #483d8b;">&quot;type2_unit&quot;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error unmatched type '$type2_unit'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">break</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># At the end, so stop</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># We got an error somewhere, bail out</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$found</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error no conversion types found&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#91;</span>conv_fixexpr <span style="color: #483d8b;">&quot;($value) * ($type1_formula) / ($type2_formula)&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> value2<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error evaluating expression&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conv_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;$value $type1 = $value2 $type2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #808080; font-style: italic;"># End Public binds code</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Init stuff</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #008000;">package</span> require Tcl <span style="color: #ff4500;">8.3</span><span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">error</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; putlog <span style="color: #483d8b;">&quot;error TCL v8.3 or higher is required to run this script&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span><br />
<span style="color: black;">&#125;</span><br />
<br />
putlog <span style="color: #483d8b;">&quot;*** LOADED: convert.tcl&quot;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://briped.net/2007/06/20/converttcl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>faq.tcl</title>
		<link>http://briped.net/2007/06/20/faqtcl/</link>
		<comments>http://briped.net/2007/06/20/faqtcl/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 09:21:28 +0000</pubDate>
		<dc:creator>Brian Schmidt Pedersen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[TCL]]></category>
		<category><![CDATA[Eggdrop]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://briped.net/2007/06/20/faqtcl/</guid>
		<description><![CDATA[#### faq.tcl v1.0.0 ############################################################ ################################################################################ ## Written by: &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;## ## &#160; KuNgFo0 &#160;(http://www.eggfaq.com/). &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container tcl default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="tcl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#### faq.tcl v1.0.0 ############################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## Written by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; KuNgFo0 &nbsp;(http://www.eggfaq.com/). &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Modified by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; Brian Schmidt aka. brianMan. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;">#### Readme / Help #############################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## This script is ripped from KuNgFoO's ib.tcl v3.19 (infobot) script. &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;">#### Changelog #################################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## v1.0.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## + Initial release. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## + Added the possibility to control which channels could use the commands &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; with a channel flag. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## * Applied a dirty hack to solve a minor redirection bug, which caused all &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; add/append/remove commands that contained a &gt; to break the script. &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set next line as the directory where the database files are</span><br />
<span style="color: #808080; font-style: italic;"># located (no other files should be in the same dir)</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_dir <span style="color: #483d8b;">&quot;data/&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as the default database to save changes to</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_database <span style="color: #483d8b;">&quot;FooBot.dat&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># What should the channel flag be, to enable the FAQ for that channel?</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_channel_flag <span style="color: #483d8b;">&quot;faq&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># The default value should be ok for the next two:</span><br />
<span style="color: #808080; font-style: italic;"># Set the next line as the format to display time in (without timezone)</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_format_notz <span style="color: #483d8b;">&quot;%H:%M:%S - %A, %B %d, %Y&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as the format to display time in (with timezone)</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_format <span style="color: #483d8b;">&quot;$faq_format_notz %Z&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as the maxinum number of matches to</span><br />
<span style="color: #808080; font-style: italic;"># return on searches</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_max <span style="color: #ff4500;">5</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as the maxinum number of lines to</span><br />
<span style="color: #808080; font-style: italic;"># return publicly</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_max_lines <span style="color: #ff4500;">3</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as the flag required to add/remove</span><br />
<span style="color: #808080; font-style: italic;"># questions and etc</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_flag <span style="color: #483d8b;">&quot;+f&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as how often to save changes to the database</span><br />
<span style="color: #808080; font-style: italic;"># (in minutes)</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> faq_time <span style="color: #ff4500;">10</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> xrange <span style="color: black;">&#123;</span>xr xr1 xr2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">join</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lrange</span> <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$xr</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$xr1</span> <span style="color: #ff3333;">$xr2</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> xindex <span style="color: black;">&#123;</span>xr xr1<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">join</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lrange</span> <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$xr</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$xr1</span> <span style="color: #ff3333;">$xr1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> validnum <span style="color: black;">&#123;</span>num<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#91;</span><span style="color: #008000;">scan</span> <span style="color: #ff3333;">$num</span> <span style="color: #483d8b;">&quot;%f%s&quot;</span> a b<span style="color: black;">&#93;</span> == <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> anymatch <span style="color: black;">&#123;</span>string1 string2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> <span style="color: #008000;">string</span> <span style="color: #ff3333;">$string2</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">lsearch</span> -exact <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: #ff3333;">$string1</span><span style="color: black;">&#93;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: #ff3333;">$string</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> parseurl <span style="color: black;">&#123;</span>url<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> var <span style="color: black;">&#123;</span>protocol user pass server port path cgiargs anchor<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span> <span style="color: #ff7700;font-weight:bold;">upvar</span> <span style="color: #ff4500;">1</span> <span style="color: #ff3333;">$var</span> <span style="color: #ff3333;">$var</span> <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">regexp</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>^:<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>://<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>^:<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>:<span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>^@<span style="color: black;">&#93;</span>+<span style="color: black;">&#41;</span>@<span style="color: black;">&#41;</span><span style="color: #66cc66;">?</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>^:/\<span style="color: #66cc66;">?</span><span style="color: #808080; font-style: italic;">#]+)(:([0-9]+))?(/([^\?#]+))?(\?([^#]+))?(#(.*))?} $url a b protocol c user pass server d port e path f cgiargs g anchor]} {</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$protocol</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> protocol <span style="color: #483d8b;">&quot;http&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span>validnum <span style="color: #ff3333;">$port</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> port <span style="color: #ff4500;">80</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Begin Database code</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_fixtopic <span style="color: black;">&#123;</span>arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>\\\<span style="color: black;">&#123;</span>\<span style="color: black;">&#125;</span>\<span style="color: black;">&#91;</span>\<span style="color: black;">&#93;</span>\<span style="color: #483d8b;">&quot;]} $arg {} &nbsp; arg ; # Bad characters<br />
&nbsp; &nbsp; regsub -all {(<span style="color: #000099; font-weight: bold;">\s</span>)+} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arg {<span style="color: #000099; font-weight: bold;">\1</span>} arg ; # Double whitespace<br />
&nbsp; &nbsp; regsub -all {^<span style="color: #000099; font-weight: bold;">\s</span>*|<span style="color: #000099; font-weight: bold;">\s</span>*$} &nbsp; &nbsp; &nbsp;$arg {} &nbsp; arg ; # Whitespace at ends<br />
&nbsp; &nbsp; return $arg<br />
}<br />
<br />
proc faq_fixdb {arg} {<br />
&nbsp; &nbsp; global faq_databases<br />
&nbsp; &nbsp; if {[set i [lsearch -exact [string tolower $faq_databases] [string tolower $arg]]] == -1} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; return &quot;</span><span style="color: #ff7700;font-weight:bold;">error</span> no such database <span style="color: #483d8b;">'$arg'</span> loaded<span style="color: #483d8b;">&quot;<br />
&nbsp; &nbsp; } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; return [lindex $faq_databases $i]<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
proc faq_fixdata {arg output} {<br />
&nbsp; &nbsp; global botnick<br />
&nbsp; &nbsp; if {[string index $output 0] != &quot;</span><span style="color: #808080; font-style: italic;">#&quot;} {</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all -nocase <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output</span><span style="color: #483d8b;">'s} $arg &quot;your&quot; arg<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; regsub -all -nocase {$botnick'</span>s<span style="color: black;">&#125;</span> <span style="color: #ff3333;">$arg</span> <span style="color: #483d8b;">&quot;my&quot;</span> arg<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$arg</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_msg <span style="color: black;">&#123;</span>targets arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> target <span style="color: #ff3333;">$targets</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; puthelp <span style="color: #483d8b;">&quot;PRIVMSG $target :[faq_fixdata $arg $target]&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_check <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_dir<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">file</span> exists <span style="color: #ff3333;">$faq_dir</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error $faq_dir does not exist&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">file</span> isdirectory <span style="color: #ff3333;">$faq_dir</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error $faq_dir is not a directory&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">file</span> readable <span style="color: #ff3333;">$faq_dir</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error $faq_dir is unreadable&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">file</span> writable <span style="color: #ff3333;">$faq_dir</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error $faq_dir is unwritable&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;&quot;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_loadall <span style="color: black;">&#123;</span>output1 output2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_dir faq_databases<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Unset current databases first</span><br />
&nbsp; &nbsp; faq_unloadall<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_check<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output1</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putlog <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> <span style="color: #008000;">file</span> <span style="color: black;">&#91;</span><span style="color: #008000;">glob</span> -nocomplain <span style="color: black;">&#91;</span><span style="color: #008000;">file</span> <span style="color: #008000;">join</span> <span style="color: #ff3333;">$faq_dir</span> <span style="color: #66cc66;">*</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">file</span> isfile <span style="color: #ff3333;">$file</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> output <span style="color: black;">&#91;</span>faq_load <span style="color: black;">&#91;</span><span style="color: #008000;">file</span> tail <span style="color: #ff3333;">$file</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output1</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putlog <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output2</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putlog <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_load <span style="color: black;">&#123;</span>database<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_dir faq_databases faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #008000;">file</span> <span style="color: black;">&#91;</span><span style="color: #008000;">file</span> <span style="color: #008000;">join</span> <span style="color: #ff3333;">$faq_dir</span> <span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; faq_unload <span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> match <span style="color: #66cc66;">*</span>..<span style="color: #66cc66;">*</span> <span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> index <span style="color: #ff3333;">$database</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;/&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error invalid database name '$database'&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">file</span> exists <span style="color: #ff3333;">$file</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error database '$database' does not exist&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">file</span> isfile <span style="color: #ff3333;">$file</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error database '$database' is not a valid file&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #008000;">open</span> <span style="color: #ff3333;">$file</span> r<span style="color: black;">&#125;</span> fileid<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error could not read database '$database'&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span>array <span style="color: #ff7700;font-weight:bold;">set</span> faq_data_<span style="color: #ff3333;">$database</span> <span style="color: black;">&#91;</span><span style="color: #008000;">read</span> <span style="color: #ff3333;">$fileid</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error could not parse database '$database'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">close</span> <span style="color: #ff3333;">$fileid</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">lappend</span> faq_databases <span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;read database '$database'&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_unloadall <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_databases<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> exists faq_databases<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> database <span style="color: #ff3333;">$faq_databases</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_unload <span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> faq_databases <span style="color: #483d8b;">&quot;&quot;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_unload <span style="color: black;">&#123;</span>database<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_databases faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>array exists faq_data_<span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; array unset faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: black;">&#91;</span><span style="color: #008000;">lsearch</span> -exact <span style="color: #ff3333;">$faq_databases</span> <span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> faq_databases <span style="color: black;">&#91;</span><span style="color: #008000;">lreplace</span> <span style="color: #ff3333;">$faq_databases</span> <span style="color: #ff3333;">$i</span> <span style="color: #ff3333;">$i</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_saveall <span style="color: black;">&#123;</span>output1 output2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_databases faq_save<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> output <span style="color: black;">&#91;</span>faq_check<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output1</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putlog <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> database <span style="color: #ff3333;">$faq_databases</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> output <span style="color: black;">&#91;</span>faq_save <span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output1</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putlog <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$output2</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putlog <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> faq_save <span style="color: #ff3333;">$error</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_save <span style="color: black;">&#123;</span>database<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_dir faq_databases faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #008000;">open</span> <span style="color: black;">&#91;</span><span style="color: #008000;">file</span> <span style="color: #008000;">join</span> <span style="color: #ff3333;">$faq_dir</span> <span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span> w<span style="color: black;">&#125;</span> fileid<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error could not write database 'database'&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">puts</span> <span style="color: #ff3333;">$fileid</span> <span style="color: black;">&#91;</span>array get faq_data_<span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">close</span> <span style="color: #ff3333;">$fileid</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;wrote database '$database'&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_needsave <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_save<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> faq_save <span style="color: #ff4500;">1</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> time_faq <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_time faq_save<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$faq_save</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; faq_saveall <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> match <span style="color: #66cc66;">*</span>time_faq<span style="color: #66cc66;">*</span> <span style="color: black;">&#91;</span>timers<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; timer <span style="color: #ff3333;">$faq_time</span> time_faq<br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_topics <span style="color: black;">&#123;</span>arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> topics <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> arg &nbsp; &nbsp;<span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trimright <span style="color: #ff3333;">$arg</span> <span style="color: #483d8b;">&quot;?! &quot;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> length <span style="color: black;">&#91;</span><span style="color: #008000;">llength</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#123;</span><span style="color: #ff7700;font-weight:bold;">set</span> l <span style="color: #ff3333;">$length</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$l</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #008000;">incr</span> l -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#123;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$length</span> - <span style="color: #ff3333;">$l</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$i</span> <span style="color: #66cc66;">&gt;</span>= <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #008000;">incr</span> i -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">lsearch</span> -exact <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: #ff3333;">$topics</span><span style="color: black;">&#93;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> topic <span style="color: black;">&#91;</span><span style="color: #008000;">lrange</span> <span style="color: #ff3333;">$arg</span> <span style="color: #ff3333;">$i</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> + <span style="color: #ff3333;">$l</span> - <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> == -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">lappend</span> topics <span style="color: #ff3333;">$topic</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$topics</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># {&quot;topic 1&quot; &quot;topic 2&quot; ...} -&gt; faq_find -&gt; {&quot;database&quot; &quot;first topic found&quot;}</span><br />
<span style="color: #808080; font-style: italic;"># note: databases are not checked for validity</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_find <span style="color: black;">&#123;</span>topics<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_databases<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> topic <span style="color: #ff3333;">$topics</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> topic <span style="color: black;">&#91;</span>faq_fixtopic <span style="color: #ff3333;">$topic</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> database <span style="color: #ff3333;">$faq_databases</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> topic2 <span style="color: black;">&#91;</span>faq_exists <span style="color: #ff3333;">$topic</span> <span style="color: #ff3333;">$database</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$database</span> <span style="color: #ff3333;">$topic2</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># &quot;*topic string*&quot; -&gt; faq_find2 -&gt; { {&quot;database&quot; &quot;topic found 1&quot;} {&quot;database&quot; &quot;topic found 2&quot;} ... }</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_find2 <span style="color: black;">&#123;</span>topic<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_databases<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> topic &nbsp;<span style="color: black;">&#91;</span>faq_fixtopic <span style="color: #ff3333;">$topic</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> topics <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> database <span style="color: #ff3333;">$faq_databases</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># [array names faq_data_$database -glob *topic*] would be really nice here, but it has no -nocase option!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> topic2 <span style="color: black;">&#91;</span>array names faq_data_<span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> match -nocase <span style="color: #66cc66;">*</span><span style="color: #ff3333;">$topic</span><span style="color: #66cc66;">*</span> <span style="color: #ff3333;">$topic2</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">lappend</span> topics <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$database</span> <span style="color: #ff3333;">$topic2</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$topics</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_parsetopic <span style="color: black;">&#123;</span>arg var1 var2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> <span style="color: #ff3333;">$var1</span> <span style="color: #ff3333;">$var2</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> i &nbsp; &nbsp; <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> first <span style="color: #483d8b;">&quot;=&quot;</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var1</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trim <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> range <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">0</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> - <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var2</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trim <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> range <span style="color: #ff3333;">$arg</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> end<span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#123;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$i</span> <span style="color: #66cc66;">&lt;</span>= <span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><span style="color: #008000;">incr</span> i<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> match <span style="color: #483d8b;">&quot;topic*&quot;</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> topic_var <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> var<span style="color: #ff3333;">$i</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># if this is a topic, we look for a database too</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> database_var <span style="color: #483d8b;">&quot;database[string range $topic_var 5 end]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_parsedb <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$topic_var</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$topic_var</span> <span style="color: #ff3333;">$database_var</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># we got an error parsing the db</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var1</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var2</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: #ff3333;">$i</span> == -<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error parsing sentence&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_parsedb <span style="color: black;">&#123;</span>arg var1 var2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_database <span style="color: #ff3333;">$var1</span> <span style="color: #ff3333;">$var2</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> last <span style="color: #483d8b;">&quot;|&quot;</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var1</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trim <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> range <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">0</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> - <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var2</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trim <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> range <span style="color: #ff3333;">$arg</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> end<span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> tmp <span style="color: black;">&#91;</span>faq_find <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var2</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$tmp</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># we go with the db that this topic is already stored in</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var2</span> <span style="color: #ff3333;">$faq_database</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># we go w/ default db</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var1</span> <span style="color: black;">&#91;</span>faq_fixtopic <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var2</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error parsing sentence&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var2</span> <span style="color: black;">&#91;</span>faq_fixdb <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff3333;">$var2</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># this may return an error</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># type = 0, returns 1/0 ; type = 1, returns proper case (or error), for use with existing topics ;</span><br />
<span style="color: #808080; font-style: italic;"># type = 2, returns proper case (or original topic), for use with creating new topics</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_exists <span style="color: black;">&#123;</span>topic database type<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: black;">&#91;</span><span style="color: #008000;">lsearch</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: black;">&#91;</span>array names faq_data_<span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: #ff3333;">$topic</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$type</span> == <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: black;">&#91;</span>array names faq_data_<span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$i</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$type</span> == <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$type</span> == <span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error topic '$topic' does not exist in database '$database'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$topic</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_write <span style="color: black;">&#123;</span>topic database type arg host<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> topic <span style="color: black;">&#91;</span>faq_exists <span style="color: #ff3333;">$topic</span> <span style="color: #ff3333;">$database</span> <span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$type</span> == <span style="color: #483d8b;">&quot;w&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> faq_data_<span style="color: #66cc66;">$</span><span style="color: black;">&#123;</span>database<span style="color: black;">&#125;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$topic</span><span style="color: black;">&#41;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$type</span> == <span style="color: #483d8b;">&quot;a&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">lappend</span> faq_data_<span style="color: #66cc66;">$</span><span style="color: black;">&#123;</span>database<span style="color: black;">&#125;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$topic</span><span style="color: black;">&#41;</span> <span style="color: #ff3333;">$arg</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">lappend</span> faq_data_<span style="color: #66cc66;">$</span><span style="color: black;">&#123;</span>database<span style="color: black;">&#125;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$topic</span><span style="color: black;">&#41;</span> <span style="color: #483d8b;">&quot;#WHOSET $host [clock seconds]&quot;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_read <span style="color: black;">&#123;</span>topic database<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> database <span style="color: black;">&#91;</span>faq_fixdb <span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> topic <span style="color: black;">&#91;</span>faq_exists <span style="color: #ff3333;">$topic</span> <span style="color: #ff3333;">$database</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$topic</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> faq_data_<span style="color: #66cc66;">$</span><span style="color: black;">&#123;</span>database<span style="color: black;">&#125;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$topic</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_copy <span style="color: black;">&#123;</span>topic1 database1 topic2 database2<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_data_<span style="color: #ff3333;">$database1</span> faq_data_<span style="color: #ff3333;">$database2</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>faq_exists <span style="color: #ff3333;">$topic2</span> <span style="color: #ff3333;">$database2</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;error topic '$topic2' already exists in database '$database2'&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> output <span style="color: black;">&#91;</span>faq_read <span style="color: #ff3333;">$topic1</span> <span style="color: #ff3333;">$database1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> faq_data_<span style="color: #66cc66;">$</span><span style="color: black;">&#123;</span>database2<span style="color: black;">&#125;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$topic2</span><span style="color: black;">&#41;</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_remove <span style="color: black;">&#123;</span>topic database<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> topic <span style="color: black;">&#91;</span>faq_exists <span style="color: #ff3333;">$topic</span> <span style="color: #ff3333;">$database</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$topic</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; unset faq_data_<span style="color: #66cc66;">$</span><span style="color: black;">&#123;</span>database<span style="color: black;">&#125;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$topic</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_disp <span style="color: black;">&#123;</span>arg database output1 output2 depth num option nick<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_max_lines<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$depth</span> <span style="color: #66cc66;">&gt;</span>= <span style="color: #ff4500;">3</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error recursion too deep&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> -<span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> found <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$database</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #008000;">list</span> <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #ff3333;">$database</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># we have an exact topic/db to display</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #008000;">list</span> <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: black;">&#91;</span>faq_find <span style="color: black;">&#91;</span>faq_topics <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># find topic/db (s)</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># note: the $list vars above needed to be padded with { } - hence the [list] 's</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> tmp <span style="color: #ff3333;">$list</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$tmp</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">continue</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$depth</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> num <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> output <span style="color: black;">&#91;</span>faq_read <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> topic <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$tmp</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> database <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$tmp</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> line <span style="color: #ff3333;">$output</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$line</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;#WHOSET&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#ignore</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;#LINK&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> temp <span style="color: black;">&#91;</span>faq_disp <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output2</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$depth</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> <span style="color: #ff3333;">$num</span> <span style="color: #ff4500;">0</span> <span style="color: #ff3333;">$nick</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> num <span style="color: #ff3333;">$temp</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;.&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: black;">&#91;</span>xrange <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">1</span> end<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> num<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$num</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;$topic - $line&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> num<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;... $line&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> num<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$num</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error '$topic' exists, but is empty&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> equal -nocase <span style="color: #ff3333;">$output2</span> <span style="color: #ff3333;">$output1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$depth</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;(sent by $output1)&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;sent '$topic' to $output2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> found<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$found</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$depth</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error invalid link to '$arg'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$num</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #808080; font-style: italic;"># End Database code</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Begin 'calc' code</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_fixexpr <span style="color: black;">&#123;</span>exp<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_const<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> exp <span style="color: black;">&#91;</span>faq_fixtopic <span style="color: #ff3333;">$exp</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> i <span style="color: black;">&#91;</span>array names faq_const<span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">regsub</span> -all <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\%</span>$i&quot;</span> <span style="color: #ff3333;">$exp</span> <span style="color: #ff3333;">$faq_const</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$i</span><span style="color: black;">&#41;</span> exp<br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff3333;">$exp</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #808080; font-style: italic;"># End 'calc' code</span><br />
<br />
<span style="color: #808080; font-style: italic;"># expr's abs() and int() can't handle large unsigned integers,</span><br />
<span style="color: #808080; font-style: italic;"># these functions are just to get around this</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_int <span style="color: black;">&#123;</span>value<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;.&quot;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_abs <span style="color: black;">&#123;</span>value<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trimleft <span style="color: #ff3333;">$value</span> <span style="color: #483d8b;">&quot;-&quot;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> faq_absint <span style="color: black;">&#123;</span>value<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span>faq_int <span style="color: black;">&#91;</span>faq_abs <span style="color: #ff3333;">$value</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Begin Public binds code</span><br />
<span style="color: #ff7700;font-weight:bold;">proc</span> msg_faq <span style="color: black;">&#123;</span>nick uhost hand arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; pub_faq <span style="color: #ff3333;">$nick</span> <span style="color: #ff3333;">$uhost</span> <span style="color: #ff3333;">$hand</span> <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #ff3333;">$arg</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> pub_faq <span style="color: black;">&#123;</span>nick uhost hand chan arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> botnick faq_dir faq_format faq_max faq_flag faq_database faq_databases faq_channel_flag<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> topic topic1 topic2 database database1 database2 value<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span>isbotnick <span style="color: #ff3333;">$nick</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span>matchattr <span style="color: #ff3333;">$hand</span> +b<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff3333;">$chan</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>channel get <span style="color: #ff3333;">$chan</span> <span style="color: #ff3333;">$faq_channel_flag</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: #ff3333;">$chan</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> match -nocase <span style="color: #ff3333;">$botnick</span><span style="color: #66cc66;">*</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> arg <span style="color: black;">&#91;</span>xrange <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">1</span> end<span style="color: black;">&#93;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Only answer channel messages that begin with the bot's nick</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$chan</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Answer all privmsgs</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Msg isn't for us, bail out</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> isuser <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>matchattr <span style="color: #ff3333;">$hand</span> <span style="color: #ff3333;">$faq_flag</span>|<span style="color: #ff3333;">$faq_flag</span> <span style="color: #ff3333;">$chan</span><span style="color: black;">&#93;</span> || <span style="color: black;">&#91;</span>matchattr <span style="color: #ff3333;">$hand</span> <span style="color: #ff3333;">$faq_flag</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Note that $chan might be &quot;&quot;, so we must handle both cases</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>validchan <span style="color: #ff3333;">$chan</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> output1 <span style="color: #ff3333;">$chan</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># The bot sends the text to the channel for users</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> output1 <span style="color: #ff3333;">$nick</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Non-users get privmsg'd</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> output2 <span style="color: #ff3333;">$output1</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># By default, output2 (~stdout~) goes to output1 (~stderr~)</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">lsearch</span> -exact <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #483d8b;">&quot;shutup stop sh database db set learn add unset forget delete del remove rem rm erase append addon link join copy cp move mv rename ren&quot;</span><span style="color: black;">&#93;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: black;">&#91;</span>xindex <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> == -<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> last <span style="color: #483d8b;">&quot;&gt;&quot;</span> <span style="color: #ff3333;">$arg</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Output has been redirected</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> output2 <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trim <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> range <span style="color: #ff3333;">$arg</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> end<span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> output2 <span style="color: #ff3333;">$output1</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># Error (User doesn't have access, or output was &quot;&quot;), so we go back to the default</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> arg <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> trim <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> range <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">0</span> <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">expr</span> <span style="color: #ff3333;">$i</span> - <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> command &nbsp; <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: black;">&#91;</span>xindex <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> remainder <span style="color: black;">&#91;</span>xrange <span style="color: #ff3333;">$arg</span> <span style="color: #ff4500;">1</span> end<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">switch</span> -- <span style="color: #ff3333;">$command</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;shutup&quot;</span> - <span style="color: #483d8b;">&quot;stop&quot;</span> - <span style="color: #483d8b;">&quot;sh&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>clearqueue help<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;OK, sorry&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;But I'm not saying anything!&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;database&quot;</span> - <span style="color: #483d8b;">&quot;db&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">switch</span> -- <span style="color: black;">&#91;</span><span style="color: #008000;">string</span> tolower <span style="color: black;">&#91;</span>xindex <span style="color: #ff3333;">$remainder</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;reload&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_loadall <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;save&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_saveall <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;list&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;Loaded database(s):&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> database <span style="color: #ff3333;">$faq_databases</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> faq_data_<span style="color: #ff3333;">$database</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: black;">&#91;</span><span style="color: #008000;">format</span> <span style="color: #483d8b;">&quot;%s %-15s %s&quot;</span> <span style="color: #ff3333;">$i</span>. <span style="color: #ff3333;">$database</span> <span style="color: #808080; font-style: italic;">#[array size faq_data_$database]]</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;end&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">default</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error must be one of 'reload', 'save' , or 'list'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;set&quot;</span> - <span style="color: #483d8b;">&quot;learn&quot;</span> - <span style="color: #483d8b;">&quot;add&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_parsetopic <span style="color: #ff3333;">$remainder</span> topic value<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span> || \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_write <span style="color: #ff3333;">$topic</span> <span style="color: #ff3333;">$database</span> <span style="color: #483d8b;">&quot;w&quot;</span> <span style="color: #ff3333;">$value</span> <span style="color: #ff3333;">$nick</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$uhost</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;Set '$topic' in database '$database'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_needsave<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;unset&quot;</span> - <span style="color: #483d8b;">&quot;forget&quot;</span> - <span style="color: #483d8b;">&quot;delete&quot;</span> - <span style="color: #483d8b;">&quot;del&quot;</span> - <span style="color: #483d8b;">&quot;remove&quot;</span> - <span style="color: #483d8b;">&quot;rem&quot;</span> - <span style="color: #483d8b;">&quot;rm&quot;</span> - <span style="color: #483d8b;">&quot;erase&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_parsetopic <span style="color: #483d8b;">&quot;$remainder = null&quot;</span> topic value<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span> || \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_remove <span style="color: #ff3333;">$topic</span> <span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;Unset '$topic' in database '$database'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_needsave<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;append&quot;</span> - <span style="color: #483d8b;">&quot;addon&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_parsetopic <span style="color: #ff3333;">$remainder</span> topic value<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span> || \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_write <span style="color: #ff3333;">$topic</span> <span style="color: #ff3333;">$database</span> <span style="color: #483d8b;">&quot;a&quot;</span> <span style="color: #ff3333;">$value</span> <span style="color: #ff3333;">$nick</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$uhost</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;Appended to '$topic' in database '$database'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_needsave<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;link&quot;</span> - <span style="color: #483d8b;">&quot;join&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_parsetopic <span style="color: #ff3333;">$remainder</span> topic1 topic2<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> topic2 <span style="color: black;">&#91;</span>faq_exists <span style="color: #ff3333;">$topic2</span> <span style="color: #ff3333;">$database2</span> <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$topic2</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># check if 2nd topic exists, get proper casing too (so $topic2 not $error is used)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_write <span style="color: #ff3333;">$topic1</span> <span style="color: #ff3333;">$database1</span> <span style="color: #483d8b;">&quot;a&quot;</span> <span style="color: black;">&#91;</span><span style="color: #008000;">list</span> <span style="color: #808080; font-style: italic;">#LINK $topic2 $database2] $nick!$uhost]] 0] == &quot;error&quot;} {</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;Linked '$topic1' ($database1) to '$topic2' ($database2)&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_needsave<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;copy&quot;</span> - <span style="color: #483d8b;">&quot;cp&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_parsetopic <span style="color: #ff3333;">$remainder</span> topic1 topic2<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span> || \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_copy <span style="color: #ff3333;">$topic1</span> <span style="color: #ff3333;">$database1</span> <span style="color: #ff3333;">$topic2</span> <span style="color: #ff3333;">$database2</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;Copied '$topic1' ($database1) to '$topic2' ($database2)&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_needsave<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;move&quot;</span> - <span style="color: #483d8b;">&quot;mv&quot;</span> - <span style="color: #483d8b;">&quot;rename&quot;</span> - <span style="color: #483d8b;">&quot;ren&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$isuser</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_parsetopic <span style="color: #ff3333;">$remainder</span> topic1 topic2<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span> || \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_copy <span style="color: #ff3333;">$topic1</span> <span style="color: #ff3333;">$database1</span> <span style="color: #ff3333;">$topic2</span> <span style="color: #ff3333;">$database2</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span> || \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_remove <span style="color: #ff3333;">$topic1</span> <span style="color: #ff3333;">$database1</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;Renamed '$topic1' ($database1) to '$topic2' ($database2)&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_needsave<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;list&quot;</span> - <span style="color: #483d8b;">&quot;find&quot;</span> - <span style="color: #483d8b;">&quot;search&quot;</span> - <span style="color: #483d8b;">&quot;locate&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> topics <span style="color: black;">&#91;</span>faq_find2 <span style="color: #ff3333;">$remainder</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">switch</span> -- <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> found <span style="color: black;">&#91;</span><span style="color: #008000;">llength</span> <span style="color: #ff3333;">$topics</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff4500;">0</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;Found no matches to '$remainder'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff4500;">1</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_disp <span style="color: black;">&#91;</span><span style="color: #008000;">join</span> <span style="color: #ff3333;">$topics</span><span style="color: black;">&#93;</span> <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output2</span> <span style="color: #ff4500;">0</span> <span style="color: #ff4500;">0</span> <span style="color: #ff4500;">0</span> <span style="color: #ff3333;">$nick</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">default</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;Found $found matches to '$remainder'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> i <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> topic <span style="color: #ff3333;">$topics</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;$i. [lindex $topic 1]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$i</span> <span style="color: #66cc66;">&gt;</span>= <span style="color: #ff3333;">$faq_max</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">break</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;end&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;whoset&quot;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> <span style="color: #ff7700;font-weight:bold;">error</span> <span style="color: black;">&#91;</span>faq_parsetopic <span style="color: #483d8b;">&quot;$remainder = null&quot;</span> topic value<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> output <span style="color: black;">&#91;</span>faq_read <span style="color: #ff3333;">$topic</span> <span style="color: #ff3333;">$database</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;error&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> found <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> line <span style="color: #ff3333;">$output</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span>xindex <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;#WHOSET&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$found</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;'$topic' (database $database) set by [xindex $line 1] on [clock format [xindex $line 2] -format $faq_format]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">incr</span> found<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output2</span> <span style="color: #483d8b;">&quot;... modified by [xindex $line 1] on [clock format [xindex $line 2] -format $faq_format]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: #ff3333;">$found</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_msg <span style="color: #ff3333;">$output1</span> <span style="color: #483d8b;">&quot;error could not find who set topic '$topic'&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">default</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; faq_disp <span style="color: #ff3333;">$arg</span> <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #ff3333;">$output1</span> <span style="color: #ff3333;">$output2</span> <span style="color: #ff4500;">0</span> <span style="color: #ff4500;">0</span> <span style="color: #ff4500;">1</span> <span style="color: #ff3333;">$nick</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #808080; font-style: italic;"># End Public binds code</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Init stuff</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #008000;">package</span> require Tcl <span style="color: #ff4500;">8.3</span><span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">error</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; putlog <span style="color: #483d8b;">&quot;error TCL v8.3 or higher is required to run this script&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span><br />
<span style="color: black;">&#125;</span><br />
putlog <span style="color: #483d8b;">&quot;*** LOADED: faq.tcl&quot;</span><br />
<br />
bind pubm - <span style="color: #66cc66;">*</span> pub_faq<br />
bind msgm - <span style="color: #66cc66;">*</span> msg_faq<br />
setudef flag <span style="color: #ff3333;">$faq_channel_flag</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> exists faq_load<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; faq_loadall <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #483d8b;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> faq_load <span style="color: #ff4500;">1</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> exists faq_save<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> faq_save <span style="color: #ff4500;">0</span><br />
<span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> match <span style="color: #66cc66;">*</span>time_faq<span style="color: #66cc66;">*</span> <span style="color: black;">&#91;</span>timers<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; timer <span style="color: #ff3333;">$faq_time</span> time_faq<br />
<span style="color: black;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://briped.net/2007/06/20/faqtcl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nslookup.tcl</title>
		<link>http://briped.net/2007/06/20/nslookuptcl/</link>
		<comments>http://briped.net/2007/06/20/nslookuptcl/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 09:20:16 +0000</pubDate>
		<dc:creator>Brian Schmidt Pedersen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[TCL]]></category>
		<category><![CDATA[Eggdrop]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://briped.net/2007/06/20/nslookuptcl/</guid>
		<description><![CDATA[#### nslookup.tcl v1.0.1 ####################################################### ################################################################################ ## Written by: &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;## ## &#160; KuNgFo0 &#160;(http://www.eggfaq.com/). &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container tcl default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="tcl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#### nslookup.tcl v1.0.1 #######################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## Written by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; KuNgFo0 &nbsp;(http://www.eggfaq.com/). &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Modified by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; Brian Schmidt aka. brianMan. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;">#### Readme / Help #############################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## This is a slightly modified version of KuNgFoO's nslookup.tcl v0.5 script. ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Script that can do nslookups. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Usage: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; To have the .dns command available on a channel you need to set the &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; channel flag +nslookups from the console/partyline . &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; ``.chanset #channel +nslookups´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Channel Commands (available only if channel is +nslookups): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; .dns [ host|ip|nick[ host|ip|nick][ ...]] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## Example: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; ``.dns www.eggfaq.com´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;">#### Changelog #################################################################</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<span style="color: #808080; font-style: italic;">## v1.0.1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## * Minor code cleanup &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">## v1.0.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## + Initial release. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## + Added the possibility to control which channels could use the commands &nbsp; ##</span><br />
<span style="color: #808080; font-style: italic;">## &nbsp; with the channel flag ``+/-nslookup´´ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##</span><br />
<span style="color: #808080; font-style: italic;">################################################################################</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set then next line as the command you want to initate the nslookup</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> nslookup_command <span style="color: #483d8b;">&quot;.dns&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the flagname used for enabling the channel command</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> nslookup_channel_flag <span style="color: #483d8b;">&quot;nslookup&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as the flag required to use the command</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> nslookup_flag <span style="color: #483d8b;">&quot;-&quot;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Set the next line as the exec command to run</span><br />
<span style="color: #808080; font-style: italic;"># (Only if you're running an older eggdrop or not using the nslookup module)</span><br />
<span style="color: #ff7700;font-weight:bold;">set</span> nslookup_exec <span style="color: #483d8b;">&quot;nslookup -silent&quot;</span><br />
<br />
bind pub <span style="color: #ff3333;">$nslookup_flag</span>|<span style="color: #ff3333;">$nslookup_flag</span> <span style="color: #ff3333;">$nslookup_command</span> pub_nslookup<br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> pub_nslookup <span style="color: black;">&#123;</span>nick uhost hand chan arg<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">global</span> nslookup_command nslookup_exec botnick nslookup_channel_flag<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>channel get <span style="color: #ff3333;">$chan</span> <span style="color: #ff3333;">$nslookup_channel_flag</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span>matchattr <span style="color: #ff3333;">$hand</span> b<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: #ff3333;">$nick</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff3333;">$botnick</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$arg</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putserv <span style="color: #483d8b;">&quot;PRIVMSG $chan :Usage: $nslookup_command &nbsp;<span style="color: #000099; font-weight: bold;">\[</span>host/ip/nick #2<span style="color: #000099; font-weight: bold;">\]</span> ...&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> addr <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> addrs <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$arg</span> <span style="color: black;">&#123;</span>,<span style="color: #66cc66;">;</span>| <span style="color: black;">&#125;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$addr</span> == <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">continue</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># ignore</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">set</span> tmp <span style="color: black;">&#91;</span>getchanhost <span style="color: #ff3333;">$addr</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> addr <span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$tmp</span> @<span style="color: black;">&#93;</span> end<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #66cc66;">!</span><span style="color: black;">&#91;</span><span style="color: #008000;">regexp</span> <span style="color: black;">&#123;</span>^<span style="color: black;">&#91;</span>a-zA-Z0-<span style="color: #ff4500;">9</span>\.\-<span style="color: black;">&#93;</span><span style="color: #66cc66;">*$</span><span style="color: black;">&#125;</span> <span style="color: #ff3333;">$addr</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putserv <span style="color: #483d8b;">&quot;PRIVMSG $chan :Error: Hostname '$addr' contains illegal characters&quot;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># vulnerability</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> index <span style="color: #ff3333;">$addr</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;-&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putserv <span style="color: #483d8b;">&quot;PRIVMSG $chan :Error: Hostnames cannot begin with a - character ($addr)&quot;</span> <span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;"># vulnerability</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> commands dnslookup<span style="color: black;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dnslookup <span style="color: #ff3333;">$addr</span> return_nslookup <span style="color: #ff3333;">$chan</span> <span style="color: #ff3333;">$addr</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">catch</span> <span style="color: black;">&#123;</span><span style="color: #008000;">exec</span> bash -c <span style="color: #483d8b;">&quot;$nslookup_exec '$addr'&quot;</span><span style="color: black;">&#125;</span> output<span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putserv <span style="color: #483d8b;">&quot;PRIVMSG $chan :Could not resolve $addr&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">foreach</span> line <span style="color: black;">&#91;</span><span style="color: #008000;">split</span> <span style="color: #ff3333;">$output</span> \n<span style="color: black;">&#93;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;Name:&quot;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> host <span style="color: black;">&#91;</span><span style="color: #008000;">lrange</span> <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">1</span> end<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">elseif</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;Address:&quot;</span><span style="color: black;">&#41;</span> || <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">lindex</span> <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;Addresses:&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">set</span> ip <span style="color: black;">&#91;</span><span style="color: #008000;">lrange</span> <span style="color: #ff3333;">$line</span> <span style="color: #ff4500;">1</span> end<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> exists host<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">info</span> exists ip<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return_nslookup <span style="color: #ff3333;">$ip</span> <span style="color: #ff3333;">$host</span> <span style="color: #ff4500;">1</span> <span style="color: #ff3333;">$chan</span> <span style="color: #ff3333;">$addr</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return_nslookup <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: #ff4500;">0</span> <span style="color: #ff3333;">$chan</span> <span style="color: #ff3333;">$addr</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">proc</span> return_nslookup <span style="color: black;">&#123;</span>ip host status chan addr<span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: #ff3333;">$status</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#123;</span><span style="color: black;">&#91;</span><span style="color: #008000;">string</span> match <span style="color: #66cc66;">*</span><span style="color: #ff3333;">$ip</span><span style="color: #66cc66;">*</span> <span style="color: #ff3333;">$addr</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putserv <span style="color: #483d8b;">&quot;PRIVMSG $chan :$ip -&gt; $host&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putserv <span style="color: #483d8b;">&quot;PRIVMSG $chan :$host -&gt; $ip&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; putserv <span style="color: #483d8b;">&quot;PRIVMSG $chan :Could not resolve $addr&quot;</span><br />
&nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
<span style="color: black;">&#125;</span><br />
<br />
setudef flag <span style="color: #ff3333;">$nslookup_channel_flag</span><br />
putlog <span style="color: #483d8b;">&quot;*** LOADED: nslookup.tcl&quot;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://briped.net/2007/06/20/nslookuptcl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>antispam.mrc &#8211; Block spammers</title>
		<link>http://briped.net/2007/06/20/antispammrc-block-spammers/</link>
		<comments>http://briped.net/2007/06/20/antispammrc-block-spammers/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 09:19:22 +0000</pubDate>
		<dc:creator>Brian Schmidt Pedersen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[mIRC]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://briped.net/2007/06/20/antispammrc-block-spammers/</guid>
		<description><![CDATA[;;;; Anti Spam v1.0.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Written by: &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;;; ;; &#160; Brian Schmidt aka. brianMan aka. b&#124;man. &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container mirc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="mirc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">;;;; Anti Spam v1.0.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;; Written by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; Brian Schmidt aka. brianMan aka. b|man. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<br />
<span style="color: #808080; font-style: italic;">;;;; Readme / Help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;; Load this script in mIRC, if you don't know how to do this, then perhaps &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;; you shouldn't be using this script. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; Very simple spamblocking script, blocks private message if they contain a &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; word (usually urls) that are stored in it's dbfile. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; Right click in a query window, or click the custom menu in the menubar to &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; configure it/enable it. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<br />
<span style="color: #808080; font-style: italic;">;;;; Changelog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;; v1.0.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;; + Initial release. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<br />
<span style="color: #808080; font-style: italic;">;; Make sure the variable, with the file containing the list of blocked strings</span><br />
<span style="color: #808080; font-style: italic;">;; are set at script start.</span><br />
<span style="color: #000099;">on *:START:</span><span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; set <span style="color: #990000;">%_antispam_dbfile</span> spamdb.<span style="color: #008000;">txt</span><br />
&nbsp; &nbsp; <a href="http://www.mirc.com/echo"><span style="color: #990000; font-weight: bold;">echo</span></a> <span style="color: #888800;">-tc</span> info *** Anti-Spam by Brian Schmidt loaded..<br />
<span style="color: #FF0000;">&#125;</span><br />
<br />
<span style="color: #994444;">alias</span> antispam <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == add || <span style="color: #000099;">$1</span> == a<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span>!<span style="color: #000099;">$read</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%_antispam_dbfile</span>,w,$<span style="color: #000099;">$2</span><span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/write"><span style="color: #990000; font-weight: bold;">write</span></a> <span style="color: #990000;">%_antispam_dbfile</span> <span style="color: #000099;">$encode</span><span style="color: #FF0000;">&#40;</span>$<span style="color: #000099;">$2</span><span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/echo"><span style="color: #990000; font-weight: bold;">echo</span></a> <span style="color: #888800;">-tac</span> info *** Adding $<span style="color: #000099;">$2</span> to <span style="color: #990000;">%_antispam_dbfile</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/echo"><span style="color: #990000; font-weight: bold;">echo</span></a> <span style="color: #888800;">-tac</span> info *** $<span style="color: #000099;">$2</span> allready in <span style="color: #990000;">%_antispam_dbfile</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == <a href="http://www.mirc.com/remove"><span style="color: #990000; font-weight: bold;">remove</span></a> || <span style="color: #000099;">$1</span> == rem || <span style="color: #000099;">$1</span> == r || <span style="color: #000099;">$1</span> == delete || <span style="color: #000099;">$1</span> == del || <span style="color: #000099;">$1</span> == d<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$read</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%_antispam_dbfile</span>,w,<span style="color: #000099;">$encode</span><span style="color: #FF0000;">&#40;</span>$<span style="color: #000099;">$2</span><span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/write"><span style="color: #990000; font-weight: bold;">write</span></a> <span style="color: #888800;">-dw</span> <span style="color: #000099;">$encode</span><span style="color: #FF0000;">&#40;</span>$<span style="color: #000099;">$2</span><span style="color: #FF0000;">&#41;</span> <span style="color: #990000;">%_antispam_dbfile</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/echo"><span style="color: #990000; font-weight: bold;">echo</span></a> <span style="color: #888800;">-tac</span> info *** Removed $<span style="color: #000099;">$2</span> from <span style="color: #990000;">%_antispam_dbfile</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/echo"><span style="color: #990000; font-weight: bold;">echo</span></a> <span style="color: #888800;">-tac</span> info *** $<span style="color: #000099;">$2</span> not in <span style="color: #990000;">%_antispam_dbfile</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == check || <span style="color: #000099;">$1</span> == c<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%_antispam_status</span> != <span style="color: #000099;">$null</span> &amp;&amp; <span style="color: #990000;">%_antispam_status</span> != 0 &amp;&amp; <span style="color: #990000;">%_antispam_status</span> != off<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%i</span> 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%i</span> &lt;= <span style="color: #000099;">$numtok</span><span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$2</span>-,32<span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$read</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%_antispam_dbfile</span>,w,<span style="color: #000099;">$encode</span><span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$gettok</span><span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$2</span>-,<span style="color: #990000;">%i</span>,32<span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$line</span><span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$nick</span>,0<span style="color: #FF0000;">&#41;</span> == 0<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/window"><span style="color: #990000; font-weight: bold;">window</span></a> <span style="color: #888800;">-c</span> <span style="color: #000099;">$window</span><span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$nick</span><span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; halt<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inc <span style="color: #990000;">%i</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == status<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$2</span> == 1 || <span style="color: #000099;">$2</span> == on<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #990000;">%_antispam_status</span> 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/echo"><span style="color: #990000; font-weight: bold;">echo</span></a> <span style="color: #888800;">-tac</span> info *** Anti-Spam enabled.<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$2</span> == 0 || <span style="color: #000099;">$2</span> == off<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #990000;">%_antispam_status</span> 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/echo"><span style="color: #990000; font-weight: bold;">echo</span></a> <span style="color: #888800;">-tac</span> info *** Anti-Spam disabled.<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == <a href="http://www.mirc.com/list"><span style="color: #990000; font-weight: bold;">list</span></a> || <span style="color: #000099;">$1</span> == l<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.mirc.com/window"><span style="color: #990000; font-weight: bold;">window</span></a> <span style="color: #888800;">-d</span>Clk0 <span style="color: #888800;">@Anti</span>-Spam<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%c</span> = <span style="color: #000099;">$lines</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%_antispam_dbfile</span><span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%c</span> &gt; 0<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%i</span> = 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%i</span> &lt;= <span style="color: #990000;">%c</span><span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aline <span style="color: #888800;">-p</span> <span style="color: #888800;">@Anti</span>-Spam <span style="color: #000099;">$decode</span><span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$read</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%_antispam_dbfile</span>,t,<span style="color: #990000;">%i</span><span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inc <span style="color: #990000;">%i</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
<span style="color: #FF0000;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">;; The popup menus.</span><br />
<span style="color: #994444;">menu</span> <a href="http://www.mirc.com/query"><span style="color: #990000; font-weight: bold;">query</span></a>,menubar <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; -<br />
&nbsp; &nbsp; Anti-Spam<br />
&nbsp; &nbsp; .<span style="color: #000099;">$iif</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%_antispam_status</span> == 0 || <span style="color: #990000;">%_antispam_status</span> == <span style="color: #000099;">$null</span>,<a href="http://www.mirc.com/enable"><span style="color: #990000; font-weight: bold;">Enable</span></a><span style="color: #FF0000;">&#41;</span>:antispam status on<br />
&nbsp; &nbsp; .<span style="color: #000099;">$iif</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%_antispam_status</span> == 1,<a href="http://www.mirc.com/disable"><span style="color: #990000; font-weight: bold;">Disable</span></a><span style="color: #FF0000;">&#41;</span>:antispam status off<br />
&nbsp; &nbsp; .<span style="color: #008000;">Configure</span>:antispam <a href="http://www.mirc.com/list"><span style="color: #990000; font-weight: bold;">list</span></a><br />
&nbsp; &nbsp; -<br />
<span style="color: #FF0000;">&#125;</span><br />
<span style="color: #994444;">menu</span> <span style="color: #888800;">@Anti</span>-Spam <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; dclick:<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$input</span><span style="color: #FF0000;">&#40;</span>Delete <span style="color: #000099;">$line</span><span style="color: #FF0000;">&#40;</span><span style="color: #888800;">@Anti</span>-Spam,<span style="color: #000099;">$1</span><span style="color: #FF0000;">&#41;</span>,y,Confirm delete<span style="color: #FF0000;">&#41;</span><span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span> antispam rem <span style="color: #000099;">$line</span><span style="color: #FF0000;">&#40;</span><span style="color: #888800;">@Anti</span>-Spam,<span style="color: #000099;">$1</span><span style="color: #FF0000;">&#41;</span> | dline <span style="color: #888800;">@Anti</span>-Spam <span style="color: #000099;">$1</span> <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; Add..:<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%antispam_tmp_add</span> <span style="color: #000099;">$input</span><span style="color: #FF0000;">&#40;</span>Add spamline,e<span style="color: #FF0000;">&#41;</span> | antispam add <span style="color: #990000;">%antispam_tmp_add</span> | aline <span style="color: #888800;">@Anti</span>-Spam <span style="color: #990000;">%antispam_tmp_add</span><br />
<span style="color: #FF0000;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">;; Catch all (private) text and check it for spam.</span><br />
on ^&amp;*:TEXT:*:?:<span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; antispam check <span style="color: #000099;">$1</span>-<br />
<span style="color: #FF0000;">&#125;</span><br />
on ^&amp;*:<a href="http://www.mirc.com/action"><span style="color: #990000; font-weight: bold;">ACTION</span></a>:*:?:<span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; antispam check <span style="color: #000099;">$1</span>-<br />
<span style="color: #FF0000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://briped.net/2007/06/20/antispammrc-block-spammers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>age.mrc &#8211; Calculate Your Age</title>
		<link>http://briped.net/2007/06/20/agemrc-calculate-your-age/</link>
		<comments>http://briped.net/2007/06/20/agemrc-calculate-your-age/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 09:18:17 +0000</pubDate>
		<dc:creator>Brian Schmidt Pedersen</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[mIRC]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://briped.net/2007/06/20/agemrc-calculate-your-age/</guid>
		<description><![CDATA[;;;; My Age v1.1.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Written by: &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;;; ;; &#160; Brian Schmidt aka. brianMan. &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container mirc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="mirc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">;;;; My Age v1.1.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;; Written by: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; Brian Schmidt aka. brianMan. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<br />
<span style="color: #808080; font-style: italic;">;;;; Readme / Help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;; Load this script in mIRC, if you don't know how to do this, then perhaps &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;; you shouldn't be using this script. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; Simple script to tell how old you are in seconds, or minutes etc. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; Commands available: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; /myage &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<br />
<span style="color: #808080; font-style: italic;">;;;; Changelog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<span style="color: #808080; font-style: italic;">;; v1.1.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;; + Added possibility to only say your age in one format (hour/sec etc.). &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; * Changed the actual trigger alias from /age to /myage. The age alias is &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; only used as an identifier that returns the value to the calling script. ;;</span><br />
<span style="color: #808080; font-style: italic;">;; + Will now ask for your birthdate when run, if it isn't set. Then store it ;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; in a variable for later use. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;;</span><br />
<span style="color: #808080; font-style: italic;">;; v1.0.0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;; + Initial release. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;</span><br />
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span><br />
<br />
<span style="color: #994444;">alias</span> age <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%unix</span> = <span style="color: #000099;">$ctime</span><span style="color: #FF0000;">&#40;</span>$<span style="color: #000099;">$1</span>-<span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%now</span> = <span style="color: #000099;">$ctime</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%seconds</span> = <span style="color: #000099;">$calc</span><span style="color: #FF0000;">&#40;</span> <span style="color: #990000;">%now</span> - <span style="color: #990000;">%unix</span> <span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%minutes</span> = <span style="color: #000099;">$calc</span><span style="color: #FF0000;">&#40;</span> <span style="color: #990000;">%seconds</span> <span style="color: #FF0000;">/</span> 60 <span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%hours</span> = <span style="color: #000099;">$calc</span><span style="color: #FF0000;">&#40;</span> <span style="color: #990000;">%minutes</span> <span style="color: #FF0000;">/</span> 60 <span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%days</span> = <span style="color: #000099;">$calc</span><span style="color: #FF0000;">&#40;</span> <span style="color: #990000;">%hours</span> <span style="color: #FF0000;">/</span> 24 <span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%weeks</span> = <span style="color: #000099;">$calc</span><span style="color: #FF0000;">&#40;</span> <span style="color: #990000;">%days</span> <span style="color: #FF0000;">/</span> 7 <span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%years</span> = <span style="color: #000099;">$calc</span><span style="color: #FF0000;">&#40;</span> <span style="color: #990000;">%days</span> <span style="color: #FF0000;">/</span> 365.22222222222 <span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #990000;">%months</span> = <span style="color: #000099;">$calc</span><span style="color: #FF0000;">&#40;</span> <span style="color: #990000;">%years</span> * 12 <span style="color: #FF0000;">&#41;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$prop</span> == seconds<span style="color: #FF0000;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #990000;">%seconds</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$prop</span> == minutes<span style="color: #FF0000;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #990000;">%minutes</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$prop</span> == hours<span style="color: #FF0000;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #990000;">%hours</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$prop</span> == days<span style="color: #FF0000;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #990000;">%days</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$prop</span> == weeks<span style="color: #FF0000;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #990000;">%weeks</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$prop</span> == months<span style="color: #FF0000;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #990000;">%months</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$prop</span> == years<span style="color: #FF0000;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #990000;">%years</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #990000;">%years</span><br />
<span style="color: #FF0000;">&#125;</span><br />
<br />
<span style="color: #994444;">alias</span> myage <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span> == <span style="color: #000099;">$null</span> || <span style="color: #000099;">$1</span> == set<span style="color: #FF0000;">&#41;</span> <span style="color: #FF0000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span> $<span style="color: #000099;">$input</span><span style="color: #FF0000;">&#40;</span>What is your birth date? $+ <span style="color: #000099;">$crlf</span> $+ Example: $+ <span style="color: #000099;">$crlf</span> 13.12.1976 23:59:59,e,Birth date?<span style="color: #FF0000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #FF0000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == sec<span style="color: #FF0000;">&#41;</span> <a href="http://www.mirc.com/msg"><span style="color: #990000; font-weight: bold;">msg</span></a> <span style="color: #000099;">$active</span> I am <span style="color: #000099;">$age</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span><span style="color: #FF0000;">&#41;</span>.<span style="color: #008000;">seconds</span> seconds old.<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == min || <span style="color: #000099;">$1</span> == minute || <span style="color: #000099;">$1</span> == minutes<span style="color: #FF0000;">&#41;</span> <a href="http://www.mirc.com/msg"><span style="color: #990000; font-weight: bold;">msg</span></a> <span style="color: #000099;">$active</span> I am <span style="color: #000099;">$age</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span><span style="color: #FF0000;">&#41;</span>.<span style="color: #008000;">minutes</span> minutes old.<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == hrs || <span style="color: #000099;">$1</span> == hour || <span style="color: #000099;">$1</span> == hours<span style="color: #FF0000;">&#41;</span> <a href="http://www.mirc.com/msg"><span style="color: #990000; font-weight: bold;">msg</span></a> <span style="color: #000099;">$active</span> I am <span style="color: #000099;">$age</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span><span style="color: #FF0000;">&#41;</span>.<span style="color: #008000;">hours</span> hours old.<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == day || <span style="color: #000099;">$1</span> == days<span style="color: #FF0000;">&#41;</span> <a href="http://www.mirc.com/msg"><span style="color: #990000; font-weight: bold;">msg</span></a> <span style="color: #000099;">$active</span> I am <span style="color: #000099;">$age</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span><span style="color: #FF0000;">&#41;</span>.<span style="color: #008000;">days</span> days old.<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == wek || <span style="color: #000099;">$1</span> == week || <span style="color: #000099;">$1</span> == weeks<span style="color: #FF0000;">&#41;</span> <a href="http://www.mirc.com/msg"><span style="color: #990000; font-weight: bold;">msg</span></a> <span style="color: #000099;">$active</span> I am <span style="color: #000099;">$age</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span><span style="color: #FF0000;">&#41;</span>.<span style="color: #008000;">weeks</span> weeks old.<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == mth || <span style="color: #000099;">$1</span> == month || <span style="color: #000099;">$1</span> == months<span style="color: #FF0000;">&#41;</span> <a href="http://www.mirc.com/msg"><span style="color: #990000; font-weight: bold;">msg</span></a> <span style="color: #000099;">$active</span> I am <span style="color: #000099;">$age</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span><span style="color: #FF0000;">&#41;</span>.<span style="color: #008000;">months</span> months old.<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">elseif</span> <span style="color: #FF0000;">&#40;</span><span style="color: #000099;">$1</span> == yrs || <span style="color: #000099;">$1</span> == year || <span style="color: #000099;">$1</span> == years<span style="color: #FF0000;">&#41;</span> <a href="http://www.mirc.com/msg"><span style="color: #990000; font-weight: bold;">msg</span></a> <span style="color: #000099;">$active</span> I am <span style="color: #000099;">$age</span><span style="color: #FF0000;">&#40;</span><span style="color: #990000;">%myage</span>.<span style="color: #008000;">birthday</span><span style="color: #FF0000;">&#41;</span>.<span style="color: #008000;">years</span> years old.<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <a href="http://www.mirc.com/msg"><span style="color: #990000; font-weight: bold;">msg</span></a> <span style="color: #000099;">$active</span> My age in: Seconds: <span style="color: #000099;">$age</span><span style="color:
