#!/usr/local/bin/perl  

# CPAN Modules Used

use CGI qw(:standard );
use Time::CTime ;
use CGI::Cookie;

        %cookies = fetch CGI::Cookie;
        if (exists($cookies{'user'})) {
$personal_directory = <<"_____EoI2_____";
        <a href="kalman.cgi" onMouseOver="swapON('viewmine');" onMouseOut='swapOFF("viewmine");'>
        <img src="/images/orbit/buttons/viewmine.gif" border="0" name="viewmine"></a>
_____EoI2_____
        }

	open (DIR_FILE, "fgrep -l PUBLISHED_true ./MyOrbit/*/*info | ") ;
	@published_list = grep(!/^.*MyOrbit\/deleted.*$/, <DIR_FILE>) ;
	close DIR_FILE ;
	chop @published_list;
	&create_author_email_list ;
	&sort_list_by_date_created ;
	&find_author_name ;

	&print_screen ;

exit(0);

sub find_author_name {
	$expression1 = 'author_name:' ;
	$expression2 = 'author_url:' ;
        for ($i=0 ; $i <= $#unique_author; $i++ ) {
		# shame on me for opening the file twice instead of chopping
		$file_name = "./MyOrbit/$unique_author[$i]/.author_info" ;
		open (FGREP_FILE, "fgrep $expression1 $file_name |") ;
		$unique_name[$i] = <FGREP_FILE> ;
		chop $unique_name[$i] ;
		close FGREP_FILE ;
		$unique_name[$i] =~ s/$expression1// ;
		open (FGREP_FILE, "fgrep $expression2 $file_name |") ;
		$unique_url[$i] = <FGREP_FILE> ;
		chop $unique_url[$i] ;
		close FGREP_FILE ;
		$unique_url[$i] =~ s/$expression2// ;
	}
}

