Пример #1
0
function RefererURLBeautifier_handler($target, $mother)
{
    $keyword = false;
    if (preg_match('/\\W(q|query|k|keyword|search|stext|nlia|aqa|wd)(?:=|%3D)([^&]+)/i', $mother['url'], $matches)) {
        $keyword = urldecode(rawurldecode($matches[2]));
    } else {
        if (strpos($mother['host'], 'images.google.') !== false && preg_match('/%3Fsearch%3D([^&]+)/i', $mother['url'], $matches)) {
            $keyword = urldecode(rawurldecode($matches[1]));
        } else {
            if (strpos($mother['host'], 'yahoo.') !== false && preg_match('/\\Wp=([^&]+)/i', $mother['url'], $matches)) {
                $keyword = urldecode(rawurldecode($matches[1]));
            } else {
                if (preg_match('@/search/(?:\\w+/)*([^/?]+)@i', $mother['url'], $matches)) {
                    $keyword = urldecode(rawurldecode($matches[1]));
                }
            }
        }
    }
    if (!UTF8::validate($keyword)) {
        $keyword = UTF8::correct(UTF8::bring($keyword));
    }
    $keyword = UTF16UrlDecode($keyword);
    $url = rawurldecode(substr($mother['url'], 7));
    if (!UTF8::validate($url)) {
        $url = UTF8::correct(UTF8::bring($url));
    }
    //return '<img src="http://'.$mother['host'].'/favicon.ico" width="16" height="16" alt="Favicon" onerror="this.parentNode.removeChild(this)" style="vertical-align: middle"/> ' . (($keyword) ? '<span style="font-weight: bold; color: #594">['.htmlspecialchars($keyword).']</span> ' . UTF8::lessenAsEm($url, 65 - UTF8::lengthAsEm($keyword)) : UTF8::lessenAsEm($url, 65));
    return $keyword ? '<span style="font-weight: bold; color: #594">[' . htmlspecialchars($keyword) . ']</span> ' . htmlspecialchars(UTF8::lessenAsEm($url, 70 - UTF8::lengthAsEm($keyword))) : htmlspecialchars(UTF8::lessenAsEm($url, 70));
}
Пример #2
0
		function open($xml, $encoding = null, $nsenabled = false) {
			if (!empty($encoding) && (strtolower($encoding) != 'utf-8') && !UTF8::validate($xml)) {
				if (preg_match('/^<\?xml[^<]*\s+encoding=["\']?([\w-]+)["\']?/', $xml, $matches)) {
					$encoding = $matches[1];
					$xml = preg_replace('/^(<\?xml[^<]*\s+encoding=)["\']?[\w-]+["\']?/', '$1"utf-8"', $xml, 1);
				}
				if (strcasecmp($encoding, 'utf-8')) {
					$xml = UTF8::bring($xml, $encoding);
					if ($xml === null) {
						$this->error = XML_ERROR_UNKNOWN_ENCODING;
						return false;
					}
				}
			} else {
				if (substr($xml, 0, 3) == "\xEF\xBB\xBF")
					$xml = substr($xml, 3);
			}			
			
			$xml = str_replace('&', '&amp;', $xml); // for parse error code 23 (&)

			$this->nsenabled = $nsenabled;
			$p = ($nsenabled) ? xml_parser_create_ns() : xml_parser_create();
			xml_set_object($p, $this);
			xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
			xml_set_element_handler($p, 'o', 'c');
			xml_set_character_data_handler($p, 'd');
			xml_set_default_handler($p, 'x');
			$this->struct = array();
			$this->_cursor = &$this->struct;
			$this->_path = array('');
			$this->_cdata = false;
			if (!xml_parse($p, $xml))
				return $this->_error($p);
			unset($this->_cursor);
			unset($this->_cdata);
			if (xml_get_error_code($p) != XML_ERROR_NONE)
				return $this->_error($p);
			xml_parser_free($p);
			return true;
		}
 public static function validateArray(&$array, &$rules)
 {
     // Workaround for non Fancy-URL user.
     $cropArray = array();
     foreach ($array as $name => $value) {
         $doesHaveRequest = strpos($name, '?');
         if ($doesHaveRequest !== false) {
             $name = substr($name, $doesHaveRequest + 1);
         }
         $cropArray[$name] = $value;
     }
     $array = $cropArray;
     foreach ($rules as $key => $rule) {
         if (!isset($rule[0])) {
             trigger_error("Validator: The type of '{$key}' is not defined", E_USER_WARNING);
             continue;
         }
         if (isset($array[$key]) && ($rule[0] == 'file' || strlen($array[$key]) > 0)) {
             $value =& $array[$key];
             if (isset($rule['min'])) {
                 $rule[1] = $rule['min'];
             }
             if (isset($rule['max'])) {
                 $rule[2] = $rule['max'];
             }
             if (isset($rule['bypass'])) {
                 $rule[3] = $rule['bypass'];
             }
             switch ($rule[0]) {
                 case 'any':
                     if (isset($rule[1]) && strlen($value) < $rule[1]) {
                         return false;
                     }
                     if (isset($rule[2]) && strlen($value) > $rule[2]) {
                         return false;
                     }
                     break;
                 case 'bit':
                     $array[$key] = self::getBit($value);
                     break;
                 case 'bool':
                     $array[$key] = self::getBool($value);
                     break;
                 case 'number':
                     if (!self::number($value, isset($rule[1]) ? $rule[1] : null, isset($rule[2]) ? $rule[2] : null, isset($rule[3]) ? $rule[3] : false)) {
                         return false;
                     }
                     break;
                 case 'int':
                     if (!self::isInteger($value, isset($rule[1]) ? $rule[1] : -2147483648, isset($rule[2]) ? $rule[2] : 2147483647, isset($rule[3]) ? $rule[3] : false)) {
                         return false;
                     }
                     break;
                 case 'id':
                     if (!self::id($value, isset($rule[1]) ? $rule[1] : 1, isset($rule[2]) ? $rule[2] : 2147483647)) {
                         return false;
                     }
                     break;
                 case 'url':
                 case 'string':
                     if (!UTF8::validate($value)) {
                         $value = UTF8::bring($value);
                         if (!UTF8::validate($value)) {
                             return false;
                         }
                     }
                     $value = $array[$key] = UTF8::correct($value);
                     if (isset($rule[1]) && UTF8::length($value) < $rule[1]) {
                         return false;
                     }
                     if (isset($rule[2]) && UTF8::length($value) > $rule[2]) {
                         return false;
                     }
                     break;
                 case 'list':
                     if (!self::isList($value)) {
                         return false;
                     }
                     break;
                 case 'timestamp':
                     if (!self::timestamp($value)) {
                         return false;
                     }
                     break;
                 case 'period':
                     if (!self::period($value)) {
                         return false;
                     }
                     break;
                 case 'ip':
                     if (!self::ip($value)) {
                         return false;
                     }
                     break;
                 case 'phone':
                     if (!self::phone($value)) {
                         return false;
                     }
                     break;
                 case 'domain':
                     if (!self::domain($value)) {
                         return false;
                     }
                     break;
                 case 'email':
                     if (!self::email($value)) {
                         return false;
                     }
                     break;
                 case 'language':
                     if (!self::language($value)) {
                         return false;
                     }
                     break;
                 case 'filename':
                     if (!self::filename($value)) {
                         return false;
                     }
                     break;
                 case 'directory':
                     if (!self::directory($value)) {
                         return false;
                     }
                     break;
                 case 'path':
                     if (!self::path($value)) {
                         return false;
                     }
                     break;
                 case 'file':
                     if (!isset($value['name']) || preg_match('@[/\\\\]@', $value['name'])) {
                         return false;
                     }
                     break;
                 default:
                     if (is_array($rule[0])) {
                         if (!in_array($value, $rule[0])) {
                             return false;
                         }
                     } else {
                         trigger_error("Validator: The type of '{$key}' is unknown", E_USER_WARNING);
                     }
                     break;
             }
             if (isset($rule['check'])) {
                 $rule[5] = $rule['check'];
             }
             if (isset($rule[5])) {
                 if (function_exists($rule[5])) {
                     if (!call_user_func($rule[5], $value)) {
                         return false;
                     }
                 } else {
                     trigger_error("Validator: The check function of '{$key}' is not defined", E_USER_WARNING);
                 }
             }
         } else {
             if (array_key_exists(3, $rule)) {
                 $array[$key] = $rule[3];
             } else {
                 if (array_key_exists('default', $rule)) {
                     $array[$key] = $rule['default'];
                 } else {
                     if ((!isset($rule[4]) || $rule[4]) && (!isset($rule['mandatory']) || $rule['mandatory'])) {
                         return false;
                     }
                 }
             }
         }
     }
     return true;
 }
