<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(dirname(__FILE__)."/site_data.php");

$type = trim($_GET['type']);
$web_id = intval($_GET['wid']);
/** crawl */
if ($type == 'crawl') {
	$url = trim($_GET['url']);
	if (empty($url)) {
		ShowMsg("请输入网站域名 ！","-1","1",5000);
		exit();
	} else {
		if (!is_valid_domain($url)) {
			ShowMsg("请输入正确的网站域名(不包含http://) ！","-1","1",5000);
			exit();
		}
	}
	$meta = get_sitemeta($url);	
	echo '<script type="text/javascript">';
	echo '$("#title").attr("value", "'.$meta['title'].'");';
	echo '$("#tags").attr("value", "'.$meta['keywords'].'");';
	echo '$("#body").attr("value", "'.$meta['description'].'");';
	echo '</script>';
	unset($meta);

}

/** data */
if ($type == 'data') {
	$url = trim($_GET['url']);
	if (empty($url)) {
		        ShowMsg("请输入网站域名 ！","-1","1",5000);
        exit();
	} else {
		if (!is_valid_domain($url)) {
			ShowMsg("请输入正确的网站域名 ！","-1","1",5000);
			exit();
		}
	}
	
	$web_grank = get_pagerank($url);
	$web_brank = get_baidurank($url);
	$web_srank = get_sogourank($url);
	$web_arank = get_alexarank($url);
	echo '<script type="text/javascript">';
	echo '$("#grank").attr("value", "'.$web_grank.'");';
	echo '$("#brank").attr("value", "'.$web_brank.'");';
	echo '$("#srank").attr("value", "'.$web_srank.'");';
	echo '$("#arank").attr("value", "'.$web_arank.'");';
	echo '</script>';
}
/** outclick */
if ($type == 'outclick') {
	$dsql->ExecuteNoneQuery("UPDATE `#@__website` SET outclick=outclick+1,outtime=".time()." WHERE aid='$web_id' ");
	}
?>