<?php
 /*
 * 74cms 举报
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__).'/../include/common.inc.php');
$act = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'app';
require_once(QISHI_ROOT_PATH.'include/mysql.class.php');
require_once(QISHI_ROOT_PATH.'include/fun_user.php');
$db = new mysql($dbhost,$dbuser,$dbpass,$dbname);
if ($_SESSION['uid']=='' || $_SESSION['username']=='')
{
	$captcha=get_cache('captcha');
	$smarty->assign('verify_userlogin',$captcha['verify_userlogin']);
	$smarty->display('plus/ajax_login.htm');
	exit();
}
if ($_SESSION['utype']!='1' && $_SESSION['utype']!='2')
{
	exit('<div class="floatContent">
			<div class="float_common_box">
				<div class="float_tips">
					<div>必须是企业会员/个人会员才可以举报猎头信息！</div>
				</div>
			</div>
		</div>');
}
if($_SESSION['utype']=="1"){
	require_once(QISHI_ROOT_PATH.'include/fun_company.php');
}elseif($_SESSION['utype']=="2"){
	require_once(QISHI_ROOT_PATH.'include/fun_personal.php');
}
$user=get_user_info($_SESSION['uid']);
if ($user['status']=="2") 
{
	exit('<div class="floatContent">
			<div class="float_common_box">
				<div class="float_tips">
					<div>您的账号处于暂停状态，请联系管理员设为正常后进行操作！</div>
				</div>
			</div>
		</div>');
}
if ($act=="report")
{		
		$id=isset($_GET['hunter_id'])?$_GET['hunter_id']:exit("id 丢失");
		$hunter=get_hunter_byid($id);
		if (empty($hunter))
		{
			exit('<div class="floatContent">
					<div class="float_common_box">
						<div class="float_tips">
							<div>举报信息失败！</div>
						</div>
					</div>
				</div>');
		}
		if (check_hunter_report($_SESSION['uid'],intval($_GET['hunter_id'])))
		{
			exit('<div class="floatContent">
					<div class="float_common_box">
						<div class="float_tips">
							<div>您已经举报过此猎头！</div>
						</div>
					</div>
				</div>');
		}
?>
<script type="text/javascript">
$(".but80").hover(function(){$(this).addClass("but80_hover")},function(){$(this).removeClass("but80_hover")});
//验证
$("#ajax_report").die().click(function() {
	var content=$("#content").val();
	if (content=="")
	{
	alert("请输入描述");
	}
	else
	{
		$("#report").hide();
		$("#waiting").show();
		
		$.post("<?php echo $_CFG['site_dir'] ?>user/user_report_hunter.php", { "hunter_id": $("#hunter_id").val(),"full_name": $("#full_name").val(),"content": $("#content").val(),"type": $("#type").val(),"act":"app_save"},

	 	function (data,textStatus)
	 	 {
			if (data=="ok")
			{
				$("#report").hide();
				$("#waiting").hide();
				$("#app_ok").show();
					$("#app_ok .closed").click(function(){
					});
			}
			else
			{
				$("#report").hide();
				$("#waiting").hide();
				$("#app_ok").show();
				$(".float_auth_success").html("举报失败！"+data);
			}
	 	 });
	}
});
function DialogClose()
{
	$("#FloatBg").hide();
	$("#FloatBox").hide();
}
</script>

<div class="floatContent" id="report">
	<div class="float_common_box">
		<table class="float_auth_table">
			<tbody>
				<input type="hidden" id="hunter_id" value="<?php echo intval($_GET['hunter_id']);?>">
				<input type="hidden" id="full_name" value="<?php echo trim($_GET['full_name']);?>">
				<tr height="40">
					<td align="right">投诉的猎头：</td>
					<td>
						<div class="float_control">
							<?php echo trim($_GET['full_name']);?>
						</div>
					</td>
				</tr>
				<tr height="40">
					<td align="right">投诉类型：</td>
					<td>
						<div class="float_control">
							<select name="type" id="type">
								<option value="1">信息虚假违法</option>
								<option value="2">电话冒用</option>
								<option value="4">其他</option>
							</select>
						</div>
					</td>
				</tr>
				<tr height="40">
					<td align="right">其他描述：</td>
					<td>
						<div class="float_control">
							<textarea name="content" id="content"  style="width:300px; height:60px; line-height:180%; font-size:12px;border：1px solid "></textarea>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
		<div class="float_btn_guoup">
			<input type="submit" value="提交" name="Submit2" class="float_but55lan" id="ajax_report">&nbsp;&nbsp;&nbsp;
			<input type="button" value="取消" class="float_but55hui DialogClose">
		</div>
	</div>
</div>
<div class="floatContent" style="display:none" id="waiting" >
	<div class="float_common_box" >
		<img src="<?php echo  $_CFG['site_template']?>images/30.gif" style="margin-left:110px;" border="0"/>
	</div>
</div>
<div class="floatContent" style="display:none" id="app_ok" >
	<div class="float_common_box" >
		<div class="float_auth_success">举报成功，管理员会认真处理</div>
	</div>
</div>
<?php
}

elseif ($act=="app_save")
{
	$setsqlarr['content']=trim($_POST['content'])?trim($_POST['content']):exit("出错了");
	$setsqlarr['hunter_id']=$_POST['hunter_id']?intval($_POST['hunter_id']):exit("出错了");
	$hunter=get_hunter_byid($setsqlarr['hunter_id']);
	$setsqlarr['hunter_uid']=$hunter['uid'];
	$setsqlarr['fullname']=trim($_POST['full_name'])?trim($_POST['full_name']):exit("出错了");
	$setsqlarr['uid']=intval($_SESSION['uid']);
	$setsqlarr['username']=$_SESSION['username'];
	$setsqlarr['addtime']=time();
	$setsqlarr['type']=$_POST['type'];
	$insert_id = inserttable(table('report_hunter'),$setsqlarr,1);
	if($insert_id)
	 {
	 exit("ok");
	 }
}
//id 获取猎头信息
function get_hunter_byid($id)
{
	$id=intval($id);
	global $db;
	return $db->getone("select * from ".table("hunter_profile")." where id=$id limit 1");
}
// 检查是否据过猎头信息
function check_hunter_report($uid,$hunter_id)
{
	global $db;
	$sql = "select id from ".table('report_hunter')." WHERE uid = '".intval($uid)."' AND hunter_id='".intval($hunter_id)."' LIMIT 1";
	return $db->getone($sql);
}
?>
