<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
<rss version="0.92" xml:base="http://jeaun.com">
<channel>
 <title>Jeaun - Link-Up - Comments</title>
 <link>http://jeaun.com/linkup</link>
 <description>Comments for &quot;Link-Up&quot;</description>
 <language>en</language>
<item>
 <title>Link-Up</title>
 <link>http://jeaun.com/linkup</link>
 <description>&lt;!--break--&gt;
&lt;?php
define( &#039;LINKUP_FILE&#039;, &#039;files/links.temp&#039; );
define( &#039;LINKUP_TITLE&#039;, &#039;jeauns are reading...&#039; );
define( &#039;LINKUP_MAX_TEXT_LENGTH&#039;, 30 );
define( &#039;LINKUP_MAX_COMMENT_LENGTH&#039;, 200 );

$error_message;
$linkurl;
$linktext;
$linkcomment;
$mode;

if ( ! file_exists( LINKUP_FILE )) {
  touch( LINKUP_FILE );
}

if ( isset( $_GET[&#039;linktext&#039;] ) &amp;&amp; isset( $_GET[&#039;linkurl&#039;] ) ) {
  $linkurl = $_GET[&#039;linkurl&#039;];
  $linktext = $_GET[&#039;linktext&#039;];
  $linkcomment = $_GET[&#039;linkcomment&#039;];
  $mode = $_GET[&#039;mode&#039;];
  if ( $mode != &#039;fill&#039; ) {
    $error_message = add_link( $linktext, $linkurl, $linkcomment );
    if ( strlen($error_message) == 0 ) {
      $linktext = &quot;&quot;;
      $linkurl = &quot;&quot;;
      $linkcomment = &quot;&quot;;
      header(&#039;location:/linkup&#039;);
    }
  }
}


function add_link( $linktext, $linkurl, $linkcomment ) {

  $url = stristr( $linkurl, &#039;http://&#039; );
//  $text = substr( $linktext, 0, LINKUP_MAX_TEXT_LENGTH );
  $text = $linktext;
  $comment = $linkcomment;

  if ( strlen($url ) &lt; 1) {
    //TODO: make this a regex check.
    return &quot;$linkurl is not a valid URL.&quot;;
  }
  if ( strlen($text) &lt; 1 ) {
    return &quot;Please give the link a name.&quot;;
  }
  if ( strlen($text) &gt; LINKUP_MAX_TEXT_LENGTH ) {
    return &quot;The link name is too long.&quot;;
  }
  if ( strlen($comment) &gt; LINKUP_MAX_COMMENT_LENGTH ) {
    return &quot;The comment is too long.&quot;;
  }

  $newLinkText = &quot;      &lt;li&gt;&lt;a href=\&quot;$url\&quot;&gt;$text&lt;/a&gt; - &lt;em&gt;$comment&lt;/em&gt;&lt;/li&gt;\n&quot;;
  $links = file( LINKUP_FILE );
  foreach ( $links as $link ) {
    if ( $link == $newLinkText ) {
      return &quot;That link already exists in the list.&quot;;
    }
  }
  array_unshift( $links, $newLinkText );
  $handle = fopen( LINKUP_FILE, &#039;w&#039; );
  foreach ( $links as $link ) {
    fwrite( $handle, $link );
  }
  fclose( $handle );
}

?&gt;
&lt;link href=&quot;files/linkup.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;div id=&quot;linkup&quot;&gt;
    &lt;h1&gt;&lt;?php echo LINKUP_TITLE; ?&gt;&lt;/h1&gt;
    &lt;ul&gt;
&lt;?php include( LINKUP_FILE ); ?&gt;
    &lt;/ul&gt;
    &lt;?php if ( strlen($error_message) &gt; 0 ) {?&gt;
    	 &lt;span class=&quot;error&quot;&gt;&lt;?php echo $error_message; ?&gt;&lt;/span&gt;
    &lt;?php }?&gt;
    &lt;form action=&quot;linkup&quot; method=&quot;get&quot; enctype=&quot;text/plain&quot;&gt;
      Title: &lt;input type=&quot;text&quot; name=&quot;linktext&quot; value=&quot;&lt;?php echo $linktext; ?&gt;&quot; maxlength=&quot;&lt;?php echo LINKUP_MAX_TEXT_LENGTH; ?&gt;&quot; size=&quot;40&quot;/&gt;
      URL: &lt;input type=&quot;text&quot; name=&quot;linkurl&quot; value=&quot;&lt;?php echo $linkurl; ?&gt;&quot; size=&quot;40&quot;/&gt;
      Comment: &lt;textarea name=&quot;linkcomment&quot; cols=&quot;40&quot; rows=&quot;3&quot;&gt;&lt;?php echo $linkcomment; ?&gt;&lt;/textarea&gt;
      &lt;br/&gt;
      &lt;input type=&quot;submit&quot; name=&quot;linksubmit&quot; value=&quot;Submit&quot;/&gt;
    &lt;/form&gt;
    &lt;p&gt;&lt;em&gt;Bookmark this link, then click it when you&#039;re on a page that you want to add here: &lt;a href=&quot;javascript:q=location.href;p=document.title;void(open(&#039;http://jeaun.com/linkup?mode=fill&amp;linkurl=&#039;+encodeURIComponent(q)+&#039;&amp;linktext=&#039;+encodeURIComponent(p)))&quot;&gt;+=Link-Up&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
  &lt;/div&gt;</description>
 <pubDate>Sun, 08 Apr 2007 09:38:28 -0700</pubDate>
</item>
</channel>
</rss>
