]> git.quilime.com - aggregate.git/commitdiff
added files
authorGabriel Dunne <gdunne@quilime.com>
Fri, 10 Feb 2012 21:26:30 +0000 (13:26 -0800)
committerGabriel Dunne <gdunne@quilime.com>
Fri, 10 Feb 2012 21:26:30 +0000 (13:26 -0800)
dev.php [new file with mode: 0644]
index.php [new file with mode: 0644]
index_old.php [new file with mode: 0644]
post.php [new file with mode: 0644]
post/class.get.image.php [new file with mode: 0755]
post/demo.php [new file with mode: 0644]
post/index.php [new file with mode: 0644]
style.css [new file with mode: 0644]
thumbs.php [new file with mode: 0644]
v/index_01.php [new file with mode: 0644]

diff --git a/dev.php b/dev.php
new file mode 100644 (file)
index 0000000..1c5ecef
--- /dev/null
+++ b/dev.php
@@ -0,0 +1,393 @@
+<?
+include('/home/quilime/i/php/function.php');
+session_start();
+
+$page   = isset($_GET['page']) ? $_GET['page'] : 0 ;
+$bin    = isset($_GET['bin']) ? $_GET['bin'].'/' : '';
+$link   = isset($_GET['l']) ? $_GET['l'] : '';
+$num_pp = $_SESSION['num_pp']  = setSessionVar('num_pp', 50);
+$return = isset($_GET['return']) ? $_GET['return'] : false;
+
+define('LINK', $link);
+define('ROOT', 'agg/');
+define('WWW', 'http://quilime.com/aggregate/'.ROOT);
+define('NUM_PP', $num_pp);
+define('OFFSET', $page * NUM_PP);
+define('BIN', $bin);
+
+if(LINK && is_dir(ROOT.LINK)) {
+  header('Location: ?bin='.LINK);
+}
+
+if(BIN) {
+  clearKeywords();
+}
+
+if(!LINK) {
+  $agg = fileArray(ROOT.BIN, array(), array('.','..'), WWW.BIN);
+  $agg = sortFiles($agg, 'D', 'M');
+  getKeywords();
+  $agg = filterKeywords($agg); 
+}
+
+switch ($return) 
+{
+ case 'rss' :
+   rss();
+   exit();
+}
+
+function rss() 
+{
+  global $agg;
+
+  header("Content-Type: application/xml;");
+  header("Pragma: no-cache");  
+  header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");  
+  
+  echo '<?xml version="1.0" encoding="UTF-8"?>
+    <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
+    <channel>
+    <title>aggregate</title>
+    <link>http://quilime.com/aggregate/</link>
+    <generator>media.quilime.com</generator>
+    <description>aggregate</description>
+';
+
+
+$count = 20;
+
+foreach($agg as $i)
+{    
+    $count--;
+    if($count == 0) break;
+    echo '
+        <item>
+        <img>'.$i['url'].'</img>
+        <reference>[reference url]</reference>
+        <title>'.$i['name'].'</title>
+        <description>
+        &lt;p&gt;&lt;a href="?l='.$i['name'].'"&gt;&lt;img src="'.$i['url'].'" alt="" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;
+        </description>
+        <link>http://quilime.com/aggregate/?l='.$i['name'].'</link>
+        </item>
+    ';
+}
+
+echo '</channel>
+    </rss>
+';
+}
+
+
+
+
+
+function filterKeywords($agg) {
+  // filter keywords
+  if(sizeof($_SESSION['keywords']) > 0) {
+    $filtered = array();
+    foreach($agg as $f) {
+      foreach($_SESSION['keywords'] as $keyword) {
+       $pattern = '/'.strtolower($keyword).'/';    
+       preg_match($pattern,strtolower($f['name']), $matches);  
+       if(sizeof($matches) > 0) {
+         $filtered[] = $f;
+       }
+      }
+    }
+    $agg = $filtered;
+  }
+  return $agg;
+}
+
+
+
+function search()
+{
+?>
+
+<div id="s">
+<form method="get" action="<?=$_SERVER['PHP_SELF'];?>?t=sdf">
+<input type="text" value="" name="s" style="width:100px;" />
+</form>
+
+<ul style="margin:0;padding:0;">
+<? keywords(); ?>
+</ul>
+
+</div>
+
+<?
+}
+
+
+function aggTitle()
+{
+  global $link;
+  if($link)
+    return '/'.$link;
+  else
+    return BIN ? '/'.BIN:'';
+}
+
+
+
+function keywords()
+{
+    if($_SESSION['keywords']) {
+  foreach($_SESSION['keywords'] as $k) {
+    if(trim($k) == "") continue;
+    echo $k . ' ';
+    echo '<a href="?r='.$k.'">x</a>';
+    echo '<br/>';
+  }
+  }
+}
+
+function clearKeywords()
+{  
+  $_SESSION['keywords'] = array();
+  return;
+}
+
+function getKeyWords()
+{
+  $k = $_GET['s'];
+  $remove = $_GET['r'];
+
+  if($k == "___") {
+      clearKeywords();
+      return;
+  }
+
+  if(!is_array($_SESSION['keywords']))
+    $_SESSION['keywords'] = array();
+
+  $kex = explode(" ", $k);
+
+  foreach($kex as $k) {
+    if(!in_array($k, $_SESSION['keywords']))
+      $_SESSION['keywords'][] = $k;
+  }
+  
+  foreach($_SESSION['keywords'] as $key => $keyw) {
+    if(trim($keyw) == trim($remove))
+      unset($_SESSION['keywords'][$key]);
+  }
+
+  $_SESSION['keywords'] = array_unique($_SESSION['keywords']);
+  $_SESSION['keywords'] = array_filter($_SESSION['keywords']);
+}
+
+
+function pages($numImages)
+{
+  global $page;
+
+  if(BIN) return;
+  if($numImages < NUM_PP) return;
+
+  $num = $numImages / NUM_PP;
+  echo $page > 0 ? '<a href="?page='.($page-1).'" title="next page">&larr;</a>&nbsp;' : '&larr;&nbsp;';
+  $c = 0;
+  for($i = 0; $i < $num; $i++) {
+    if($page == $i) echo $i;
+    else echo '<a href="?page='.$i.'">'.$i.'</a>';
+    echo " ";
+    $c++;
+  }
+  echo $page < $c++-1 ? '<a href="?page='.($page+1).'" title="prev page">&rarr;</a>' : '&rarr;';
+  echo '<br/><br/>';
+
+  /*
+  echo 'pp: ';
+  $n = array(1, 5, 10, 20, 50);
+  foreach($n as $nn) {
+    if($nn == $num_pp) {
+      echo $num_pp.' ';
+      continue;
+    }
+    echo '<a href="?num_pp='.$nn.'">'.$nn.'</a> ';
+  }
+  */
+  
+}
+
+
+function agg($agg)
+{    
+  if(LINK) {
+    echo '<p>';
+    echo '<img title="'.LINK.'" src="'.ROOT.LINK.'">';
+    echo '</p>';
+    return;
+  }
+
+  $off = BIN ? 0 : OFFSET;
+  $num = BIN ? sizeof($agg) : NUM_PP;
+
+  for($i = $off; $i < $off + $num; $i++) {
+    echo '<p>';
+    if($i > sizeof($agg)-1) break;
+    $file = $agg[$i];
+    if($file['type'] == 'Folder') {      
+      echo '<div class="bin"><a href="?bin='.$file['name'].'">'.$file['name'].'</a></div>';
+      continue;
+    }
+    else {
+      echo '<a href="?l='.BIN.$file['name'].'">';
+      echo '<img border="0" title="'.$file['name'].'" src="'.$file['url'].'">';
+      echo '</a>';
+    }
+    echo '<p>';
+  }
+}
+
+
+
+function what() {
+if($_GET['what'] == 'what') {
+
+  echo '<br/><br/><br/><br/>';
+
+  $what = <<<END
+
+
+<strong>aggregate   \AG-rih-gut\   noun</strong><br/>
+    1 : a mass or body of units or parts somewhat loosely associated with one another
+
+       <br/><br/><br/>
+    visual aggregate:
+       <br/>
+    found images, reference, and inspiration
+
+<br/><br/><br/>
+       contact  <a href="mailto:gdunne@quilime.com">me</a> if an image on here is yours and you
+       are not credited.
+<br/><br/><br/>
+
+<a href="http://quilime.com/aggregate/">&larr;</a>
+
+
+END;
+
+
+  echo $what;
+
+  echo '</body>';
+  echo '</html>';
+
+  exit;
+}
+
+}
+
+
+
+
+
+?>
+
+<html>
+
+<head>
+
+<link rel="alternate" type="application/rss+xml" title="aggregate" href="?return=rss" />
+
+<title>aggregate</title>
+
+<style>
+
+body {
+  font-family:monospace;
+ margin:20px;
+}
+
+input {
+}
+
+#agg {
+ margin:100px 0;
+}
+
+#agg p {
+  margin-bottom:120px;
+}
+
+.bin a {
+ font-size:34px;
+}
+
+.bin {
+  margin-bottom:100px;
+}
+
+.pages {
+  margin-bottom:40px;
+  line-height:2em;
+}
+.pages a {
+ padding:2px;
+}
+
+#what, #s {
+ position:absolute;
+ right:20px;
+ top:20px;
+}
+
+#s {
+ top:45px;
+ text-align:right;
+}
+#s form {
+ margin-bottom:5px;
+}
+
+pre {
+ margin:0;
+ padding:0;
+}
+
+</style>
+</head>
+
+<body>
+
+
+<a href="?">aggregate</a><?=aggTitle();?>
+
+<? what(); ?>
+<? // search(); ?>
+
+<a id="what" title="about" href="?what=what">(?)</a>
+
+<br/><br/>
+
+<div id="agg">
+
+<? 
+agg($agg); 
+?>
+
+</div>
+
+<div class="pages">
+<? pages(sizeof($agg)); ?>
+<!--<a href="http://quilime.com">&larr;&nbsp;home</a>-->
+
+</div>
+
+<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+</script>
+<script type="text/javascript">
+_uacct = "UA-351774-1";
+urchinTracker();
+
+</script>
+
+</body>
+
+</html>
diff --git a/index.php b/index.php
new file mode 100644 (file)
index 0000000..7182cc5
--- /dev/null
+++ b/index.php
@@ -0,0 +1,504 @@
+<?
+
+include('i/php/function.php');
+
+session_start();
+
+define('ROOT', 'agg/');
+define('DESC', 'desc/');
+define('THUMB_DIR', '/home/quilime/media.quilime.com/aggregate/thumbs/');
+define('SRC_DIR',   '/home/quilime/media.quilime.com/aggregate/agg/');
+define('WWW', 'http://media.quilime.com/aggregate/' . ROOT);
+define('PW', 'aggaggagg');
+
+$page   = isset($_GET['page']) ? $_GET['page'] : 0 ;
+$bin    = isset($_GET['bin']) ? $_GET['bin'].'/' : '';
+$link   = isset($_GET['l']) ? $_GET['l'] : '';
+$return = isset($_GET['return']) ? $_GET['return'] : false;
+$admin  = isset($_GET['login']) && $_GET['login'] == PW ? true : false;
+$sub    = isset($_GET['sub']) ? true : false;
+$num_pp = $_SESSION['num_pp']  = setSessionVar('num_pp', 50);
+
+$gen_thumb = isset($_GET['gen_thumb']) ? $_GET['gen_thumb'] : false;
+$img = isset($_GET['img']) ? $_GET['img'] : false;
+
+$offset = $page * $num_pp;
+
+if ($gen_thumb && $img)
+{
+    generate_thumb( SRC_DIR . $img, THUMB_DIR . $img );
+    echo 'thumb generated for ';
+    echo '<a href="http://media.quilime.com/aggregate/thumbs/'.$img.'">'.$img.'</a>';
+    exit;
+}
+
+if($link && is_dir(ROOT . $link))
+       header('Location: ?bin=' . $link);
+
+if($bin)
+       clearkeywords();
+
+if(!$link) {
+       $agg = fileArray(ROOT . $bin, array(), array('.','..'), WWW . $bin);
+       $agg = sortFiles($agg, 'D', 'M');
+       getkeywords();
+       $agg = filterkeywords($agg);
+}
+
+switch ($return) {
+       case 'rss' : rss(); exit();
+       case 'js'  : js();  exit();
+}
+
+
+function generate_thumb($src_img, $thumb_img)
+{
+    $img = $src_img;
+    if ($img && is_file( $img ))
+    {
+        $thumb_dims = array(140, 140);
+        
+        $thumb = $thumb_img;
+        $thumb_src = $img;
+        
+        // resize centered on white
+        $exec = "/usr/bin/convert $thumb_src -resize $thumb_dims[0]x$thumb_dims[1]\> \
+                          -size $thumb_dims[0]x$thumb_dims[1] xc:white +swap -gravity center  -composite \
+                           $thumb";
+
+        exec( $exec, $retval );
+    }
+    return false;
+}
+
+
+function rss()
+{
+       $count = 20;
+
+       global $agg;
+       header("Content-Type: application/xml;");
+       header("Pragma: no-cache");
+       header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
+       echo '<?xml version="1.0" encoding="UTF-8"?>
+                       <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
+                       <channel>
+                       <title>aggregate</title>
+                       <link>http://quilime.com/aggregate/</link>
+                       <generator>media.quilime.com</generator>
+                       <description>aggregate</description>
+       ';
+
+       foreach($agg as $i) {
+       $count--;
+               if($count == 0) break;
+       echo '
+                       <item>
+                       <img>' . $i['url'] . '</img>
+                       <thumb>http://media.quilime.com/aggregate/thumbs/' .$i['name']. '</thumb>
+                       <reference>[reference url]</reference>
+                       <title>' . $i['name'] . '</title>
+                       <pubDate>' . date("r", $i['mtime']) . '</pubDate>
+                       <description>
+                       &lt;p&gt;&lt;a href="?l=' . $i['name'] . '"&gt;&lt;img src="' . $i['url'] . '" alt="" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;
+                       </description>
+                       <link>http://media.quilime.com/aggregate/?l=' . $i['name'] . '</link>
+                       </item>
+       ';
+       }
+
+       echo '</channel>
+       </rss>
+       ';
+}
+
+
+
+
+
+function filterkeywords($agg)
+{
+       if(sizeof($_SESSION['keywords']) > 0) {
+       $filtered = array();
+       foreach($agg as $f) {
+               foreach($_SESSION['keywords'] as $keyword) {
+                               $pattern = '/'.strtolower($keyword).'/';
+                               preg_match($pattern,strtolower($f['name']), $matches);
+                               if(sizeof($matches) > 0) {
+                               $filtered[] = $f;
+                               }
+               }
+               }
+       $agg = $filtered;
+       }
+       return $agg;
+}
+
+
+
+
+function aggTitle()
+{
+       global $link;
+
+       $keywords = keywords();
+
+       if($link)
+               return ' - '.$link;
+       else if(isset($_GET['s']) && $_GET['s'] != '___')
+               return ' - results for : ' . $keywords .'';
+       else
+               return $bin ? ' - ' . $bin : '';
+}
+
+
+
+function keywords()
+{
+       $r = "";
+    if($_SESSION['keywords']) {
+               foreach($_SESSION['keywords'] as $k) {
+               if(trim($k) == "") continue;
+               $r .= $k . ' ';
+               //echo '<a href="?r='.$k.'">x</a>';
+               //echo '<br/>';
+       }
+  }
+  return $r;
+}
+
+
+function clearkeywords()
+{
+  $_SESSION['keywords'] = array();
+  return;
+}
+
+
+function getkeywords()
+{
+  $k = $_GET['s'];
+  $remove = $_GET['r'];
+
+  if($k == "___") {
+      clearkeywords();
+      return;
+  }
+
+  if(!is_array($_SESSION['keywords']))
+    $_SESSION['keywords'] = array();
+
+  $kex = explode(" ", $k);
+
+  foreach($kex as $k) {
+    if(!in_array($k, $_SESSION['keywords']))
+      $_SESSION['keywords'][] = $k;
+  }
+
+  foreach($_SESSION['keywords'] as $key => $keyw) {
+    if(trim($keyw) == trim($remove))
+      unset($_SESSION['keywords'][$key]);
+  }
+
+  $_SESSION['keywords'] = array_unique($_SESSION['keywords']);
+  $_SESSION['keywords'] = array_filter($_SESSION['keywords']);
+}
+
+
+function pages($numImages)
+{
+  global $page, $num_pp, $bin;
+
+  if($bin) return;
+  if($numImages < $num_pp) return;
+
+  $num = $numImages / $num_pp;
+  echo $page > 0 ? '<a href="?page='.($page-1).'" title="next page">&larr;</a>&nbsp;&nbsp;' : '<span>&larr;&nbsp;&nbsp;</span>';
+  $c = 0;
+  for($i = 0; $i < $num; $i++) {
+    if($page == $i) echo '<span>' . $i . '</span>';
+    else echo '<a href="?page='.$i.'">'.$i.'</a>';
+    echo " ";
+    $c++;
+  }
+  echo $page < $c++-1 ? '<a href="?page='.($page+1).'" title="prev page">&rarr;</a>' : '<span>&rarr;</span>';
+
+  echo '<br/><br/>';
+
+  echo '# PER PAGE: ';
+  $n = array(1, 5, 10, 20, 50);
+  foreach($n as $nn) {
+    if($nn == $num_pp) {
+      echo $num_pp.' ';
+      continue;
+    }
+    echo '<a href="?num_pp='.$nn.'">'.$nn.'</a> ';
+  }
+
+}
+
+
+function agg($agg)
+{
+       global $admin, $link, $bin, $num_pp, $offset;
+
+       if($link) {
+    
+        $descfile = false;
+        if(file_exists(DESC . $link . '.txt')) {
+            $descfile = true;
+        }
+    
+               //echo '<p><img title="' . $link.'" src="' . ROOT . $link . '"></p>';
+
+            if($descfile) {
+                               $img_json = file_get_contents( DESC . $link . '.txt' );
+                               $img_desc = json_decode($img_json, true);
+                echo '<a href="' . $img_desc['link'] . '">';
+            }
+        
+                       echo '<img border="0" title="'.ROOT . $link.'" src="'. ROOT . $link.'">';
+                       
+                       if($descfile) 
+            {
+                               echo '<div class="desc" id="inf">';
+                               $img_json = file_get_contents( DESC . $link . '.txt' );
+                               $img_desc = json_decode($img_json, true);
+                               echo $img_desc['link'] . '</a>';
+                               echo '</div>';
+                       }
+
+               return;
+       }
+
+       $off = $bin ? 0 : $offset;
+       $num = $bin ? sizeof($agg) : $num_pp;
+
+       for($i = $off; $i < $off + $num; $i++) {
+           
+        // thumbs
+        if (is_file( SRC_DIR . $agg[$i]['name'] ) && !is_file( THUMB_DIR . $agg[$i]['name'] ) )
+        {
+            generate_thumb( SRC_DIR . $agg[$i]['name'], THUMB_DIR . $agg[$i]['name']);
+        }
+
+               echo '<div class="aggim">';
+
+               if($i > sizeof($agg)-1) break;
+               $file = $agg[$i];
+
+               if($file['type'] == 'Folder') {
+
+                 echo '<div class="bin"><a href="?bin='.$file['name'].'">'.$file['name'].'</a></div>';
+                 continue;
+
+               }
+               else {
+
+                       if($admin) {
+                       echo '
+                               <form class="ed" name="ed_' . $i . '" id="ed_' . $i . '">
+                                       <input type="hidden" name="img"/ value="' . $bin.$file['name'] . '">
+                                       <label>link</label> <input type="text" name="link" /><br/>
+                                       <label>title</label> <input type="text" name="title"/><br/>
+                                       <label>tags</label> <input type="text" name="tags"/><br/>
+                                       <label>desc</label> <input type="text" name="desc" /><br/>
+                                       <input type="button" value="edit" onClick="sub(\'ed_' . $i . '\');">
+                               </form>
+                               ';
+                       }
+                       
+                       if(file_exists(DESC . $file['name'] . '.txt')) {                        
+                       $img_json = file_get_contents( DESC . $file['name'] . '.txt' );
+                       $img_info = json_decode($img_json, true);               
+            //echo '<a href="' . $img_info['link'] . '">'                      ;
+                       }       
+                       
+                       echo '<img border="0" title="'.$file['name'].'" src="'.$file['url'].'">';
+                       
+                               echo '<div class="desc" id="' . $i . '_inf">';
+                               echo '<a href="?l=' . $file['name'] . '">#</a><br/>';
+
+                               if(file_exists(DESC . $file['name'] . '.txt')) {
+                               echo '<a href="' . $img_info['link'] . '"><br/>';                               
+                               echo $img_info['link'] . '</a><br/>';
+                               echo '' . $img_info['desc'] . '';
+                               
+                               }
+                               echo '</div>';
+
+
+               }
+
+       echo '</div>';
+       }
+}
+
+
+function fopen_recursive($path, $mode, $chmod=0755)
+{
+       $directory = dirname($path);
+       $file = basename($path);
+       if (!is_dir($directory)){
+               if (!mkdir($directory, $chmod, 1)) {
+                       return FALSE;
+               }
+       }
+       return fopen ($path, $mode);
+}
+
+
+// make sure destination folder is chmodable
+function dl_remote_image($remote_image, $local_filename) {
+    $ch = curl_init();
+    curl_setopt ($ch, CURLOPT_URL, $remote_image);
+    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
+    $fileContents = curl_exec($ch);
+    curl_close($ch);
+    $newImg = imagecreatefromstring($fileContents);
+    return imagejpeg($newImg, $local_filename, 100);
+}
+
+
+
+
+function js()
+{
+       header("Content-Type: text/javascript;");
+       header("Pragma: no-cache");
+       header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
+
+       $img = isset($_GET['img']) ? $_GET['img'] : false;
+       
+       if(!file_exists(ROOT . $img)) {
+        $new_image = dl_remote_image($_GET['link'], ROOT . time() .'_'. basename($_GET['link'])  );
+       }
+
+       $json =  '{';
+       foreach($_GET as $k=>$param) {
+               $json .= '"'.$k.'"'.' : '.'"'.$param.'", ';
+       }
+       $json .= '"json":0}';
+
+       if($img) {
+               $file = fopen_recursive(DESC . $img . '.txt',"w");
+               fwrite($file,$json);
+               fclose($file);
+               ?>
+               <?php
+       }
+}
+
+
+?>
+
+<html>
+
+<head>
+
+<link rel="alternate" type="application/rss+xml" title="aggregate" href="?return=rss" />
+
+    <title>aggregate<?=aggTitle();?></title>
+
+       <script>
+
+
+               function $()
+               {
+                       var elements = new Array();
+                       for (var i = 0; i < arguments.length; i++) {
+                               var element = arguments[i];
+                               if (typeof element == 'string') element = document.getElementById(element);
+                               if (arguments.length == 1)              return element;
+                               elements.push(element);
+                       }
+                       return elements;
+               }
+
+
+               window.onload = function()
+               {
+                       resizeImages();
+               }
+
+
+               function resizeImages()
+               {
+                       for each(var img in document.getElementsByTagName('img')) {
+                               if(img.offsetWidth + 60 > window.innerWidth)
+                                       img.style.width = window.innerWidth - 100 + 'px';
+                       }
+               }
+
+
+               function sub(form)
+               {
+                       var img   = document.forms[form].img.value;
+                       var link  = document.forms[form].link.value;
+                       var tags  = document.forms[form].tags.value;
+                       var title = document.forms[form].title.value;
+                       var desc  = document.forms[form].desc.value;
+                       doURL( '?return=js&tags=' + tags + '&formid=' + form + '&img=' + escape(img) + '&link=' + escape(link) + '&title=' + escape(title) + '&desc=' + escape(desc)  );
+               }
+
+
+               function doURL(url) {
+                   var jsel = document.createElement('script');
+                   jsel.type = 'text/javascript';
+                   jsel.src = url;
+                   document.body.appendChild (jsel);
+               }
+
+
+
+       </script>
+       
+       <link rel="stylesheet" href="style.css" type="text/css">
+
+</head>
+
+
+<body>
+
+       <a href="?s=___">aggregate</a><?=aggTitle();?><br/>
+
+    <?
+    if($sub) {
+        ?>
+        <br/><br/>
+        <strong>post new image</strong><br/><br/>
+        <form class="submit" name="submit" id="submit">
+            <input type="hidden" name="img" value="null"/><br/>
+            <label>link</label> <input type="text" name="link" /><br/>
+            <label>title</label> <input type="text" name="title"/><br/>
+            <label>tags</label> <input type="text" name="tags"/><br/>
+            <label>desc</label> <input type="text" name="desc" /><br/>
+            <input type="button" value="edit" onClick="sub('submit');">
+        </form>
+        <?php
+        exit;
+    }
+    ?>
+
+       <div id="s">
+               <form method="get" action="<?=$_SERVER['PHP_SELF'];?>?t=sdf">
+               <input type="text" value="" name="s" style="width:100px;" />
+               </form>
+       </div>
+
+       <br/><br/>
+
+       <div id="agg">
+       <? agg($agg); ?>
+       </div>
+
+       <div class="pages">
+       <? pages(sizeof($agg)); ?>
+       </div>
+    
+       <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">_uacct = "UA-351774-1";urchinTracker();</script>
+
+</body>
+
+</html>
diff --git a/index_old.php b/index_old.php
new file mode 100644 (file)
index 0000000..0069ecd
--- /dev/null
@@ -0,0 +1,402 @@
+<?
+include('/home/quilime/i/php/function.php');
+session_start();
+
+$page   = isset($_GET['page']) ? $_GET['page'] : 0 ;
+$bin    = isset($_GET['bin']) ? $_GET['bin'].'/' : '';
+$link   = isset($_GET['l']) ? $_GET['l'] : '';
+$num_pp = $_SESSION['num_pp']  = setSessionVar('num_pp', 50);
+$return = isset($_GET['return']) ? $_GET['return'] : false;
+
+define('LINK', $link);
+define('ROOT', 'agg/');
+define('WWW', 'http://quilime.com/aggregate/'.ROOT);
+define('NUM_PP', $num_pp);
+define('OFFSET', $page * NUM_PP);
+define('BIN', $bin);
+
+if(LINK && is_dir(ROOT.LINK)) {
+  header('Location: ?bin='.LINK);
+}
+
+if(BIN) {
+  clearKeywords();
+}
+
+if(!LINK) {
+  $agg = fileArray(ROOT.BIN, array(), array('.','..'), WWW.BIN);
+  $agg = sortFiles($agg, 'D', 'M');
+  getKeywords();
+  $agg = filterKeywords($agg); 
+}
+
+switch ($return) 
+{
+ case 'rss' :
+   rss();
+   exit();
+}
+
+function rss() 
+{
+  global $agg;
+
+  header("Content-Type: application/xml;");
+  header("Pragma: no-cache");  
+  header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");  
+  
+  echo '<?xml version="1.0" encoding="UTF-8"?>
+    <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
+    <channel>
+    <title>aggregate</title>
+    <link>http://quilime.com/aggregate/</link>
+    <generator>media.quilime.com</generator>
+    <description>aggregate</description>
+';
+
+
+$count = 20;
+
+foreach($agg as $i)
+{    
+    $count--;
+    if($count == 0) break;
+    echo '
+        <item>
+        <img>'.$i['url'].'</img>
+        <reference>[reference url]</reference>
+        <title>'.$i['name'].'</title>
+        <description>
+        &lt;p&gt;&lt;a href="?l='.$i['name'].'"&gt;&lt;img src="'.$i['url'].'" alt="" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;
+        </description>
+        <link>http://quilime.com/aggregate/?l='.$i['name'].'</link>
+        </item>
+    ';
+}
+
+echo '</channel>
+    </rss>
+';
+}
+
+
+
+
+
+function filterKeywords($agg) {
+  // filter keywords
+  if(sizeof($_SESSION['keywords']) > 0) {
+    $filtered = array();
+    foreach($agg as $f) {
+      foreach($_SESSION['keywords'] as $keyword) {
+       $pattern = '/'.strtolower($keyword).'/';    
+       preg_match($pattern,strtolower($f['name']), $matches);  
+       if(sizeof($matches) > 0) {
+         $filtered[] = $f;
+       }
+      }
+    }
+    $agg = $filtered;
+  }
+  return $agg;
+}
+
+
+
+function search()
+{
+?>
+
+<div id="s">
+<form method="get" action="<?=$_SERVER['PHP_SELF'];?>?t=sdf">
+<input type="text" value="" name="s" style="width:100px;" />
+</form>
+
+<ul style="margin:0;padding:0;">
+<? keywords(); ?>
+</ul>
+
+</div>
+
+<?
+}
+
+
+function aggTitle()
+{
+  global $link;
+  if($link)
+    return '/'.$link;
+  else
+    return BIN ? '/'.BIN:'';
+}
+
+
+
+function keywords()
+{
+    if($_SESSION['keywords']) {
+  foreach($_SESSION['keywords'] as $k) {
+    if(trim($k) == "") continue;
+    echo $k . ' ';
+    echo '<a href="?r='.$k.'">x</a>';
+    echo '<br/>';
+  }
+  }
+}
+
+function clearKeywords()
+{  
+  $_SESSION['keywords'] = array();
+  return;
+}
+
+function getKeyWords()
+{
+  $k = $_GET['s'];
+  $remove = $_GET['r'];
+
+  if($k == "___") {
+      clearKeywords();
+      return;
+  }
+
+  if(!is_array($_SESSION['keywords']))
+    $_SESSION['keywords'] = array();
+
+  $kex = explode(" ", $k);
+
+  foreach($kex as $k) {
+    if(!in_array($k, $_SESSION['keywords']))
+      $_SESSION['keywords'][] = $k;
+  }
+  
+  foreach($_SESSION['keywords'] as $key => $keyw) {
+    if(trim($keyw) == trim($remove))
+      unset($_SESSION['keywords'][$key]);
+  }
+
+  $_SESSION['keywords'] = array_unique($_SESSION['keywords']);
+  $_SESSION['keywords'] = array_filter($_SESSION['keywords']);
+}
+
+
+function pages($numImages)
+{
+  global $page;
+
+  if(BIN) return;
+  if($numImages < NUM_PP) return;
+
+  $num = $numImages / NUM_PP;
+  echo $page > 0 ? '<a href="?page='.($page-1).'" title="next page">&larr;</a>&nbsp;' : '&larr;&nbsp;';
+  $c = 0;
+  for($i = 0; $i < $num; $i++) {
+    if($page == $i) echo $i;
+    else echo '<a href="?page='.$i.'">'.$i.'</a>';
+    echo " ";
+    $c++;
+  }
+  echo $page < $c++-1 ? '<a href="?page='.($page+1).'" title="prev page">&rarr;</a>' : '&rarr;';
+  echo '<br/><br/>';
+
+  /*
+  echo 'pp: ';
+  $n = array(1, 5, 10, 20, 50);
+  foreach($n as $nn) {
+    if($nn == $num_pp) {
+      echo $num_pp.' ';
+      continue;
+    }
+    echo '<a href="?num_pp='.$nn.'">'.$nn.'</a> ';
+  }
+  */
+}
+
+
+function agg($agg)
+{    
+  if(LINK) {
+    echo '<p>';
+    echo '<img title="'.LINK.'" src="'.ROOT.LINK.'">';
+    echo '</p>';
+    return;
+  }
+
+  $off = BIN ? 0 : OFFSET;
+  $num = BIN ? sizeof($agg) : NUM_PP;
+
+  for($i = $off; $i < $off + $num; $i++) {
+    echo '<p>';
+    if($i > sizeof($agg)-1) break;
+    $file = $agg[$i];
+    if($file['type'] == 'Folder') {      
+      echo '<div class="bin"><a href="?bin='.$file['name'].'">'.$file['name'].'</a></div>';
+      continue;
+    }
+    else {
+      echo '<a href="?l='.BIN.$file['name'].'">';
+      echo '<img border="0" title="'.$file['name'].'" src="'.$file['url'].'">';
+      echo '</a>';
+    }
+    echo '<p>';
+  }
+}
+
+
+
+function what() {
+if($_GET['what'] == 'what') {
+
+  echo '<br/><br/><br/><br/>';
+
+  $what = <<<END
+
+
+<strong>aggregate   \AG-rih-gut\   noun</strong><br/>
+    1 : a mass or body of units or parts somewhat loosely associated with one another
+
+       <br/><br/><br/>
+    visual aggregate:
+       <br/>
+    found images, reference, and inspiration
+       <br/><br/><br/>
+
+
+words: <br>
+  
+  images, screenshots, photos, IM, 
+events, thoughts, collections, chaos, searches, 
+grotesque, excess, inspiring, stimulating, messy, art, 
+sculpture, device, map, unattanded, disorganized, unpolished,
+soulful, conscious, pile, rhythm, motion, journaling, diary, repetition, connective, texture, political, conversational, 
+dialogue, community, reference, historical, past, growth, humor, color
+
+<br/><br/><br/>
+       contact: <a href="mailto:gdunne@quilime.com">gdunne@quilime.com</a>
+<br/><br/><br/>
+
+&larr;&nbsp;<a href="http://quilime.com/aggregate/">back</a>
+
+<br/><br/><br/>
+
+<a href="http://quilime.com">quilime</a><br/>
+
+
+END;
+
+
+  echo $what;
+
+  echo '</body>';
+  echo '</html>';
+
+  exit;
+}
+
+}
+
+
+
+
+
+?>
+
+<html>
+
+<head>
+
+<link rel="alternate" type="application/rss+xml" title="aggregate" href="?return=rss" />
+
+<title>aggregate</title>
+
+<style>
+
+body {
+  font-family:monospace;
+ margin:20px;
+}
+
+input {
+}
+
+#agg {
+ margin:100px 0;
+}
+
+#agg p {
+  margin-bottom:120px;
+}
+
+.bin a {
+ font-size:34px;
+}
+
+.bin {
+  margin-bottom:100px;
+}
+
+.pages {
+  margin-bottom:40px;
+  line-height:2em;
+}
+.pages a {
+ padding:2px;
+}
+
+#what, #s {
+ position:absolute;
+ right:20px;
+ top:20px;
+}
+
+#s {
+ top:45px;
+ text-align:right;
+}
+#s form {
+ margin-bottom:5px;
+}
+
+pre {
+ margin:0;
+ padding:0;
+}
+
+</style>
+</head>
+
+<body>
+
+
+<a href="?s=___">aggregate</a><?=aggTitle();?>
+
+<? what(); ?>
+<? search(); ?>
+
+<a id="what" title="about" href="?what=what">(?)</a>
+
+<br/><br/>
+
+<div id="agg">
+<? agg($agg); ?>
+</div>
+
+<div class="pages">
+<? pages(sizeof($agg)); ?>
+<!--<a href="http://quilime.com">&larr;&nbsp;home</a>-->
+
+</div>
+
+<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+</script>
+<script type="text/javascript">
+_uacct = "UA-351774-1";
+urchinTracker();
+
+</script>
+
+</body>
+
+</html>
diff --git a/post.php b/post.php
new file mode 100644 (file)
index 0000000..e4200c8
--- /dev/null
+++ b/post.php
@@ -0,0 +1,16 @@
+<?php
+
+       include_once 'class.get.image.php';
+
+       $image = new GetImage;
+       
+       if (isset($_GET['i']))
+       {
+               $image->source = $_GET['i'];
+               $image->save_to = '../agg/';
+               $get = $image->download('curl');                
+               if($get)
+                       echo "The image $_GET['i'] has been saved.";    
+       }
+
+?>
\ No newline at end of file
diff --git a/post/class.get.image.php b/post/class.get.image.php
new file mode 100755 (executable)
index 0000000..cb282c4
--- /dev/null
@@ -0,0 +1,129 @@
+<?php\r
+/*\r
+-------------------------------------------------------------------------\r
+Credits: Bit Repository\r
+URL: http://www.bitrepository.com/web-programming/php/download-image.html\r
+-------------------------------------------------------------------------\r
+*/\r
+class GetImage {\r
+\r
+var $source;\r
+var $save_to;\r
+var $set_extension;\r
+var $quality;\r
+\r
+function download($method = 'curl') // default method: cURL\r
+{\r
+$info = @GetImageSize($this->source);\r
+$mime = $info['mime'];\r
+\r
+if(!$mime) exit('Could not obtain mime-type information. Make sure that the remote file is actually a valid image.');\r
+\r
+// What sort of image?\r
+$type = substr(strrchr($mime, '/'), 1);\r
+\r
+switch ($type) \r
+{\r
+case 'jpeg':\r
+    $image_create_func = 'ImageCreateFromJPEG';\r
+    $image_save_func = 'ImageJPEG';\r
+       $new_image_ext = 'jpg';\r
+       \r
+       // Best Quality: 100\r
+       $quality = isSet($this->quality) ? $this->quality : 100; \r
+    break;\r
+\r
+case 'png':\r
+    $image_create_func = 'ImageCreateFromPNG';\r
+    $image_save_func = 'ImagePNG';\r
+       $new_image_ext = 'png';\r
+       \r
+       // Compression Level: from 0  (no compression) to 9\r
+       $quality = isSet($this->quality) ? $this->quality : 0;\r
+    break;\r
+\r
+case 'bmp':\r
+    $image_create_func = 'ImageCreateFromBMP';\r
+    $image_save_func = 'ImageBMP';\r
+       $new_image_ext = 'bmp';\r
+    break;\r
+\r
+case 'gif':\r
+    $image_create_func = 'ImageCreateFromGIF';\r
+    $image_save_func = 'ImageGIF';\r
+       $new_image_ext = 'gif';\r
+    break;\r
+\r
+case 'vnd.wap.wbmp':\r
+    $image_create_func = 'ImageCreateFromWBMP';\r
+    $image_save_func = 'ImageWBMP';\r
+       $new_image_ext = 'bmp';\r
+    break;\r
+\r
+case 'xbm':\r
+    $image_create_func = 'ImageCreateFromXBM';\r
+    $image_save_func = 'ImageXBM';\r
+       $new_image_ext = 'xbm';\r
+    break;\r
+\r
+default: \r
+       $image_create_func = 'ImageCreateFromJPEG';\r
+    $image_save_func = 'ImageJPEG';\r
+       $new_image_ext = 'jpg';\r
+}\r
+\r
+if(isSet($this->set_extension))\r
+{\r
+$ext = strrchr($this->source, ".");\r
+$strlen = strlen($ext);\r
+$new_name = basename(substr($this->source, 0, -$strlen)).'.'.$new_image_ext;\r
+}\r
+else\r
+{\r
+$new_name = basename($this->source);\r
+}\r
+\r
+$save_to = $this->save_to.$new_name;\r
+\r
+    if($method == 'curl')\r
+       {\r
+    $save_image = $this->LoadImageCURL($save_to);\r
+       }\r
+       elseif($method == 'gd')\r
+       {\r
+       $img = $image_create_func($this->source);\r
+\r
+           if(isSet($quality))\r
+           {\r
+                  $save_image = $image_save_func($img, $save_to, $quality);\r
+               }\r
+               else\r
+               {\r
+                  $save_image = $image_save_func($img, $save_to);\r
+               }\r
+       }\r
+       \r
+       return $save_image;\r
+}\r
+\r
+function LoadImageCURL($save_to)\r
+{\r
+$ch = curl_init($this->source);\r
+$fp = fopen($save_to, "wb");\r
+\r
+// set URL and other appropriate options\r
+$options = array(CURLOPT_FILE => $fp,\r
+                 CURLOPT_HEADER => 0,\r
+                 CURLOPT_FOLLOWLOCATION => 1,\r
+                    CURLOPT_TIMEOUT => 60); // 1 minute timeout (should be enough)\r
+\r
+curl_setopt_array($ch, $options);\r
+\r
+$save = curl_exec($ch);\r
+curl_close($ch);\r
+fclose($fp);\r
+\r
+return $save;\r
+}\r
+}\r
+?>
\ No newline at end of file
diff --git a/post/demo.php b/post/demo.php
new file mode 100644 (file)
index 0000000..d00aa49
--- /dev/null
@@ -0,0 +1,17 @@
+<?php\r
+\r
+       include_once 'class.get.image.php';\r
+\r
+       // initialize the class\r
+       $image = new GetImage;\r
+\r
+       // just an image URL\r
+       $image->source = 'http://static.php.net/www.php.net/images/php_snow_2008.gif';\r
+       $image->save_to = 'images/';\r
+\r
+       $get = $image->download('curl');\r
+\r
+       if($get) {\r
+               echo 'The image has been saved.';\r
+       }\r
+?>
\ No newline at end of file
diff --git a/post/index.php b/post/index.php
new file mode 100644 (file)
index 0000000..ef0d55f
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+       include_once 'class.get.image.php';
+
+       $image = new GetImage;
+
+       if (isset($_GET['i']))
+       {
+               $image->source = $_GET['i'];
+               $image->save_to = '../agg/';
+               $get = $image->download('curl');
+               $i = basename($image->source);
+               if($get) {
+
+                       ?>
+
+
+                       <img src="../agg/<? echo $i ?>" /> <br/>
+                       <a href="http://media.quilime.com/aggregate/?l=<? echo $i ?>"><? echo $i ?></a><br/>
+
+                       <form class="ed" name="ed_<? echo $i ?>" id="ed_<? echo $i ?>">
+                               <input type="hidden" name="img" value="<? echo $i ?>">
+                               <label>link</label><input type="text" name="link" /><br/>
+                               <label>title</label><input type="text" name="title"/><br/>
+                               <label>tags</label><input type="text" name="tags"/><br/>
+                               <label>desc</label><input type="text" name="desc" /><br/>
+                               <input type="button" value="post" onClick="sub();">
+                       </form>
+
+                       <a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
+
+                       <script>
+
+                               function sub()
+                               {
+                                       var img   = document.forms[0].img.value;
+                                       var link  = document.forms[0].link.value;
+                                       var tags  = document.forms[0].tags.value;
+                                       var title = document.forms[0].title.value;
+                                       var desc  = document.forms[0].desc.value;
+                                       doURL( '../index.php?return=js&tags=' + tags + '&img=' + escape(img) + '&link=' + escape(link) + '&title=' + escape(title) + '&desc=' + escape(desc)  );
+                               }
+
+
+                               function doURL(url) {
+                                   var jsel = document.createElement('script');
+                                   jsel.type = 'text/javascript';
+                                   jsel.src = url;
+                                   document.body.appendChild (jsel);
+                               }
+
+                       </script>
+
+                       <?
+
+                       exit;
+               }
+       }
+
diff --git a/style.css b/style.css
new file mode 100644 (file)
index 0000000..414be54
--- /dev/null
+++ b/style.css
@@ -0,0 +1,28 @@
+
+
+        body { font-family:monospace; margin:20px; margin-left:30px; font-size:12px; color:#999; }
+        
+        #agg div.aggim a { color:#fff; text-decoration:none; font-size:10px; padding-top:10px;}
+        #agg div.aggim:hover a { color:#444; } 
+        #agg div.aggim:hover a:hover { text-decoration:underline; color:#000; } 
+
+        #agg { margin:0; }
+        #agg .aggim { margin-bottom:120px;}
+
+               a {color:#555; text-decoration:underline; }
+               a:hover {color:#000; text-decoration:none;}
+
+        .bin a { font-size:34px; }
+        .bin { margin-bottom:100px; }
+        .pages { margin-bottom:40px; line-height:2em; }
+        .pages a, pages span { padding:2px 6px;}
+        .pages a:hover {  }
+
+        #s { display:none; position:absolute; right:20px; top:20px; }
+        #s form { }
+
+        pre { margin:0; padding:0; }
+
+        .desc { }
+
+       .ed input[type='text']{ width:400px; }
\ No newline at end of file
diff --git a/thumbs.php b/thumbs.php
new file mode 100644 (file)
index 0000000..51494e8
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+    $img = isset($_GET['img']) ? $_GET['img'] : false;
+
+    define('THUMB_DIR', '/home/quilime/media.quilime.com/aggregate/thumbs/');
+    define('SRC_DIR',   '/home/quilime/media.quilime.com/aggregate/agg/');
+    
+    $res = "";
+    
+    if ($img && is_file( SRC_DIR . $img ))
+    {
+        $res .= "generating thumb for " . $img . "\n";
+        
+        $thumb_dims = array(160, 160);
+        
+        $thumb = THUMB_DIR . $img;
+        $thumb_src = SRC_DIR . $img;
+        
+        // resize centered on white
+        $exec = "/usr/bin/convert $thumb_src -resize $thumb_dims[0]x$thumb_dims[1]\> \
+                          -size $thumb_dims[0]x$thumb_dims[1] xc:transparent +swap -gravity center  -composite \
+                           $thumb";
+
+        exec( $exec, $retval );
+        
+        $res .= "done! thumb for " . $img . " created\n";        
+        
+    }
+
+?>
+
+<html>
+
+
+<head>
+    <style>
+        textarea { width: 100%; height:200px; }
+    </style>
+</head>
+
+<body>
+    
+    <h1>thumbs</h1>
+    <textarea><?php echo $res; ?></textarea>
+<body>
+
+</html>
\ No newline at end of file
diff --git a/v/index_01.php b/v/index_01.php
new file mode 100644 (file)
index 0000000..f0adc0a
--- /dev/null
@@ -0,0 +1,236 @@
+<?
+include('/home/quilime/i/php/function.php');
+session_start();
+
+$page   = isset($_GET['page']) ? $_GET['page'] : 0 ;
+$bin    = isset($_GET['bin']) ? $_GET['bin'].'/' : '';
+
+getKeywords();
+
+define('ROOT', 'agg/');
+define('NUM_PP', 20);
+define('OFFSET', $page * NUM_PP);
+define('BIN', $bin);
+
+$agg = fileArray(ROOT.BIN, array(), array('.','..'),'http://media.quilime.com/aggregate/agg/'.BIN);
+$agg = sortFiles($agg, 'D', 'M');
+
+?>
+
+<html>
+
+<head>
+
+<title>aggregate</title>
+
+<style>
+
+body {
+  font-family:monospace;
+ margin:20px;
+}
+
+#agg {
+ margin:40px 0;
+}
+
+#agg p {
+  margin-bottom:120px;
+}
+
+.bin a {
+ font-size:34px;
+}
+
+.bin {
+  margin-bottom:100px;
+}
+
+.pages {
+  margin-bottom:40px;
+}
+.pages a {
+ padding:2px;
+}
+
+#what, #s {
+ position:absolute;
+ right:20px;
+ top:20px;
+}
+
+#s {
+ top:45px;
+}
+
+#s input {
+ color:#999;
+}
+
+pre {
+ margin:0;
+ padding:0;
+}
+
+</style>
+</head>
+<body>
+
+
+<a href="?=">aggregate</a><?=BIN?'/'.BIN:''?>
+<? what(); ?>
+<? /*
+<div id="s">
+<form method="get" action="<?=$_SERVER['PHP_SELF'];?>?t=sdf">
+<input type="text" value="" name="s" style="width:100px;" />
+</form>
+
+<ul style="margin:0;padding:0;">
+<? keywords(); ?>
+</ul>
+   */ ?>
+</div>
+
+<a id="what" href="?what=what">what?</a>
+
+
+<br/><br/>
+
+<div class="pages">
+<? pages(sizeof($agg)); ?>
+</div>
+
+<br/><br/>
+
+<div id="agg">
+<? agg($agg); ?>
+</div>
+
+<div class="pages">
+<? pages(sizeof($agg)); ?>
+</div>
+
+</body>
+
+</html>
+
+<?
+
+function keywords()
+{
+  foreach($_SESSION['keywords'] as $k) {
+    if(trim($k) == "") continue;
+    echo $k . ' ';
+    echo '<a href="?r='.$k.'">x</a>';
+    echo '<br/>';
+  }
+}
+
+function getKeyWords()
+{
+  $k = $_GET['s'];
+  $remove = $_GET['r'];
+
+  echo $k;
+
+  if(!is_array($_SESSION['keywords']))
+    $_SESSION['keywords'] = array();
+
+
+  if(!in_array($k, $_SESSION['keywords']))
+     $_SESSION['keywords'][] = $k;
+
+  if(in_array($remove, $_SESSION['keywords'])) {
+    
+    echo $remove;
+
+  }
+
+  $_SESSION['keywords'] = array_unique($_SESSION['keywords']);
+
+  //  print_pre($_SESSION['keywords']);
+    
+
+}
+
+
+# PAGINATION
+function pages($numImages)
+{
+  global $page;
+  if(BIN) return;
+  $num = $numImages / NUM_PP;
+  echo $page > 0 ? '<a href="?page='.($page-1).'" title="next page">&larr;</a>&nbsp;' : '&larr;&nbsp;';
+  $c = 0;
+  for($i = 0; $i < $num; $i++) {
+
+    if($page == $i) 
+      echo $i;
+    else
+      echo '<a href="?page='.$i.'">'.$i.'</a>';
+
+    echo "&nbsp;";
+    $c++;
+  }
+  echo $page < $c++-1 ? '&nbsp;<a href="?page='.($page+1).'" title="prev page">&rarr;</a>' : '&nbsp;&rarr;';
+}
+
+
+# LIST
+function agg($agg)
+{
+  $off = BIN ? 0 : OFFSET;
+  $num = BIN ? sizeof($agg) : NUM_PP;
+
+  for($i = $off; $i < $off + $num; $i++) {
+    echo '<p>';
+
+    if($i > sizeof($agg)-1) break;
+
+    $file = $agg[$i];
+
+    if($file['type'] == 'Folder') {
+      echo '<div class="bin"><a href="?bin='.$file['name'].'">'.$file['name'].'</a></div>';
+      continue;
+    }
+    else {
+       echo '<img title="'.$file['name'].'" src="'.$file['url'].'">';
+    }
+    
+    echo '<p>';
+  }
+}
+
+
+
+function what() {
+if($_GET['what'] == 'what') {
+
+  echo '<br/><br/><br/><br/>';
+
+  $what = <<<END
+  
+  stuff i've collected, my own screenshots, 
+my own photos, friends' photos, friends' screenshots, IM conversations, emails, weird stuff, 
+current events, past events, things, thoughts, collections, chaos, searches, 
+grotesque, messy, scary, fun, copyright, 
+illegal, art, sculpture, device, map, media, undefined, null, void, 
+unfocused, unattanded, disorganized, unpolished,
+designless, tasteless, artless, artful, soulless, soulful, conscious, questions, 
+pile, graphic, robotic, cold, human, gorgeous, elegant, warm, beautiful, inspirational, 
+rhythm, motion, tracing, journaling, diary, wonderment, oscillations, repetition, waves, polygons, 
+connections, circles, texture, light,
+radiation, refraction, reflection, radiosity, energy, giving, sharing, collaborating, political,
+conversational, dialogue, community, reference, historical, past, sigularity, evolving, growth, humor, color,  in progress, . . .
+END;
+
+  echo $what;
+
+  exit;
+}
+
+}
+
+
+?>
\ No newline at end of file