#!/usr/local/bin/perl 

# CPAN Modules Used

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


umask 000 ;

# initialize variables

$ad_style = param('ad_style') ;
$tag_string = param('tag_string') ;
$sig_string = param('sig_string') ;
$ad_left = param('ad_left') ;
$ad_left_carry = param('ad_left_carry') ;
$stock_view = param('stock_view') ;

####
# Author Information
$author_name = param('author_name') || "" ;	
$author_email = param('author_email') || "" ;	
$author_url = param('author_url') || "" ;

$image_filename = param('image_filename') ;

	$author_safe_email = $author_email ;
	$author_safe_email =~ s/\^\&\|\<\>/./g ;

$directory = "./MyOrbit" ;

	%cookies = fetch CGI::Cookie;
	@jar = (exists($cookies{'user'})) ? $cookies{'user'}->value : ();
	if (($jar[1] ne "") && ($author_email eq "")) { $author_email = $jar[1] ; }
	if ($jar[3] ne "" )  { $password = $jar[3] ; }


if ($author_email eq "" )
{
	&print_screen;
}
if ( -d "$directory/$author_safe_email" )
{
	# old user
	

	$old_password = "<p>Please enter your password below." ;

	&print_screen;

} else {
	# new user
	$new_password = "<p>This password enables you to save your unad so you can share it in our public gallery." ;
	$old_password = "<p>Welcome!  We'll need a password so you can access your account." ;
	$c = new CGI::Cookie(-name    =>  'user',
                             -value   =>  ["$author_name","$author_email", "$author_url", "" ],
                             -expires =>  '+3M' 	# three months
	                    );

	
	mkdir ("$directory/$author_safe_email",0777) ;

	open (DIR_FILE, ">./MyOrbit/$author_safe_email/.author_info") ;
	print DIR_FILE "author_email:", $author_email, "\n" ;
	print DIR_FILE "author_name:", $author_name, "\n" ;
	print DIR_FILE "author_url:", $author_url, "\n" ;
	print DIR_FILE "password:", "NEW_USER", "\n" ;
	chmod 0644, DIR_FILE ;
	close DIR_FILE ;

	


	&print_screen ;

}


exit(0);

sub print_screen {

###
###
### Main Screen
###
if ($c ne "")
{
print header(-cookie=>$c, -type=>'text/html',-expires=>'now');
} else
{
print header(-type=>'text/html',-expires=>'now');
}
print <<"_____EoI2_____";


<HTML>
<HEAD>
<TITLE>undesign - in orbit</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 login_off = new Image() ;
        login_off.src = "/images/orbit/buttons/login_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 | the undesigners"></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="Everything is an experiment." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/images/orbit/tibor_sm1.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="THEM = US" onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/images/orbit/tibor_sm2.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Consumer culture is an oxymoron." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/images/orbit/tibor_sm3.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Wealth is poverty." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/images/orbit/tibor_sm4.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Religion works better for corporations than for people." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/images/orbit/tibor_sm5.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Rules are good. Break them." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/images/orbit/tibor_sm6.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Success = Boredom" onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/images/orbit/tibor_sm7.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="Mistakes, misunderstandings, and mis-comprehensions provide fresh ideas." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img src="/images/orbit/tibor_sm8.gif" hspace="2" vspace="2" width="15" height="15" border="1"></a><a href="/glimpses.html" title="You'll see it better if you look upside down." onMouseOver="wwtson()" onMouseOut="wwtsoff()"><img 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="12" align="left">&nbsp;</TD></TR>  
  <TR>
    
      <TD width="85"><img src="/trans.gif" width="85" height="1"></TD>
      <TD></TD>
    
      <TD valign="top">&nbsp;</TD>
      <TD></TD>
    
      <TD valign="top">&nbsp;</TD>
      <TD></TD>
    
      <TD valign="top">&nbsp;</TD>
      <TD></TD>
    
      <TD valign="top">&nbsp;</TD>
      <TD></TD>
    
      <TD valign="top" width="30%">&nbsp;</TD>
      <TD></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%">
	
	

<br><center>
<FONT size="2" FACE="VERDANA,ARIAL,HELVETICA,SANS-SERIF">
$old_password

<p>$new_password

</center></FONT>

<FORM method="POST" name="loginform" action="kalman.cgi" >
<INPUT TYPE="hidden" NAME="ad_style" VALUE="$ad_style">
<INPUT TYPE="hidden" NAME="tag_string" VALUE="$tag_string">
<INPUT TYPE="hidden" NAME="sig_string" VALUE="$sig_string">
<INPUT TYPE="hidden" NAME="ad_left" VALUE="$ad_left">
<INPUT TYPE="hidden" NAME="ad_left_carry" VALUE="$ad_left_carry">
<INPUT TYPE="hidden" NAME="author_name" VALUE="$author_name">
<P align="CENTER">
<TABLE cellpadding="5" cellspacing="0" border="0" width="100%">

<TR>
<TD align="RIGHT">
<FONT size="2" FACE="VERDANA,ARIAL,HELVETICA,SANS-SERIF">
Your email
</FONT></TD>
<TD align="LEFT">
<INPUT TYPE="text" NAME="author_email" VALUE="$author_email">
</TD>
</TR>

<TR>
<TD align="RIGHT">
<FONT size="2" FACE="VERDANA,ARIAL,HELVETICA,SANS-SERIF">
Your password
</FONT></TD>
<TD align="LEFT">
<INPUT TYPE="password" NAME="password" VALUE="$password">
<INPUT TYPE="hidden" NAME="author_url" VALUE="$author_url">
<INPUT TYPE="hidden" NAME="stock_view" VALUE="$stock_view">
<INPUT TYPE="hidden" NAME="image_filename" VALUE="$image_filename">
</TD>
</TR>

<TR>
<TD align="RIGHT">
<br>
</TD>
<TD align="LEFT">
<script Language="JavaScript">
document.write (
        '<a href="javascript:document.loginform.submit();" onMouseOver="swapON(\\'login\\');" onMouseOut="swapOFF(\\'login\\');">' +
        '<img src="/images/orbit/buttons/login.gif" border="0" name="login"></a>')
</script>
<noscript>
<INPUT TYPE="submit" VALUE="login">
</noscript>
</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);

}