Пример #4
0
			$sp_booms = $skin->parseTag('boom_author', UTF8::clear($item['author']), $sp_booms);
			$sp_booms = $skin->parseTag('boom_date', (Validator::is_digit($item['written']) ? date('Y-m-d', $item['written']) : $item['written']), $sp_booms);

			$s_booms_rep .= $sp_booms;
			$sp_booms = '';
		}		
		$s_booms = $skin->dressOn('boom_rep', $src_booms_rep, $s_booms_rep, $src_booms);
	} else {
		$s_booms = '';
	}
	$skin->dress('boom', $s_booms);

	// ** 태그 클라우드
	$skin->dress('tagcloud', SkinElement::getTagCloud($skinConfig->tagCloudOrder, $skinConfig->tagCloudLimit));

	// ** 달력
	$skin->replace('calendar', SkinElement::getCalendarView((($searchType=='archive')&&!empty($searchKeyword)) ? substr($searchKeyword, 0, 6) : null));

	// ** 검색
	$searchTypeSelector = '<select name="type"><option value="all">'._t('전체').'</option><option value="tag"'.(($searchType=='tag')?' selected="selected"':'').'>'._t('태그').'</option><option value="blogURL"'.(($searchType=='blogURL')?' selected="selected"':'').'>'._t('블로그주소').'</option><option value="archive"'.(($searchType=='archive')?' selected="selected"':'').'>'._t('날짜지정').'</option></select>';
	$skin->replace('search_typeselect', $searchTypeSelector);
	$skin->replace('search_keyword', $searchKeyword);
	$src_search = $skin->cutSkinTag('search');

	$s_search = '<form action="'.$servicePath.'/" enctype="application/x-www-form-urlencoded" method="get">'.$src_search.'</form>';
	$skin->dress('search', $s_search);

	$skin->output = $skin->parseTagWithCondition('search_keyword', Korean::doesHaveFinalConsonant(UTF8::bring($searchKeyword)), '<span class="searchKeyword">"'.$searchKeyword.'"</span>', $skin->output);
	if(Validator::is_empty($searchKeyword)) $skin->dress('cond_search', '');			