# reverse sort
sub sort_function { $KEYS[$b] <=> $KEYS[$a] ; }
sub sort_list_by_date_created {
        local(@KEYS);
        for ($i=0 ; $i <= $#unique_author; $i++ ) {
		$directory_name = "./MyOrbit/$unique_author[$i]" ;
 		open (DIR_FILE, "fgrep -l PUBLISHED_true $directory_name/*info | ") ;
                $date_key[$i] = 0 ;
                while ($filename = <DIR_FILE>) {
                        chop $filename ;
                        $date_mod = (stat($filename))[9] ;
                        if ($date_key[$i] < $date_mod ) { $date_key[$i] = $date_mod ; }
                }
                close DIR_FILE ;
                push(@KEYS, $date_key[$i]);
		$date_key[$i] = strftime("%B %e, %Y: %R",localtime($date_key[$i])) ;
        }
        @unique_author = @unique_author[sort sort_function $[..$#unique_author];
        @date_key = @date_key[sort sort_function $[..$#date_key];
}
sub create_author_email_list {
	for ($i = 0; $i <= $#published_list; $i++ ) {
		$published_list[$i] =~ s/^\.\/([^\/]+)\/([^\/]+)\/([^\/]+)/$3/ ;
		$published_list[$i] =~ s/^(.*)\.([0-9]+)\.([0-9]+)\.info$/$1/ ;
	}
	@unique_author = grep { not $found{$_}++ } @published_list;
}
sub encode {
        local($variable) = $_[0];
        $KeepUnencoded = 'a-zA-Z 0-9_\\-@.=' ;
    $variable=~s/([^$KeepUnencoded])/sprintf("%%%02X",ord($1))/ego;
    $variable=~s/ /+/gm;
    return $variable
}
sub build_unadvertiser_list {

for ( $i = 0 ; $i<=$#unique_author  ; $i++ )
{
$encoded_author = &encode($unique_name[$i]) ;
print <<"_____EoI2_____";
<TABLE cellpadding="2" cellspacing="0" width="100%" border="0">
                <TR>
                <TD align="LEFT" valign="TOP" width="25%" >
                <FONT size="1" FACE="VERDANA,ARIAL,HELVETICA"><B>
                &nbsp;&nbsp;<A HREF="tiborocity.cgi?author_page=$encoded_author">$unique_name[$i]</A>
                </B></FONT></TD>
                <TD align="LEFT" valign="TOP" width="50%" >
                <FONT size="1" FACE="VERDANA,ARIAL,HELVETICA"><B>
_____EoI2_____
if ($unique_url[$i] ne "")
{
print <<"_____EoI2_____";
                <A HREF="$unique_url[$i]">$unique_url[$i]</A>
_____EoI2_____
}
print <<"_____EoI2_____";
                </B></FONT></TD>
                <TD align="LEFT" valign="TOP" width="25%" >
                <FONT size="1" FACE="VERDANA,ARIAL,HELVETICA">
                $date_key[$i]
                </FONT></TD>
                </TR>
                </TABLE>


                <TABLE cellpadding="0" cellspacing="0" width="100%" border="0">
                <TR>
                <TD align="CENTER" valign="TOP" BGCOLOR="#999999">
                <img src="/trans.gif" width="1" height="1" border="0" alt=""></TD>
                </TR>
                </TABLE>
_____EoI2_____
}
	

}
sub print_screen {

###
###
### Main Screen
###
print header(-type=>'text/html', -expires=>'now');
print <<"_____EoI2_____";


<HTML>
<HEAD>
<TITLE>undesign - meet the unadvertisers</TITLE>
<link rel="SHORTCUT ICON" HREF="http://undesign.org/favicon.ico">
<META NAME="Author" CONTENT="media.org">
<META NAME="Keywords" CONTENT="Tibor Kalman,webchick,undesign,Kalle Lasn,adbusters,WWTD,media.org,culture jamming,social responsibility">
<META NAME="Description" CONTENT="Context is everything: Tibor Kalman inspires a plan for all seasons.">
<style type="text/css">
<!--
A:visited {COLOR: #666666; TEXT-DECORATION: underline;}
A:link {COLOR: #666666; TEXT-DECORATION: underline;}
A:hover {COLOR: #333333; TEXT-DECORATION: underline;}

A.white:visited {COLOR: #ffffff; TEXT-DECORATION: none;}
A.white:link {COLOR: #ffffff; TEXT-DECORATION: none;}
A.white:hover {COLOR: #333333; TEXT-DECORATION: underline;}

A.gray:visited {COLOR: #666666; TEXT-DECORATION: none;}
A.gray:link {COLOR: #666666; TEXT-DECORATION: none;}
A.gray:hover {COLOR: #333333; TEXT-DECORATION: underline;}
-->
</style>

<script type="text/javascript" src="/orbit/js/win.js"></script>

<script type="text/javascript" Language="JavaScript">
<!--
        var create_off = new Image() ;
        create_off.src = "/images/orbit/buttons/create_off.gif";
        var viewpublic_off = new Image()  ;
        viewpublic_off.src = "/images/orbit/buttons/viewpublic_off.gif" ;
        var viewmine_off = new Image()  ;
        viewmine_off.src = "/images/orbit/buttons/viewmine_off.gif" ;
function swapON (imagename)
{
        var imagename ;
        the_swap_image = eval ("document." + imagename) ;
        the_old_swap = the_swap_image.src
        the_swap_image.src = eval (imagename + "_off.src") ;

}

function swapOFF (imagename)
{
        var imagename ;
        theimage = eval ("document." + imagename) ;
        theimage.src = the_old_swap  ;

}



// -->
</script>

</HEAD>

<BODY bgcolor="#cccccc" link="#999999" vlink="#999999" alink="#999999" text="#666666" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">


<TABLE width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <TR><td valign="top" height="80%">
  
<!-- BEGIN HEADER TABLE -->

<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
  <TR> 
    <TD height="75" align="left" valign="middle" bgcolor="#ffffff">
    
<TABLE width="750" border="0" cellpadding="0" cellspacing="0">
  <TR> 
    <TD height="75" align="left" valign="middle">
		<a href="/" title="undesign. a plan for all seasons."><img src="/images/undesign_sm.gif" width="291" height="50" hspace="20" border="0" alt="UNDESIGN | a plan for all seasons"></a>
	</TD><td align="right" bgcolor="#ffffff">
				<img src="/trans.gif" hspace="2" vspace="0" name="tibor" width="62" height="13" border="0"><a href="/glimpses.html" title="Design is a means, not an end. A language, not content." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="Design is a means, not an end. A language, not content." src="/images/orbit/tibor_sm1.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Wealth is a means, not an end." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="Wealth is a means, not an end." src="/images/orbit/tibor_sm2.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="F*ck committess. I believe in lunatics." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="F*ck committess. I believe in lunatics." src="/images/orbit/tibor_sm3.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Good clients are smarter than you." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="Good clients are smarter than you." src="/images/orbit/tibor_sm4.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Bad clients are dumber than you." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="Bad clients are dumber than you." src="/images/orbit/tibor_sm5.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Most media, architecture, design and art exist for the sole purpose of creating wealth." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="Most media, architecture, design and art exist for the sole purpose of creating wealth." src="/images/orbit/tibor_sm6.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Waste Not a Moment." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="Waste Not a Moment." src="/images/orbit/tibor_sm7.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Never trust someone who tells the truth. They aren't trustworthy." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="Never trust someone who tells the truth. They aren't trustworthy." src="/images/orbit/tibor_sm8.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Exercise free will and learn from your mistakes. There will be many." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img alt="Exercise free will and learn from your mistakes. There will be many." src="/images/orbit/tibor_sm9.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a>
	</td><TD width="30" bgcolor="#ffffff"><img src="/trans.gif" width="30" height="1">
	</TD>
  </TR>
</table>

</TD>
</TR>
</table>


<!-- BEGIN CONTENT TABLE -->

<TABLE width="750" border="0" cellpadding="0" cellspacing="0" vspace="0" hspace="0">  
  <TR><TD colspan="14" align="left">&nbsp;</TD></TR>  
  <TR><TD colspan="14" align="left">&nbsp;</TD></TR>  

  <TR>
  
<!-- LEFT QUOTE -->

    <TD valign="top" align="right"><a href="/orbit/unmadison.cgi"  title="WWYS? Join our un-advertising campaign today!"><img src="/left_quote.gif" border="0" width="70" height="62" alt="quote"></a></TD>

<!-- BEGIN CORE CONTENT -->

	<TD colspan="9" valign="top" width="100%">

		<a href="/glimpses.html" title="Look to Tibor for inspiration." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/tibor2.gif" width="58" height="58" hspace="8" vspace="5" border="1" alt="Tibor" align="left"></a>

<br><b><font FACE="Arial, Helvetica, sans-serif" size="+1"><font color="#999999">undesign</font> <font color="#eeeeee">in</font> <font color="#ffffff">orbit</font></font></b>
<br><font FACE="Verdana, Arial, Helvetica, sans-serif" size="1" color="#666666"> &#147;Everything is an Experiment.&#148; - <a href="/glimpses.html" title="Look to Tibor for inspiration." onMouseOver="wwtson()" onMouseOut="wwtsoff()">Tibor Kalman</a><br></font>

<br clear="all"><br>
<FONT size="2" FACE="VERDANA,ARIAL,HELVETICA,SANS-SERIF">
Make an un-statement! Create an <b><font color="#999999">UN</font><font color="#666666">AD</font></b> and add your voice to <a href="/orbit/">UNDESIGN IN ORBIT.</a>
</font>


<br clear="all"><br>

		<TABLE cellpadding="2" cellspacing="0" width="100%" border="0" bgcolor="#999999">
		<TR>
		<TD align="LEFT" valign="TOP" width="25%">
		<FONT size="1" FACE="VERDANA,ARIAL,HELVETICA" color="#ffffff"><b>
		&nbsp;unadvertiser
		</b></FONT></TD>
		<TD align="LEFT" valign="TOP" width="50%">
		<FONT size="1" FACE="VERDANA,ARIAL,HELVETICA" color="#ffffff"><b>
		URL
		</b></FONT></TD>
		<TD align="LEFT" valign="TOP" width="25%">
		<FONT size="1" FACE="VERDANA,ARIAL,HELVETICA" color="#ffffff"><b>
		Last update
		</b></FONT></TD>		
		</TR>
		</TABLE>
		
		<TABLE cellpadding="0" cellspacing="0" width="100%" border="0">
		<TR>
		<TD align="CENTER" valign="TOP" BGCOLOR="#666666">
		<img src="/trans.gif" width="1" height="1" border="0" alt=""></TD>
		</TR>
		</TABLE>
		
_____EoI2_____

&build_unadvertiser_list ;

print <<"_____EoI2_____";
		

<br>
<TABLE cellpadding="3" cellspacing="0" border="0">
	<TR>
<TD valign="TOP" width="92">
                <a href="context.cgi" onMouseOver='swapON("create")' onMouseOut='swapOFF("create")'><img name="create" alt="Create unad" border="0" src="/images/orbit/buttons/create.gif"></a>
        </TD>
        <TD valign="top">
                <form action="tiborocity.cgi" method="post">
                <a href="tiborocity.cgi" onMouseOver='swapON("viewpublic")' onMouseOut='swapOFF("viewpublic")'><img name="viewpublic" alt="View Public Gallery" border="0" src="/images/orbit/buttons/viewpublic.gif"></a>
        </TD>
	<TD valign="top">
$personal_directory
	</TD>
</TR></TABLE>



</FORM>

<br clear="all"><br>
<br><br>
</TD>
   
<!-- RIGHT QUOTE -->

	<TD valign="top" align="left" nowrap><a href="/orbit/unmadison.cgi"  title="WWYS? Join our un-advertising campaign today!"><img src="/right_quote.gif" border="0" width="70" height="62" alt="quote"></a></TD>

	<TD width="10">&nbsp;</TD>
   
</TR></TABLE>

</td></tr><tr><td valign="top" bgcolor="#ffffff">


<!-- BEGIN FOOTER TABLE -->

<br>
<TABLE width="98%" border="0" cellpadding="0" cellspacing="0"><TR> 
	<TD width="85" bgcolor="#ffffff"><img src="/trans.gif" width="85" height="1"></td>
     <TD nowrap align="left" valign="top" bgcolor="#ffffff">
		<br clear="all">
		<A HREF="/" class="gray" title="undesign. a plan for all seasons."><font FACE="Verdana, Arial, Helvetica, sans-serif" size="1" color="#999999">&lt;&lt; home </font></a>
		<br clear="all">
		</TD>
	<TD width="100%" align="center" valign="top" bgcolor="#ffffff">
		<br clear="all">
		<A HREF="http://jam.media.org/" class="gray" title="meet the undesigners."><font FACE="Verdana, Arial, Helvetica, sans-serif" size="1" color="#999999">[ <b>\&amp;\*\$\#\@~!</b> ] </font></a>
		<br clear="all">
	</TD>
     <TD nowrap align="right" valign="top" bgcolor="#ffffff">
		<br clear="all">
		<A HREF="/orbit/" class="gray" title="undesign in orbit."><font FACE="Verdana, Arial, Helvetica, sans-serif" size="1" color="#999999">orbit &gt;&gt;</font></a>
		<img src="/trans.gif" width="30" height="1"> 
		<br clear="all">
		</TD>
  </TR></table>
  <br><br>
  
</td></tr></table>

  
  </BODY>
</HTML>
_____EoI2_____
###
###
### End of Main Screen
###


exit(0);

}
