Edgar/linktitle

function linktitle($link) { global $linktitle_db; if (isset ($linktitle_db['temp_blacklist'])) { $largest_key = -2; //-2 for: we havent found any key yet $largest_key_size = -1; foreach ($linktitle_db['temp_blacklist'] as $key => $value) { if ($value['url'] == $link && $value['expire'] > (time - 23)) { return "I just told you about that url..."; }                       if ($value['expire'] > time && $largest_key != -1) { unset ($GLOBALS['linktitle_db']['temp_blacklist'][$key]); $largest_key = -1; //-1 for: we dont need to delete any more rows - even if mem just was full } else { $size = time - $value['expire']; if ($size > $largest_key_size) { $largest_key_size = $size; $largest_key = $key; }                       }                }                if (count($linktitle_db['temp_blacklist']) > 100 && $largest_key >= 0) { unset ($GLOBALS['linktitle_db']['temp_blacklist'][$largest_key]); }       }        $linktitle_db['temp_blacklist'][] = array (                'url' => $link,        'expire' => (time + 115)); # Add feature to detect and download image links --mutante 080223 $image_extensions = array (               "jpg",                "gif",                "png",                "jpeg",                "bmp",        );
 * 1) if somebody mentions a http link, return the of the page
 * 2) mutante and finn in screen session, idea by finn
 * 3) advanced features by took

if (in_array(strtolower(substr($link, -3)), $image_extensions)) {

$directory = "public_html/images"; $imagename = explode("/", $link); $imagename = end($imagename);

$output = "Looks like an image. Downloading.. "; $image = `wget -q -P $directory $link`; $file = `file $directory/$imagename`; $size = `ls -hs $directory/$imagename | cut -d " " -f1`; $output .= "Saved to ". trim($file). " size: ". trim($size). ".";

} elseif (stristr($link,"/wiki/")){ # < finn__> edgar k?nnte wiki seiten ignorieren, da der titel ja nach dem letzten / abzulesen ist $output=""; } else {

$buffer = file_get_contents($link); preg_match('@ (.*?) @i', str_replace(array (                       "\n",                        "\r"                ), array (                        "",                        ""                ), $buffer), $pieces); $title = $pieces[1];

if ($title != '') { $output = "Title: '". trim(html_entity_decode($title)). "'";               } else { if ($buffer != '') { $output = "Sorry, 200 but no title"; } else { $output = ""; // "Sorry, empty buffer"; -> (21:19:39) mutante: Edgar23: if empty buffer, just say nothing }               }

}

return $output; }