get($cache_key)) { list($ext,$pict) = $cached_data; if($pict_data = $memcache->get($pict)) { // image from memory } else { // image not found - purged? list($ext,$pict) = getPict(); $pict_key = md5("{$pict}_pic"); $pict_data = file_get_contents($pict); $memcache->set($pict_key, $pict_data, false, $time); $memcache->set($cache_key,array($ext,$pict_key), false, $time); } } else { // cache key does not exist global $addPhotoPict; list($ext,$pict) = getPict(); $pict_key = md5("{$pict}_pic"); if ($pict_data = $memcache->get($pict_key)) { // image already exists $memcache->set($cache_key,array($ext,$pict_key), false, $time); } else { // download image and store to cache if($pict_data = @file_get_contents($pict)) { // pict found $memcache->set($pict_key, $pict_data, false, $time); $memcache->set($cache_key,array($ext,$pict_key), false, $time); } else { // fail safe if url from amazon is forbidden or crappy url? $pict_key = md5("{$addPhotoPict}_pic"); // does static image exist in memory already? if ($pict_data = $memcache->get($pict_key)) { $memcache->set($cache_key,array($ext,$pict_key), false, $time); } else { $pict_data = file_get_contents($addPhotoPict); $memcache->set($pict_key, $pict_data, false, $time); } $memcache->set($cache_key,array($ext,$pict_key), false, $time); } } } if($ext == '.jpg') { $ctype = 'Content-type: image/jpg'; } else if($ext == '.jpeg') { $ctype = 'Content-type: image/jpeg'; } else if($ext == '.gif') { $ctype = 'Content-type: image/gif'; } else if($ext == '.bmp') { $ctype = 'Content-type: image/bitmap'; } else { exit; } header($ctype); print $pict_data; /* ini_set("mysql.connect_timeout", 1); require("/home/y/share/htdocs/includes/conn_pub_usage_stats.php"); $da = date("YmdHi"); $REFERER = addslashes(yahoo_get_data(YIV_SERVER,'HTTP_REFERER',YIV_FILTER_URL)); @mysql_query("insert into usage_cf values('$sid','$da','1','$REFERER') on duplicate key update count = count + 1"); */ function getPict() { global $cp, $sid, $href, $title, $name, $oo, $commNonePict; $urlArr = @parse_url($href); $titleArr = @parse_url($title); $titleURLs = $hrefURLs = array(); $caseEmail = false; if(strpos($title, "profile.typekey.com/") > 0) { /// TypeKey /// $arr = explode("profile.typekey.com/", $title); $typeKeyID = addslashes(trim($arr[1], " /")); } else if(strpos($href, "blogger.com/profile/") > 0) { /// Blogger ID /// $arr = explode("blogger.com/profile/", $href); $bloggerID = addslashes(trim($arr[1], " /")); } else { if($urlArr['scheme'] == 'mailto') { $email = $urlArr['path']; $caseEmail = true; } else if($urlArr['host'] && strpos($urlArr['scheme'], 'http') === 0) { $caseEmail = false; $hrefURLs = getPossibleURLs($urlArr['host'], $href); $titleURLs = getPossibleURLs($titleArr['host'], $title); } else { $caseNoPic = true; } } require("includes/pub_igor_settings.inc"); ini_set("mysql.connect_timeout", 3); require_once("includes/conn_mbludb_slave.php"); if ($caseNoPic) { return array(".jpg", $addPhotoPict); } elseif($caseEmail) { $email = addslashes($email); $q = mysql_query("select a.pict from com_member a where a.email_address = '$email' limit 1") or die(); } elseif($typeKeyID) { $q = mysql_query("select a.pict from com_member a, com_member_service_merge b where a.member_id = b.member_id and b.typekey = '$typeKeyID' limit 1") or die(); } elseif($bloggerID) { $q = mysql_query("select a.pict from com_member a, com_member_service_merge b where a.member_id = b.member_id and b.blogger_id = '$bloggerID' limit 1") or die(); } else { if($oo == "y" && $sid) { $siteCheck = "and (c.site_id = '$sid')"; // and a.pict <> '' and a.pict is not null } if(count($titleURLs) > 0) { $q = mysql_query("select a.pict,b.is_primary,(select first_name from com_member_option_merge where member_id = a.member_id limit 1) first_name,(select last_name from com_member_option_merge where member_id = a.member_id limit 1) last_name,a.screen_name from com_member a, com_rel_auth_blog b, com_site c where c.site_url in ('".implode("','", $titleURLs)."') $siteCheck and c.site_id = b.site_id and b.author_id = a.member_id") or die(); } else { $q = mysql_query("select a.pict,b.is_primary,(select first_name from com_member_option_merge where member_id = a.member_id limit 1) first_name,(select last_name from com_member_option_merge where member_id = a.member_id limit 1) last_name,a.screen_name from com_member a, com_rel_auth_blog b, com_site c where c.site_url in ('".implode("','", $hrefURLs)."') $siteCheck and c.site_id = b.site_id and b.author_id = a.member_id") or die(); } } $r = $r1 = $r2 = null; $nrs = mysql_num_rows($q); if($nrs > 1) { while($rx = mysql_fetch_row($q)) { if($rx[1] == 'y') { $r1 = $rx; } $rx[4] = trim($rx[4]); if($name && ((strcasecmp(str_replace(" ", "", $name),$rx[4])==0) || (strcasecmp(str_replace(" ", "", $rx[4]),$name)==0) || (strcasecmp($rx[4],$name)==0) || (strlen($rx[2])>=3 && stristr($name, $rx[2])) || (strlen($rx[3])>=3 && stristr($name, $rx[3])))) { $r2 = $rx; if((strstr($name, " ") && (strcasecmp(str_replace(" ", "", $name),$rx[4])==0)) || (strstr($rx[4], " ") && (strcasecmp(str_replace(" ", "", $rx[4]),$name)==0))){ break; } } } //found it - use it now $r = $r2 ? $r2 : null; } elseif($nrs == 1) { $r = mysql_fetch_row($q); } @mysql_close(); if(is_array($r)) { $pict = $r[0]; if(!$pict) { $pict = $commNonePict; } $ext = ""; if(strrpos($pict, ".") > 0) { $ext = strtolower(trim(substr($pict, strrpos($pict, ".")))); } return array($ext,$pict); } else { //non-registered commenter if($siteCheck) { exit; } $pict = $addPhotoPict; $ext = ".gif"; return array($ext,$pict); } } function getPossibleURLs($host, $url, $addSlashes = true) { $host = str_replace('www.', '', $host); $url = str_replace('http://', '', $url); $url = str_replace('www.', '', $url); if(strpos(strtolower($url), 'mybloglog.com/buzz/') === 0) { $host = $url; } if($addSlashes) { $host = addslashes($host); $url = addslashes($url); } if($host) { return array("http://$url", "http://www.$url", "http://$url/", "http://www.$url/", "http://$host","http://blog.$host", "http://$host/", "http://blog.$host/", "http://$host/blog", "http://$host/blog/", "http://www.$host/blog", "http://www.$host/blog/", "http://www.$host", "http://www.$host/", "https://$host", "https://$host/", "https://www.$host", "https://www.$host/"); } else { return array(); } } ?>