i-fubar.com

Slashpoem Generator Script

Feel free to use this. Working version here. This is PHP, a server-side scripting language. To use: copy and paste into a text editor, save as slashpoem.php and upload it to your server. It's all for fun.

<?
// public released under no license whatsoever
//       Bill Pellowe 2003
if(trim($slashpoem)!="")
{
        $view="do";
}
else { $view = "ask"; }
 
// make pull-down
$pulldown = "";
for($i=5; $i<51; $i++)
{       
        // default is width 12
        if($i==12)
        { $selected = " selected"; }
        else
        { $selected = ""; }
        $pulldown .= "<option value=\"$i\""
                          . $selected
                          . ">$i</option>";
}
        
if($view=="ask"){
        ?>
<html><head><title>slashtext generator</title></head><body>
<font face="courier, courier new" size=2>
<form action="slashpoem.php" method="post">
<input type="hidden" name="submit" value="submit">
<ul>
Type or paste some text:</ul>
<textarea name="slashpoem" rows="15" cols="50">
</textarea>
<br><br>
Line width: <select name="length">
<?=$pulldown?>
</select>
<input type="submit" value="get slashpoem">
</form>
<?
}
elseif($view=="do")
{     
        if($redone=="yes") { $slashpoem=urldecode($slashpoem); }
        else{ $slashpoem=trim(str_replace(" ", "", str_replace("\n", "", $slashpoem))); }
        
        $hfbuttons = "<table border=0><tr><td>"
                . "<form action=\"slashpoem.php\" method=\"post\">"
                . "<input type=\"submit\" value=\"new\">"
                . "</form></td><td>"
                . "<form action=\"slashpoem.php\" method=\"post\">"
                . "<input type=\"hidden\" name=\"redone\" value=\"yes\">"
                . "<input type=\"hidden\" name=\"slashpoem\" value=\""
                . urlencode($slashpoem)
                . "\">"
                . "<input type=\"submit\" value=\"re-do: width:\"><select name=\"length\">"
                . $pulldown
                . "</select></form>"
                . "</td></tr></table>";
                
         ?>
     <html><head><title>Your slashpoem</title></head><body>
     <font face="courier, courier new" size=2>
         <?=$hfbuttons ?>
         <hr>
         <?
         $tempString = $slashpoem;
         if(!($length))
         { $length = 12; }
         $pos = 0;
         $direction = "forward";
         $symbol = "&gt;";
     while (strlen($tempString) > 0)
     {
            if($direction == "forward")
        { $pos++; }
        else { $pos--; }
 
            $i=$pos;
            while ($i - 1 > 0)
            { echo $symbol;
              $i--;
            }
        // print the letter     
        echo substr($tempString, 0, 1);
        $tempString = substr($tempString, 1);
            // print more
            for($i=$pos; $i<$length; $i++)
            { echo $symbol; }
        echo "<br>";
        if($pos == 1)
        { $direction="forward";
          $symbol = "&gt;"; }
        elseif($pos==$length)
        { $direction = "backward";
          $symbol = "&lt;"; }
     }
 
                ?>
            <hr>
            <?=$hfbuttons ?>
                <?
}       
?>
<hr size=1>
</font><font face="verdana" size=2><a href="http://www.i-fubar.com/slashpoem.html">See code</a></font>
</body></html>