?>
Пример #5
0
		function getFeedItems($xml) {		
			if (preg_match('/^<\?xml[^<]*\s+encoding=["\']?([\w-]+)["\']?/', $xml, $matches)) // kor env
				$encoding = $matches[1];
			if (strcasecmp($encoding, 'euc-kr') == 0) {
				$xml = UTF8::bring($xml, $encoding);
				$xml = preg_replace('/^(<\?xml[^<]*\s+encoding=)["\']?[\w-]+["\']?/', '$1"utf-8"', $xml, 1);
			}

			$xmls=new XMLStruct();
			if (!$xmls->open($xml))
				return false;

			$items = array();

			if ($xmls->getAttribute('/rss','version')){ // rss element must have version attribute
				for ($i=1;$link=$xmls->getValue("/rss/channel/item[$i]/link");$i++){
					$item=array('permalink'=>rawurldecode($link));
					if (!$item['author']=$xmls->getValue("/rss/channel/item[$i]/author"))
						$item['author']=$xmls->getValue("/rss/channel/item[$i]/dc:creator");
					$item['title']=$xmls->getValue("/rss/channel/item[$i]/title");
					if (!$item['description']=$xmls->getValue("/rss/channel/item[$i]/content:encoded"))
						$item['description']=htmlspecialchars_decode($xmls->getValue("/rss/channel/item[$i]/description"));
					$item['tags']=array();
					for ($j=1;$tag=$xmls->getValue("/rss/channel/item[$i]/category[$j]");$j++)
						if (!empty($tag)) {
						//	array_push($item['tags'],$tag);
							$tags = explode('/', $tag); // allblog, blogkorea types
							foreach($tags as $tag) {
								array_push($item['tags'], trim($tag));
							}
						}

					for ($j=1;$tag=$xmls->getValue("/rss/channel/item[$i]/subject[$j]");$j++)
						if (!empty($tag))
							array_push($item['tags'],$tag);
					if ($youtubeTags = $xmls->getValue("/rss/channel/item[$i]/media:category")) { // for Youtube,Flickr Feed
						array_push($item['tags'], ''); // blank. first tag not equals category
						foreach (explode(' ', $youtubeTags) as $tag) {
							$tag = trim($tag);
							if(!empty($tag))
								array_push($item['tags'], $tag);
						}
					}

					$item['enclosures']=array();
					for ($j=1;$result=$xmls->getAttributes("/rss/channel/item[$i]/enclosure[$j]",array('url','type'));$j++) {
						if (!empty($result)) {
							array_push($item['enclosures'],array('url'=>$result[0],'type'=>$result[1]));
						}
					}
					$flickrContent=$xmls->getAttributes("/rss/channel/item[$i]/media:content[$j]",array('url','type')); // for flickr feed
					if(!empty($flickrContent)) {
							array_push($item['enclosures'],array('url'=>$flickrContent[0],'type'=>$flickrContent[1]));
					}	

					if ($xmls->getValue("/rss/channel/item[$i]/pubDate"))
						$item['written']=Feed::parseDate($xmls->getValue("/rss/channel/item[$i]/pubDate"));
					elseif ($xmls->getValue("/rss/channel/item[$i]/dc:date"))
						$item['written']=Feed::parseDate($xmls->getValue("/rss/channel/item[$i]/dc:date"));
					else
						$item['written']=0;
					if (!$item['generator']=$xmls->getValue("/rss/channel/generator")) {
						if (strpos($item['permalink'], 'tvpot.daum.net') !== false)
							$item['generator'] = 'Daum Tvpot';
						else 
							$item['generator'] = 'Unknown';
					}
					if (!$item['guid']=$xmls->getValue("/rss/channel/item[$i]/guid"))
						$item['guid'] = $item['permalink'];
					
					array_push($items, $item);
				}
			} elseif ($xmls->doesExist('/feed')){ // atom 0.3
				for ($i=1;$link=$xmls->getValue("/feed/entry[$i]/id");$i++){
					$item['enclosures']=array();

					for ($j=1;$rel=$xmls->getAttribute("/feed/entry[$i]/link[$j]",'rel');$j++){
						if ($rel=='alternate'){
							$link=$xmls->getAttribute("/feed/entry[$i]/link[$j]",'href');
						} else if($rel=='enclosure' || $rel=='image') { 
							$result = $xmls->getAttributes("/feed/entry[$i]/link[$j]",array('href','type'));
							if($result) {
								array_push($item['enclosures'],array('url'=>$result[0],'type'=>$result[1]));
							}
						}
					}

					$item=array('permalink'=>rawurldecode($link),'enclosures'=>$item['enclosures']);	

					$item['author']=$xmls->getValue("/feed/entry[$i]/author/name");
					$item['title']=$xmls->getValue("/feed/entry[$i]/title");
					if (!$item['description']=htmlspecialchars_decode($xmls->getValue("/feed/entry[$i]/content")))
						$item['description']=htmlspecialchars_decode($xmls->getValue("/feed/entry[$i]/summary"));
					$item['tags']=array();
					for ($j=1;$tag=$xmls->getValue("/feed/entry[$i]/dc:subject[$j]");$j++) {
						if (!empty($tag)) array_push($item['tags'],trim($tag));
					}
					for ($j=1;$tag=$xmls->getAttribute("/feed/entry[$i]/category[$j]", 'term');$j++) {
						if (!empty($tag)) array_push($item['tags'],trim($tag));
					}
					if (!$item['written']= $xmls->getValue("/feed/entry[$i]/issued")) {
						if (!$item['written'] = $xmls->getValue("/feed/entry[$i]/published")) {
							$item['written'] = $xmls->getValue("/feed/entry[$i]/updated");
						}
					}
					$item['written'] = Feed::parseDate($item['written']);
					if (!$item['generator'] = $xmls->getValue("/feed/generator"))
						$item['generator'] = 'Unknown';
					
					array_push($items, $item);
				}
			} elseif ($xmls->getAttribute('/rdf:RDF','xmlns')){ // rss 1.0, rdf
				for ($i=1;$link=$xmls->getValue("/rdf:RDF/item[$i]/link");$i++){
					$item=array('permalink'=>rawurldecode($link));
					if (!$item['author']=$xmls->getValue("/rdf:RDF/item[$i]/dc:creator"))
						$item['author']=$xmls->getValue("/rdf:RDF/item[$i]/author"); // for NaverBlog rss 1.0
					$item['title']=$xmls->getValue("/rdf:RDF/item[$i]/title");
					if (!$item['description']=$xmls->getValue("/rdf:RDF/item[$i]/content:encoded"))
						$item['description']=htmlspecialchars_decode($xmls->getValue("/rdf:RDF/item[$i]/description"));
					$item['tags']=array();
					$item['enclosures']=array();
					$item['written']=Feed::parseDate($xmls->getValue("/rdf:RDF/item[$i]/dc:date"));

					array_push($items, $item);
				}
			} else
				return false;

			return $items;
		}
