From ae86720a8937c273b349568f7dd180459aa6033d Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Fri, 10 Feb 2012 13:26:30 -0800 Subject: [PATCH 1/1] added files --- dev.php | 393 ++++++++++++++++++++++++++++++ index.php | 504 +++++++++++++++++++++++++++++++++++++++ index_old.php | 402 +++++++++++++++++++++++++++++++ post.php | 16 ++ post/class.get.image.php | 129 ++++++++++ post/demo.php | 17 ++ post/index.php | 59 +++++ style.css | 28 +++ thumbs.php | 47 ++++ v/index_01.php | 236 ++++++++++++++++++ 10 files changed, 1831 insertions(+) create mode 100644 dev.php create mode 100644 index.php create mode 100644 index_old.php create mode 100644 post.php create mode 100755 post/class.get.image.php create mode 100644 post/demo.php create mode 100644 post/index.php create mode 100644 style.css create mode 100644 thumbs.php create mode 100644 v/index_01.php diff --git a/dev.php b/dev.php new file mode 100644 index 0000000..1c5ecef --- /dev/null +++ b/dev.php @@ -0,0 +1,393 @@ + + + + aggregate + http://quilime.com/aggregate/ + media.quilime.com + aggregate +'; + + +$count = 20; + +foreach($agg as $i) +{ + $count--; + if($count == 0) break; + echo ' + + '.$i['url'].' + [reference url] + '.$i['name'].' + + <p><a href="?l='.$i['name'].'"><img src="'.$i['url'].'" alt="" border="0"></a></p><p> + + http://quilime.com/aggregate/?l='.$i['name'].' + + '; +} + +echo ' + +'; +} + + + + + +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() +{ +?> + +
+
+ +
+ + + +
+ +x'; + echo '
'; + } + } +} + +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 ? ' ' : '← '; + $c = 0; + for($i = 0; $i < $num; $i++) { + if($page == $i) echo $i; + else echo ''.$i.''; + echo " "; + $c++; + } + echo $page < $c++-1 ? '' : '→'; + echo '

'; + + /* + echo 'pp: '; + $n = array(1, 5, 10, 20, 50); + foreach($n as $nn) { + if($nn == $num_pp) { + echo $num_pp.' '; + continue; + } + echo ''.$nn.' '; + } + */ + +} + + +function agg($agg) +{ + if(LINK) { + echo '

'; + echo ''; + echo '

'; + return; + } + + $off = BIN ? 0 : OFFSET; + $num = BIN ? sizeof($agg) : NUM_PP; + + for($i = $off; $i < $off + $num; $i++) { + echo '

'; + if($i > sizeof($agg)-1) break; + $file = $agg[$i]; + if($file['type'] == 'Folder') { + echo '

'.$file['name'].'
'; + continue; + } + else { + echo ''; + echo ''; + echo ''; + } + echo '

'; + } +} + + + +function what() { + +if($_GET['what'] == 'what') { + + echo '



'; + + $what = <<aggregate \AG-rih-gut\ noun
+ 1 : a mass or body of units or parts somewhat loosely associated with one another + +


+ visual aggregate: +
+ found images, reference, and inspiration + +


+ contact me if an image on here is yours and you + are not credited. +


+ + + + +END; + + + echo $what; + + echo ''; + echo ''; + + exit; +} + +} + + + + + +?> + + + + + + + +aggregate + + + + + + + +aggregate + + + + +(?) + +

+ +

+ + + +
+ +
+ + + +
+ + + + + + + diff --git a/index.php b/index.php new file mode 100644 index 0000000..7182cc5 --- /dev/null +++ b/index.php @@ -0,0 +1,504 @@ +'.$img.''; + 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 ' + + + aggregate + http://quilime.com/aggregate/ + media.quilime.com + aggregate + '; + + foreach($agg as $i) { + $count--; + if($count == 0) break; + echo ' + + ' . $i['url'] . ' + http://media.quilime.com/aggregate/thumbs/' .$i['name']. ' + [reference url] + ' . $i['name'] . ' + ' . date("r", $i['mtime']) . ' + + <p><a href="?l=' . $i['name'] . '"><img src="' . $i['url'] . '" alt="" border="0"></a></p><p> + + http://media.quilime.com/aggregate/?l=' . $i['name'] . ' + + '; + } + + echo ' + + '; +} + + + + + +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 'x'; + //echo '
'; + } + } + 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 ? '  ' : '←  '; + $c = 0; + for($i = 0; $i < $num; $i++) { + if($page == $i) echo '' . $i . ''; + else echo ''.$i.''; + echo " "; + $c++; + } + echo $page < $c++-1 ? '' : ''; + + echo '

