<?php
/*
		[FuShow.cn] (C) 2013-2014 HXWY Inc.
		FuShow Friend V3.0				Id: walk_inputpwd.php
		Email <service@fushow.cn>		http://fushow.cn/
*/

if(!defined('IN_FUSHOW')) {
	exit('Access Denied');
}

if(submitcheck('pwdsubmit')) {

	$blogid = empty($_POST['blogid'])?0:intval($_POST['blogid']);
	$albumid = empty($_POST['albumid'])?0:intval($_POST['albumid']);
	
	$itemarr = array();
	if($blogid) {
		$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('blog')." WHERE blogid='$blogid'");
		$itemarr = $_SGLOBAL['db']->fetch_array($query);
		$itemurl = "fushow.php?uid=$itemarr[uid]&do=blog&id=$itemarr[blogid]";
		$cookiename = 'view_pwd_blog_'.$blogid;
	} elseif($albumid) {
		$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('album')." WHERE albumid='$albumid'");
		$itemarr = $_SGLOBAL['db']->fetch_array($query);
		$itemurl = "fushow.php?uid=$itemarr[uid]&do=album&id=$itemarr[albumid]";
		$cookiename = 'view_pwd_album_'.$albumid;
	}
	
	if(empty($itemarr)) {
		showmessage('news_does_not_exist');
	}
	
	if($itemarr['password'] && $_POST['viewpwd'] == $itemarr['password']) {
		ssetcookie($cookiename, md5(md5($itemarr['password'])));
		showmessage('proved_to_be_successful', $itemurl);
	} else {
		showmessage('password_is_not_passed', $itemurl);
	}
}

?>