Пример #6
0
function getRefererKeywordStatistics()
{
    $more = false;
    $refereres = getRefererLogsDB();
    $keywordlist = array();
    $record = array();
    for ($i = 0; $i < sizeof($refereres); $i++) {
        $record = $refereres[$i];
        if ($i == 0) {
            $referredend = $record['referred'];
        }
        $keyword = "";
        if (preg_match('/\\W(q|query|k|keyword|search|stext|nlia|aqa|wd)(?:=|%3D)([^&]+)/i', $record['url'], $matches)) {
            $keyword = urldecode(rawurldecode($matches[2]));
        } else {
            if (strpos($record['url'], 'yahoo.') !== false && preg_match('/\\Wp=([^&]+)/i', $record['url'], $matches)) {
                $keyword = urldecode(rawurldecode($matches[1]));
            } else {
                if (preg_match('@/search/(?:\\w+/)*([^/?]+)@i', $record['url'], $matches)) {
                    $keyword = urldecode(rawurldecode($matches[1]));
                }
            }
        }
        if (!UTF8::validate($keyword)) {
            $keyword = UTF8::correct(UTF8::bring($keyword));
        }
        if (array_key_exists($keyword, $keywordlist)) {
            $keywordlist[$keyword]++;
        } elseif ($keyword) {
            $keywordlist[$keyword] = 1;
        }
    }
    $referredstart = array_key_exists('referred', $record) ? $record['referred'] : '';
    $keywordlist = RefererKeywordArraySort($keywordlist, 'desc');
    $keywordkeys = array_keys($keywordlist);
    $beforekeywordvalue = '';
    $rank = 0;
    $keywordArray = array();
    for ($i = 0; $i < sizeof($keywordlist); $i++) {
        $keywordkey = $keywordkeys[$i];
        $keywordvalue = $keywordlist[$keywordkey];
        $keywordkey = str_replace("\"", "&quot;", $keywordkeys[$i]);
        if ($keywordvalue != $beforekeywordvalue) {
            $rank++;
            $beforekeywordvalue = $keywordvalue;
        }
        array_push($keywordArray, array('keyword' => $keywordkey, 'count' => $keywordvalue, 'total' => count($keywordlist), 'rank' => $rank, 'dateStart' => Timestamp::formatDate($referredstart), 'dateEnd' => Timestamp::formatDate($referredend)));
    }
    return $keywordArray;
}
		function getFeedItemsQuery($searchType, $searchKeyword, $searchExtraValue,$viewDelete = false,$owner = 0) {	
			global $db, $database, $config;

			$sQuery = '';

			if (($searchType=='tag' || $searchType=='tag+group_category') && !Validator::is_empty($searchKeyword)) {		
				$tagIds = array();
				$tags = explode(',',$searchKeyword);

				if($tagResult = $db->queryAll('SELECT id FROM '.$database['prefix'].'Tags WHERE name IN ('.Func::implode_string(',',$tags).')')) {
					foreach($tagResult as $tagItem) array_push($tagIds, $tagItem['id']);
				}

				if (empty($tagIds)) {
					return array(null,0);
				} else {
					if($searchType == 'tag') {
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed")) WHERE r.tag IN ('.implode(',',$tagIds).')';
					} else if($searchType == 'tag+group_category') {
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed" || r.type = "group_category")) WHERE r.tag IN ('.implode(',',$tagIds).')';
					}
				}

			} else if ($searchType=='blogURL' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				$searchFeedId = $searchExtraValue;
				if(empty($searchFeedId)) {
					$searchFeedId = Feed::blogURL2Id('http://'.str_replace('http://', '', $searchKeyword));
				} 
				if(!empty($searchFeedId)) {
					$sQuery = ' WHERE i.feed = '.$searchFeedId;
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
				
			} else if ($searchType=='user' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				$searchFeedId = $searchExtraValue;
				if(empty($searchFeedId)) {

					if(is_numeric($searchKeyword)) {
						$user = User::getById($searchKeyword);
					} else {
						$user = User::getByloginId($searchKeyword);
					}		
					
					$searchFeedId = Feed::getIdListByOwner($user['id']);
				} 
				if(!empty($searchFeedId)) {
					$sQuery = ' WHERE i.feed IN ('.implode(",",$searchFeedId).')';
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
			} else if ($searchType=='author' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				if(!empty($searchKeyword)) {
					$sQuery = ' WHERE i.author = "' . $searchKeyword . '"';
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
			} else if ($searchType=='title+description' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.description LIKE "%'.$keyword.'%"';				
			}  else if ($searchType=='title' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.title LIKE "%'.$keyword.'%"';				
			} else if ($searchType=='description' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.description LIKE "%'.$keyword.'%"';				
			} else if ($searchType=='focus'){		
					$sQuery =  ' WHERE i.focus = "'.$searchKeyword.'"';		
			} else if ($searchType=='group') {
				requireComponent('Bloglounge.Data.Groups');	
				
				if(!empty($searchExtraValue)) {
					$tagId = $db->pick('SELECT id FROM '.$database['prefix'].'Tags WHERE name="'.$db->escape(urldecode($searchExtraValue)).'"');
					if($tagId) {
						$tagId = $tagId[0];
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND r.type = "group_category") ';
					}
				}

				if(!is_numeric($searchKeyword)) {
					$group = Group::getByName($searchKeyword);
					$searchKeyword = $group['id'];
				}
				
				if($searchKeyword) {	
					$feedIds = Group::getFeedIdList($searchKeyword);
					$sQuery .= ' WHERE i.feed IN (' . implode(',',$feedIds) .')';

					if($tagId) {
						$sQuery .= ' AND r.tag="'.$tagId.'"';
					}
				}

			} else if ($searchType=='category') {
				requireComponent('Bloglounge.Data.Category');
				if(is_numeric($searchKeyword)) {
					$category = Category::getById($searchKeyword);
				} else {
					$category = Category::getByName($searchKeyword);
				}

				if($category) {
					$sQuery = ' WHERE c.category = ' . $category['id'];
				}
			} else if ($searchType == 'archive' && !Validator::is_empty($searchKeyword)) {
				if(is_array($searchExtraValue) && array_key_exists('start',$searchExtraValue) && array_key_exists('end',$searchExtraValue)) {
					$tStart = $searchExtraValue['start'];
					$tEnd = $searchExtraValue['end'] + 86400;
				} else {
					$tStart = $searchExtraValue;
					$tEnd = $tStart + 86400;
				}

				$tQuery = ' WHERE i.written > '.$tStart.' AND i.written < '.$tEnd.' ';
				if (strpos($sQuery, 'WHERE') !== false) {
					$sQuery = str_replace('WHERE ', $tQuery.' AND (', $sQuery);
					$sQuery .= ')';
				} else {
					$sQuery .= $tQuery;
				}

			} else {
				if (!Validator::is_empty($searchKeyword)) {
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);
					
					if(empty($searchExtraValue)) { // all : title, description, tags, permlink						
						$sQuery =  ' WHERE i.author LIKE "%'.$keyword.'%" OR i.title LIKE "%'.$keyword.'%" OR i.description LIKE "%'.$keyword.'%" OR i.tags LIKE "%'.$keyword.'%" OR i.permalink LIKE "%'.$keyword.'%"';					
					} else { // custom					
						$sQuery = ' WHERE ' . $searchExtraValue;
					}
				}
			}


			// boomDownReactor, boomDownReactorLimit : 리액터가 숨기기일때 쿼리에서 제외 파트 추가 ( 특정수만큼 붐다운(비추천)한글은 제외하거나 특정기능..
			
			if(isset($config)) {
				
				if (($config->boomDownReactor == 'hide') && ($config->boomDownReactLimit > 0)) {
					$bQuery = ' WHERE (i.boomDown <= '.$config->boomDownReactLimit.') ';
					if (strpos($sQuery, 'WHERE') !== false) {
						$sQuery = str_replace('WHERE ', $bQuery.' AND (', $sQuery);
						$sQuery .= ')';
					} else {
						$sQuery .= $bQuery;
					}
				}
			
			}
								

			if(empty($owner)) {
				if($viewDelete) {
					// 공개된 블로그만 뽑기 + 삭제된 글 보이기		
					if(!isAdmin()) {
						$bQuery = ' WHERE  (i.visibility = "d") AND (i.feedVisibility = "y") ';
					} else {
						$bQuery = ' WHERE  (i.visibility = "d") ';
					}
				} else {
					// 공개된 블로그만 뽑기
					if(!isAdmin()) {
						$bQuery = ' WHERE  (i.visibility = "y") AND (i.feedVisibility = "y") ';
					} else {
						$bQuery = ' WHERE  (i.visibility != "d") ';
					}
				}
			} else {		
				if($viewDelete) {
					// 공개된 블로그만 뽑기		
				//	if(!isAdmin()) {
				//		$bQuery = ' WHERE  (i.visibility = "d") AND (i.feedVisibility = "y") AND (f.owner = ' . $owner . ')';
				//	} else {
						$bQuery = ' WHERE  (i.visibility = "d") AND (f.owner = ' . $owner . ')';
				//	}
				} else {
					// 공개된 블로그만 뽑기		
				//	if(!isAdmin()) {
				//		$bQuery = ' WHERE  (i.visibility = "y") AND (i.feedVisibility = "y") AND (f.owner = ' . $owner . ')';
				//	} else {
						$bQuery = ' WHERE  (i.visibility != "d") AND (f.owner = ' . $owner . ')';
				//	}
				}
			}

			if($viewDelete) {
				if(strpos($sQuery, 'Feeds f') === false ) {
				$bQuery = ' LEFT JOIN '.$database['prefix'].'Feeds f ON (f.id = i.feed) ' . $bQuery;
				}
			}

			if (strpos($sQuery, 'WHERE') !== false) {
				$sQuery = str_replace('WHERE ', $bQuery.' AND (', $sQuery);
				$sQuery .= ')';
			} else {
				$sQuery .= $bQuery;
			}
	
			return $sQuery;
		}