'; + + echo '# PER PAGE: '; + $n = array(1, 5, 10, 20, 50); + foreach($n as $nn) { + if($nn == $num_pp) { + echo $num_pp.' '; + continue; + } + echo ''.$nn.' '; + } + +} + + +function agg($agg) +{ + global $admin, $link, $bin, $num_pp, $offset; + + if($link) { + + $descfile = false; + if(file_exists(DESC . $link . '.txt')) { + $descfile = true; + } + + //echo '

'; + + if($descfile) { + $img_json = file_get_contents( DESC . $link . '.txt' ); + $img_desc = json_decode($img_json, true); + echo ''; + } + + echo ''; + + if($descfile) + { + echo '
'; + $img_json = file_get_contents( DESC . $link . '.txt' ); + $img_desc = json_decode($img_json, true); + echo $img_desc['link'] . ''; + echo '
'; + } + + 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 '
'; + + if($i > sizeof($agg)-1) break; + $file = $agg[$i]; + + if($file['type'] == 'Folder') { + + echo ''; + continue; + + } + else { + + if($admin) { + echo ' +
+ +
+
+
+
+ +
+ '; + } + + if(file_exists(DESC . $file['name'] . '.txt')) { + $img_json = file_get_contents( DESC . $file['name'] . '.txt' ); + $img_info = json_decode($img_json, true); + //echo '' ; + } + + echo ''; + + echo '
'; + echo '#
'; + + if(file_exists(DESC . $file['name'] . '.txt')) { + echo '
'; + echo $img_info['link'] . '

'; + echo '' . $img_info['desc'] . ''; + + } + echo '
'; + + + } + + echo '
'; + } +} + + +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); + ?> + + + + + + + + + aggregate<?=aggTitle();?> + + + + + + + + + + + aggregate
+ + +

+ post new image

+
+
+
+
+
+
+ +
+ + +
+
+ +
+
+ +

+ +
+ +
+ +
+ +
+ + + + + + diff --git a/index_old.php b/index_old.php new file mode 100644 index 0000000..0069ecd --- /dev/null +++ b/index_old.php @@ -0,0 +1,402 @@ + + + + aggregate + http://quilime.com/aggregate/ + media.quilime.com + aggregate +'; + + +$count = 20; + +foreach($agg as $i) +{ + $count--; + if($count == 0) break; + echo ' + + '.$i['url'].' + [reference url] + '.$i['name'].' + + <p><a href="?l='.$i['name'].'"><img src="'.$i['url'].'" alt="" border="0"></a></p><p> + + http://quilime.com/aggregate/?l='.$i['name'].' + + '; +} + +echo ' + +'; +} + + + + + +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() +{ +?> + +
+
+ +
+ + + +
+ +x'; + echo '
'; + } + } +} + +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 ? ' ' : '← '; + $c = 0; + for($i = 0; $i < $num; $i++) { + if($page == $i) echo $i; + else echo ''.$i.''; + echo " "; + $c++; + } + echo $page < $c++-1 ? '' : '→'; + echo '

'; + + /* + echo 'pp: '; + $n = array(1, 5, 10, 20, 50); + foreach($n as $nn) { + if($nn == $num_pp) { + echo $num_pp.' '; + continue; + } + echo ''.$nn.' '; + } + */ +} + + +function agg($agg) +{ + if(LINK) { + echo '

'; + echo ''; + echo '

'; + return; + } + + $off = BIN ? 0 : OFFSET; + $num = BIN ? sizeof($agg) : NUM_PP; + + for($i = $off; $i < $off + $num; $i++) { + echo '

'; + if($i > sizeof($agg)-1) break; + $file = $agg[$i]; + if($file['type'] == 'Folder') { + echo '

'.$file['name'].'
'; + continue; + } + else { + echo ''; + echo ''; + echo ''; + } + echo '

'; + } +} + + + +function what() { + +if($_GET['what'] == 'what') { + + echo '



'; + + $what = <<aggregate \AG-rih-gut\ noun
+ 1 : a mass or body of units or parts somewhat loosely associated with one another + +


+ visual aggregate: +
+ found images, reference, and inspiration +


+ + +words:
+ + 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 + +


+ contact: gdunne@quilime.com +


+ +← back + +


+ +quilime
+ + +END; + + + echo $what; + + echo ''; + echo ''; + + exit; +} + +} + + + + + +?> + + + + + + + +aggregate + + + + + + + +aggregate + + + + +(?) + +

+ +

