<?
// function to remove the hyphen or underscore from filename.
function removeHyphen($filename) {
    
$target $filename;
    
$patterns[0] = '/-/';
    
$patterns[1] = '/_/';
    
$replacements[0] = ' ';
    
$replacements[1] = ' ';
    
$filename preg_replace($patterns$replacements$target);
    return 
$filename;
}
// function to capatalize the first character of each word.  Must be called after
// the removal of the hyphen or underscore
function capFirstWord($word) {
    
$cap $word;
    
$cap explode(' '$cap);
        foreach(
$cap as $key => $value) {
            
$cap[$key] = ucfirst($cap[$key]); 
        }
    
$word implode(' '$cap);
    return 
$word;
}
// Formats the file.  This is the main function that calls all functions explained above.
function formatFile($name) {
    
$name removeHyphen($name);
    
$name capFirstWord($name);
    return 
$name;
}

function 
scriptList ($dir) {
$mydir dir('./'.$dir);
echo 
"<dl>";
    while((
$file $mydir->read()) !== false) {
        
$ffile "./$dir/$file";
        if (
$file != "." && $file != ".." && !fnmatch("*.php"$ffile) && !fnmatch("*.desc"$ffile)) {
        
$size round(filesize($ffile) / 10242);
        
$mod filemtime($ffile);
            echo 
"\n\n<dt><a href='$ffile'>".formatFile($file)."</a> ";
            echo
"<font size='2'>File Size: " .$size"KB - Last Modified: " .date('d/m/Y'$mod). " - To Update Type:</font> ";
            echo 
"<input type='text' id='".$dir.$file."' onclick='copyToClipboard(\"".$dir.$file."\");' value='/sbnc tcl catch {exec wget --output-document=scripts/".$file." http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).ltrim($ffile,".")."} o; foreach l [split \$o \\n\"] { putlog \$l }; rehash;' /></dt>";
            
$descfile $ffile.'.desc';
            if (
file_exists($descfile)) {
                
$fh fopen($descfile'r');
                
$theData fgets($fh);
                
fclose($fh);
                echo 
"\n<dd><font color='#736F6E'>".$theData." <a href='".$descfile."'>Read more.</a></font></dd>";
            }
            echo 
"\n<dd style='line-height: 0.6'>&nbsp;</dd>";
         }
    }
echo 
"\n</dl>\n";
$mydir->close();
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sBNC Scripts</title>

<script type="text/javascript">
function copyToClipboard(field)
{
    var content = eval(document.getElementById(field))
    content.focus()
    content.select()
    range = content.createTextRange()
    range.execCommand("Copy")
}
</script>
<style type="text/css">
 dd.c3 {line-height: 0.6}
 dd.c2 {color: #736F6E}
 span.c1 {font-size: 80%}
</style>
</head>
<body>
<h1>sBNC Scripts</h1>
<p>The sBNC scripts here are split into 4 sections, firstly scripts which work on any version of sBNC (or at least as far as I know), scripts which work on 1.1, scripts which work on 1.2, and scripts which are just uploaded for the sake of having all scripts uploaded in one place (ie I've not edited in any way).</p>
<p>The scripts you find here are offered free to anyone who wants to use them, with the understanding that your using them at your own risk, and that I can't promise you any support for problems you might encounter. The reason these scripts are available is simply that I thought others might want to use and improve upon them.</p>
<p>Also I won't pretend that I wrote all these scripts from scratch, there are scripts you will find here, that I might have only edited to fix a typo. In fact there's a whole folder of scripts I've not edited at all, just uploaded so I have a place to wget them from. At the same time there are scripts here which are written completely from scratch, and major edits to scripts I have found elsewhere, to add functionality or just to suit me better.</p>
<p>To install these scripts you will need to place them in the scripts folder, and then edit the sbnc.tcl script source list, to tell the bnc to load the script.  If it has been added to the tcl, you can download and update the script simply by running the command in the text box below.</p>
<p>If you do need to get in touch with me for whatever reason you can try #kh on irc.swiftirc.net. For other sbnc issues I would checking out the support <a href="http://www.shroudbnc.info/Support.aspx">here.</a></p>
<h2>sBNC Scripts</h2>
<h3>Unedited Scripts</h3>
<p>Firstly if you want to tap into the folder with the unedited scripts in, you can find those at <a href="./unedited/">/unedited/</a>.</p>
<h3>Scripts for all versions</h3>
<? scriptList ("sbnc"); ?>
<h3>Scripts for sbnc 1.2</h3>
<? scriptList ("sbnc1.2"); ?>
<h3>Scripts for sbnc 1.1</h3>
<? scriptList ("sbnc1.1"); ?>
 <p>
    <a href="index.phps">Page source</a>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="valid-xhtml10-blue"
        alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
  </p>
 </body>
</html>