<?php
/*
	[Phpup.Net!] (C)2009-2011 Phpup.net.
	This is NOT a freeware, use is subject to license terms

	$Id: getinfo.php 2010-08-24 10:42 $
*/
define('IN_PHPUP',1);
date_default_timezone_set('Asia/Shanghai');
define('ROOT_PATH',str_replace('models','',dirname(__FILE__)));
include ROOT_PATH.'/inc/curl.class.php';
include ROOT_PATH.'/data/cache/setting.php';
include ROOT_PATH.'/data/config.inc.php';
header("Content-type:text/html;charset=".$GLOBALS['charset']);
$setting=$content;
$dbcharset ='utf8';
$serverset = 'character_set_connection='.$dbcharset.', character_set_results='.$dbcharset.', character_set_client=binary';
$link=mysql_pconnect($dbhost,$dbuser,$dbpw);
mysql_query('use '.$dbname,$link);
$version=mysql_get_server_info($link);
$serverset .= $version> '5.0.1' ? ((empty($serverset) ? '' : ',').'sql_mode=\'\'') : '';
$serverset && mysql_query("SET $serverset", $link);
$id=intval($_REQUEST['id']);
$regurl=trim(strip_tags($_REQUEST['regurl']));
if($id && $regurl)
{
	$sql="select siteapi,localapi,id from `".$table_prefix."site` where id=".$id;
	
	$query=mysql_query($sql);
	$data=mysql_fetch_array($query);

	if($data)
	{
		$regurl=str_replace('limengqi2','?',str_replace('limengqiurl1','&',$regurl));
		$curl=new curl();
		$content=$curl->get($regurl);
		if($content)
		{
			$file='/api/attach/'.md5(microtime()).'.xml';
			if(file_put_contents(ROOT_PATH.'/'.$file,$content))
			{
				mysql_query("update `".$table_prefix."site` set localapi='".$file."' where id=".$id);
				echo 'success';
			}
		}
		else
		{
			echo 'false';
		}
	}
	else
	{
		echo 'false';
	}
}