+ +
+ +
+ + + +
+ + + + + + + diff --git a/post.php b/post.php new file mode 100644 index 0000000..e4200c8 --- /dev/null +++ b/post.php @@ -0,0 +1,16 @@ +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 index 0000000..cb282c4 --- /dev/null +++ b/post/class.get.image.php @@ -0,0 +1,129 @@ +source); +$mime = $info['mime']; + +if(!$mime) exit('Could not obtain mime-type information. Make sure that the remote file is actually a valid image.'); + +// What sort of image? +$type = substr(strrchr($mime, '/'), 1); + +switch ($type) +{ +case 'jpeg': + $image_create_func = 'ImageCreateFromJPEG'; + $image_save_func = 'ImageJPEG'; + $new_image_ext = 'jpg'; + + // Best Quality: 100 + $quality = isSet($this->quality) ? $this->quality : 100; + break; + +case 'png': + $image_create_func = 'ImageCreateFromPNG'; + $image_save_func = 'ImagePNG'; + $new_image_ext = 'png'; + + // Compression Level: from 0 (no compression) to 9 + $quality = isSet($this->quality) ? $this->quality : 0; + break; + +case 'bmp': + $image_create_func = 'ImageCreateFromBMP'; + $image_save_func = 'ImageBMP'; + $new_image_ext = 'bmp'; + break; + +case 'gif': + $image_create_func = 'ImageCreateFromGIF'; + $image_save_func = 'ImageGIF'; + $new_image_ext = 'gif'; + break; + +case 'vnd.wap.wbmp': + $image_create_func = 'ImageCreateFromWBMP'; + $image_save_func = 'ImageWBMP'; + $new_image_ext = 'bmp'; + break; + +case 'xbm': + $image_create_func = 'ImageCreateFromXBM'; + $image_save_func = 'ImageXBM'; + $new_image_ext = 'xbm'; + break; + +default: + $image_create_func = 'ImageCreateFromJPEG'; + $image_save_func = 'ImageJPEG'; + $new_image_ext = 'jpg'; +} + +if(isSet($this->set_extension)) +{ +$ext = strrchr($this->source, "."); +$strlen = strlen($ext); +$new_name = basename(substr($this->source, 0, -$strlen)).'.'.$new_image_ext; +} +else +{ +$new_name = basename($this->source); +} + +$save_to = $this->save_to.$new_name; + + if($method == 'curl') + { + $save_image = $this->LoadImageCURL($save_to); + } + elseif($method == 'gd') + { + $img = $image_create_func($this->source); + + if(isSet($quality)) + { + $save_image = $image_save_func($img, $save_to, $quality); + } + else + { + $save_image = $image_save_func($img, $save_to); + } + } + + return $save_image; +} + +function LoadImageCURL($save_to) +{ +$ch = curl_init($this->source); +$fp = fopen($save_to, "wb"); + +// set URL and other appropriate options +$options = array(CURLOPT_FILE => $fp, + CURLOPT_HEADER => 0, + CURLOPT_FOLLOWLOCATION => 1, + CURLOPT_TIMEOUT => 60); // 1 minute timeout (should be enough) + +curl_setopt_array($ch, $options); + +$save = curl_exec($ch); +curl_close($ch); +fclose($fp); + +return $save; +} +} +?> \ No newline at end of file diff --git a/post/demo.php b/post/demo.php new file mode 100644 index 0000000..d00aa49 --- /dev/null +++ b/post/demo.php @@ -0,0 +1,17 @@ +source = 'http://static.php.net/www.php.net/images/php_snow_2008.gif'; + $image->save_to = 'images/'; + + $get = $image->download('curl'); + + if($get) { + echo 'The image has been saved.'; + } +?> \ No newline at end of file diff --git a/post/index.php b/post/index.php new file mode 100644 index 0000000..ef0d55f --- /dev/null +++ b/post/index.php @@ -0,0 +1,59 @@ +source = $_GET['i']; + $image->save_to = '../agg/'; + $get = $image->download('curl'); + $i = basename($image->source); + if($get) { + + ?> + + +
+
+ +
+ +
+
+
+
+ +
+ + Tweet + + + + \ + -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"; + + } + +?> + + + + + + + + + + +

thumbs

+ + + + \ No newline at end of file diff --git a/v/index_01.php b/v/index_01.php new file mode 100644 index 0000000..f0adc0a --- /dev/null +++ b/v/index_01.php @@ -0,0 +1,236 @@ + + + + + + +aggregate + + + + + + +aggregate + + +
+ +
+ + + */ ?> + + +what? + + +

+ +
+ +
+ +

+ +
+ +
+ +
+ +
+ + + + + +x'; + echo '
'; + } +} + +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 ? ' ' : '← '; + $c = 0; + for($i = 0; $i < $num; $i++) { + + if($page == $i) + echo $i; + else + echo ''.$i.''; + + echo " "; + $c++; + } + echo $page < $c++-1 ? ' ' : ' →'; +} + + +# LIST +function agg($agg) +{ + $off = BIN ? 0 : OFFSET; + $num = BIN ? sizeof($agg) : NUM_PP; + + for($i = $off; $i < $off + $num; $i++) { + echo '

'; + + if($i > sizeof($agg)-1) break; + + $file = $agg[$i]; + + if($file['type'] == 'Folder') { + echo '

'.$file['name'].'
'; + continue; + } + else { + echo ''; + } + + echo '

'; + } +} + + + +function what() { + +if($_GET['what'] == 'what') { + + echo '



'; + + $what = << \ No newline at end of file -- 2.34.1