<?php
	require("foundation/module_users.php");
	require("foundation/module_mypals.php");
	require("foundation/aanti_refresh.php");
	require("foundation/aintegral.php");

	//数据表定义区
	$t_report=$tablePreStr."report";

	//引入语言包
	$rp_langpackage=new reportlp;
	
	$dbo = new dbex;

	//变量区
	$type = short_check(get_argg('type'));
	$user_id = get_sess_userid();
	$user_name = get_sess_username();
	$ued_id = short_check(get_argg('uid'));
	$reason = short_check(get_argp('reason'));
	$mod_id=short_check(get_argg('mod_id'));
	
	$t_report=$tablePreStr."report";

	dbtarget('r',$dbServs);
	$sql="select * from $t_report where reported_id=$mod_id and type=$type";
	$report_row=$dbo->getRow($sql);
	
	if($report_row){
		if($user_id==$report_row['user_id']){
			echo $rp_langpackage->rp_no_repeat;
		}else{
			dbtarget('w',$dbServs);
			$sql="update $t_report set rep_num=rep_num+1 where reported_id=$mod_id and type=$type";
			if($dbo->exeUpdate($sql)){
				echo 'true';
			}else{
				echo $rp_langpackage->rp_los;
			}
		}
	}else{
		if($type=='3'){
			$t_photo=$tablePreStr."photo";
			$t_user=$tablePreStr."users";
			$sql="select * from $t_photo where photo_id=$mod_id";
			$photo_row=$dbo->getRow($sql);
			$sql="select user_name from $t_user where user_id=$ued_id";
			$user_row=$dbo->getRow($sql);
			$ued_id=$photo_row['user_id'];
			$ued_name=$user_row['user_name'];
			$content=$rp_langpackage->rp_report.'<a href="../home.php?h='.$ued_id.'" target="_blank">'.$ued_name.'</a>'.$rp_langpackage->rp_pho.$photo_row['photo_information'].'<br /><a href="../home.php?h='.$ued_id.'&app=photo_view&album_id='.$photo_row['album_id'].'&photo_id='.$photo_row['photo_id'].'" target="_blank"><img src="../{ico_url}" width="100" /></a>';
			$content=str_replace('{ico_url}',$photo_row['photo_src'],$content);
		}
		if($type=='2'){
			$t_album=$tablePreStr."album";
			$sql="select * from $t_album where album_id=$mod_id";
			$album_row=$dbo->getRow($sql);
			$ued_id=$album_row['user_id'];
			$content=$rp_langpackage->rp_report.'<a href="../home.php?h='.$ued_id.'" target="_blank">'.$album_row['user_name'].'</a>'.$rp_langpackage->rp_alb.$album_row['album_name'].'<br /><a href="../home.php?h='.$ued_id.'&app=photo_list&album_id='.$album_row['album_id'].'" target="_blank"><img src="../{ico_url}" width="100" /></a>';
			$content=str_replace('{ico_url}',$album_row['album_skin'],$content);
		}
		if($type=='0'){
			$t_blog=$tablePreStr."blog";
			$sql="select * from $t_blog where log_id=$mod_id";
			$blog_row=$dbo->getRow($sql);
			$ued_id=$blog_row['user_id'];
			$content=$rp_langpackage->rp_report.'<a href="../home.php?h='.$ued_id.'" target="_blank">'.$blog_row['user_name'].'</a>'.$rp_langpackage->rp_blog.'<a href="../home.php?h='.$ued_id.'&app=blog_show&id='.$blog_row['log_id'].'" target="_blank">{ico_url}</a>';
			$content=str_replace('{ico_url}',$blog_row['log_title'],$content);
		}
		if($type=='1'){
			$t_groups=$tablePreStr."groups";
			$sql="select * from $t_groups where group_id=$mod_id";
			$groups_row=$dbo->getRow($sql);
			$ued_id=$groups_row['add_userid'];
			$content=$rp_langpackage->rp_report.'<a href="../home.php?h='.$ued_id.'" target="_blank">'.$groups_row['group_creat_name'].'</a>'.$rp_langpackage->rp_group.'<a href="../home.php?h='.$ued_id.'&app=group_space&group_id='.$groups_row['group_id'].'" target="_blank">{ico_url}<br /><img src="../'.$groups_row['group_logo'].'" width="100" /></a>';
			$content=str_replace('{ico_url}',$groups_row['group_name'],$content);
		}
		if($type=='4'){
			$t_poll=$tablePreStr."poll";
			$sql="select * from $t_poll where p_id=$mod_id";
			$poll_row=$dbo->getRow($sql);
			$ued_id=$poll_row['uid'];
			$content=$rp_langpackage->rp_report.'<a href="../home.php?h='.$ued_id.'" target="_blank">'.$poll_row['username'].'</a>'.$rp_langpackage->rp_poll.'<a href="../home.php?h='.$ued_id.'&app=poll_show&p_id='.$poll_row['pid'].'" target="_blank">{ico_url}</a>';
			$content=str_replace('{ico_url}',$poll_row['subject'],$content);
		}
		if($type=='9'){
			$t_subject=$tablePreStr."group_subject";
			$sql="select * from $t_subject where subject_id=$mod_id";
			$subject_row=$dbo->getRow($sql);
			$ued_id=$subject_row['user_id'];
			$content=$rp_langpackage->rp_report.'<a href="../home.php?h='.$ued_id.'" target="_blank">'.$subject_row['user_name'].'</a>'.$rp_langpackage->rp_sub.'<a href="../home.php?h='.$ued_id.'&app=group_sub_show&subject_id='.$subject_row['subject_id'].'&group_id='.$subject_row['group_id'].'" target="_blank">{ico_url}</a>';
			$content=str_replace('{ico_url}',$subject_row['title'],$content);
		}
		if($type=='10'){
			$t_users=$tablePreStr."users";
			$sql="select * from $t_users where user_id=$mod_id";
			$user_row=$dbo->getRow($sql);
			$ued_id=$user_row['user_id'];
			$content=$rp_langpackage->rp_report.'<a href="../home.php?h='.$ued_id.'" target="_blank">{ico_url}</a>'.$rp_langpackage->rp_space;
			$content=str_replace('{ico_url}',$user_row['user_name'],$content);
		}
		if($type=='8'){
			$t_share=$tablePreStr."share";
			$sql="select * from $t_share where s_id=$mod_id";
			$share_row=$dbo->getRow($sql);
			$ued_id=$share_row['user_id'];
			$content=$rp_langpackage->rp_report.'<a href="../home.php?h='.$ued_id.'" target="_blank">'.$share_row['user_name'].'</a>'.$rp_langpackage->rp_share.'<br />{ico_url}';
			$search=array('{date_time}','href="');
			$replace=array('','href="../');
			$share_content=str_replace($search,$replace,$share_row['content']);
			$content=str_replace('{ico_url}',$share_content,$content);
		}
		dbtarget('w',$dbServs);
		$sql="insert into $t_report (user_id,reason,user_name,type,content,add_time,reported_id,ued_id) "
			."values ('$user_id','$reason','$user_name','$type','$content',now(),'$mod_id','$ued_id')";
		if($dbo->exeUpdate($sql)){
			echo 'true';
		}else{
			echo $rp_langpackage->rp_los;
		}
	}
	

?>