<?php
	//引入语言包
	$a_langpackage=new albumlp;
	$mn_langpackage=new menulp;
	
	require("foundation/module_users.php");
	require("foundation/module_restore.php");
	
	//变量取得
	$photo_id = short_check(get_argg('photo_id'));
	$album_id=short_check(get_argg('album_id'));
	$img_num = short_check(get_argg('img_num'));
	$photo_id_array = get_session($album_id.'S_photo_id_array');
	$num = get_session($album_id.'S_num');
	$url_uid= short_check(get_argg('user_id'));
	$ses_uid=get_sess_userid();
	
	//引入模块公共权限过程文件
	$is_login_mode='';
	$is_self_mode='partLimit';
	require("foundation/auser_validate.php");
	require("foundation/module_mypals.php");
	
	//数据表定义区
	$t_photo = $tablePreStr."photo";
	$t_photo_comment = $tablePreStr."photo_comment";
	$t_holerpals = $tablePreStr."pals_mine";
	$t_users=$tablePreStr."users";
	$t_album=$tablePreStr."album";
	$dbo = new dbex;

	//读写分离定义函数
	dbtarget('r',$dbServs);
	$album_info=array();
	$sql="select album_name from $t_album where album_id=$album_id";
	$album_info=$dbo->getRow($sql);
	$album_name=$album_info['album_name'];
	$holder_pals=getHodlerpals($dbo,$t_holerpals,$url_uid);
	$p=strstr($holder_pals,",".$ses_uid.",");

	if(!get_session($album_id.'S_photo_id_array') or !get_session($album_id.'S_num')){
		$sql="select * from $t_photo where album_id='$album_id' order by add_time desc";
		$photo_rs = $dbo->getRs($sql);
		$num=$dbo->rowCount;
		set_session($album_id.'S_num',$num);
		$i=0;
		foreach($photo_rs as $val){
			$photo_id_array[$i]=$val['photo_id'];
			$i++;
		}
		set_session($album_id.'S_photo_id_array',$photo_id_array);
	}
	if($img_num==""){
		$img_num=@array_search($photo_id,$photo_id_array);
	}
	//翻页
	if($img_num == $num){$img_num=0;}
	if($img_num == -1){$img_num = $num-1;}
	$photo_id=$photo_id_array[$img_num];
	
	//数据显示控制
	$photo_lock="content_none";
	$show_data="";
	$show_error="content_none";
	$show_content="content_none";
	
	if($photo_id==""){
		$show_data="content_none";
		$show_error="";
	}else{
		$sql = "select * from $t_photo where photo_id=$photo_id";
		$photo_row = $dbo ->getRow($sql);
	}
	$is_admin=get_sess_admin();
	if($is_admin==''){
		if($photo_row['photo_pass']==0){
			$show_data="content_none";
			$photo_lock="";
		}
	}
	if(empty($photo_row)){
		$show_data="content_none";
		$show_error="";
		$photo_lock="content_none";
	}else{
		$img_info=getimagesize($photo_row['photo_src']);
	}
	
	if($photo_row['album_secret']==2 and $photo_row['user_id']!=$ses_uid){
		$show_data="content_none";
		$show_content="";
		$photo_lock="content_none";
	}else if($photo_row['album_secret']==1 and $photo_row['user_id']!=$ses_uid){
		if(!$p||empty($ses_uid)){
			$show_data="content_none";
			$show_content="";
			$photo_lock="content_none";
		}
	}
	$host_id=$photo_row['user_id'];
	if(empty($photo_row['photo_information'])){
		$photo_inf = $a_langpackage->a_pht_inf;
	}else{
		$photo_inf = $photo_row['photo_information'];
	}
	if($is_self=='Y'){
		$a_who=$a_langpackage->a_mine;
		$button="";
	}else{
		$user_name=get_hodler_name($dbo,$t_users,$url_uid);
		$a_who=str_replace('{holder}',filt_word($user_name),$a_langpackage->a_holder)."</div>";
		$button="content_none";
	}
?>