⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.php

📁 功能齐全
💻 PHP
📖 第 1 页 / 共 2 页
字号:

	function onLogin()
	{

		$db = & $this->db;
		$tpl = & $this->tpl;

		require_once($this->sys_lang->getLangfile());
		require_once("function.php");

		$name = $_POST['username'];
		$pass = $_POST['pass'];
		$sql = "select * from friends_user where username='$name' and pass = md5('$pass')";
		$res = $db->query($sql);
		if($this->db->num_rows($res)>0)
		{
			setcookie("loginname",$_POST['username'],time()+3600*24*20);
			if(isAdmin($_POST['username']))$tpl->set("gourl","administrator.php");
			else $tpl->set("gourl","index.php");
			$tpl->set("msg",$lang_sysmsg['loginok']);
			//更新积分
			upPoint($name,"Login","");

		}
		else
		$tpl->set("msg",$lang_sysmsg['loginerro']);
		
		$tpl->set("timesup","2000");
		$tpl->set("main_middle","sysmsg.html");
		$tpl->parse("main.html");
	}

	function onGetpass()
	{
		$tpl = & $this->tpl;
		require_once($this->sys_lang->getLangfile());
		$tpl->set("column",$nav["getpass"]);
		$tpl->set("main_middle","sendpass.html");
		$tpl->parse("main.html");
	}

	function onSendpass()
	{
		$tpl = & $this->tpl;
		$db  = & $this->db;
		$strObj = & new String();

		require_once($this->sys_lang->getLangfile());

		$name  = $_POST['name'];
		$email = $_POST['email'];

		$str = "select * from friends_user where username='$name' and email='$email'";
		$res = $db->query($str);
		if($this->db->num_rows($res)>0)
		{
			$randpass = $strObj->getRandStr(6,5);
			$newpass  = md5($randpass);
			if($db->query("update friends_user set pass='$newpass' where username='$name'"))
			{
				//
				email_pass($email,$randpass);
				$tpl->set("msg",$lang_sysmsg['sendpassok']);
			}
		}
		else
		{
			$tpl->set("msg",$lang_sysmsg['sendpasserro']);
		}
		$tpl->set("gourl","index.php");
		$tpl->set("timesup","2000");
		$tpl->set("main_middle","sysmsg.html");
		$tpl->parse("main.html");
	}

	function onLogout()
	{
		$tpl = & $this->tpl;
		$db  = & $this->db;
		
		$user = $_COOKIE["loginname"];
		$db->query("delete from user_online where username='$user'");
		setcookie("loginname","");

		require_once($this->sys_lang->getLangfile());

		$tpl->set("msg",$lang_sysmsg['logout']);
		$tpl->set("gourl","index.php");
		$tpl->set("timesup","2000");
		$tpl->set("main_middle","sysmsg.html");
		$tpl->parse("main.html");
	}

	function onSearch()
	{
		$tpl = & $this->tpl;
		$db  = & $this->db;
		$ds  = & new DataSet($db);

		require_once($this->sys_lang->getLangfile());
		require_once("function.php");
		//取得积分配置
		$conf=getConf();
		//更新积分
		if($_COOKIE['loginname']!='')upPoint($_COOKIE['loginname'],"Search","");

		$name     = $_GET['username'] != '' ? $_GET['username']:$_POST['username'];
		$sex      = $_GET['sex'] != '' ? $_GET['sex']:$_POST['sex'];
		$age1     = $_GET['age1'] != '' ? $_GET['age1']:$_POST['age1'];
		$age2     = $_GET['age2'] != '' ? $_GET['age2']:$_POST['age2'];
		$place    = $_GET['place'] != '' ? $_GET['place']:$_POST['place'];
		$city     = $_GET['city'] != '' ? $_GET['city']:$_POST['city'];
		$job      = $_GET['job'] != '' ? $_GET['job']:$_POST['job'];
		$income   = $_GET['income'] != '' ? $_GET['income']:$_POST['income'];
		$haspic   = $_GET['haspic'] != '' ? $_GET['haspic']:$_POST['haspic'];
		$edu	  = $_GET['edu'] != '' ? $_GET['edu']:$_POST['edu'];
		$relation = $_GET['relation'] != '' ? $_GET['relation']:$_POST['relation'];

		if($name != '')
		{
			$str = "select * from friends_user where username='$name' and grade>0 and active='1' ";//add active information
		}
		else
		{
			if($haspic==1)$str = "select t1.* from friends_user as t1,user_album as t2 where (TO_DAYS(now())-TO_DAYS(t1.birth))/365 between '".$age1."' and '".$age2."' ";
			else $str = "select t1.* from friends_user as t1 where (TO_DAYS(now())-TO_DAYS(t1.birth))/365 between '".$age1."' and '".$age2."' ";
			if($sex >0)$str .= "and t1.sex='$sex' ";
			if($place >0)$str .= "and t1.place='$place' ";
			if($city >0)$str .= "and t1.city='$city' ";
			if($job >0)$str .= "and t1.job='$job' ";
			if($income >0)$str .= "and t1.income='$income' ";
			if($edu >0)$str .= "and t1.edu>'$edu' ";
			if($relation >0)$str .= "and t1.relation='$relation' ";
			if($haspic==1)$str .= "and t1.username = t2.username AND t2.fm =1 ";
			$str .= "and t1.grade>0 and t1.active='1' order by rand()";//add active information
		}
		$coObj = $ds->getList($str,2);

		$tpl->set("pagejump",$coObj->pagejump());
		$coObj->navchar=$lang_nav;
		$tpl->set("navbar",$coObj->navbar(10));
		$tpl->set("user_data",$coObj->field);
		$tpl->set("price",abs($conf[0]));
		$tpl->set("column",$nav["searchres"]);
		$tpl->set("main_middle","userlist.html");
		$tpl->parse("main.html");
	}
	
	function onSearchFor()
	{
		$tpl = & $this->tpl;
		$otHtml = & new OutputHtml();

		require_once($this->sys_lang->getLangfile());
		$tpl->set("column",$nav["search"]);
		$tpl->set("edu",$otHtml->selection("edu",$lang_edu["values"],$lang_edu["texts"],0,""));
		$tpl->set("job",$otHtml->selection("job",$lang_job["values"],$lang_job["texts"],0,""));
		$tpl->set("income",$otHtml->selection("income",$lang_income["values"],$lang_income["texts"],0,""));
		$tpl->set("relation",$otHtml->selection("relation",$lang_relation["values"],$lang_relation["texts"],0,""));
		$tpl->set("main_middle","search_for.html");
		$tpl->parse("main.html");
	}
	
	function onContact()
	{
		$tpl = & $this->tpl;
		$db  = & $this->db;

		require_once($this->sys_lang->getLangfile());
		require_once("function.php");
		$conf=getConf();

		$name	= $_GET['name'];
		$cost	= $_GET['cost'];
		$view	= $_GET['view'];
		$id=$_GET['id'];//照片ID数据
		$user	= $_COOKIE['loginname'];
		if($user == '')
		{
			$tpl->set("msg",$lang_sysmsg['nologin']);
			$tpl->set("gourl","index.php");
			$tpl->set("timesup","2000");
			$tpl->set("main_middle","sysmsg.html");
		}
		else
		{
			$str = "select money from friends_user where username='$user'";
			$res = $db->query($str);
			$arr = $db->fetch_array($res);
			$pnt = $arr["money"];
			if($pnt<$cost)//积分小于资料的价格
			{
				$tpl->set("msg",$lang_sysmsg['nopoints']);
				$tpl->set("gourl","index.php?op=Point");
				$tpl->set("timesup","2000");
				$tpl->set("main_middle","sysmsg.html");
			}
			else
			{
				//如果浏览照片收费
				if($view==1)
				{
					$item = sprintf($lang_sysmsg['buypic'],$name);
					$date = date("Y-m-d H:i:s");
					//更新用户的积分
					$db->query("update friends_user set money=money-'$cost' where username='$user'");
					//记录消费明细
					$db->query("insert into user_charge values('$user','$item','$cost','0','$date')");
					//被浏览照片的用户点数同时增加
					$item1 = sprintf($lang_sysmsg['beclick'],$user);
					$reward = ($cost*$conf[2]);//$conf[2]为回报率
					$db->query("update friends_user set money=money+'$reward' where username='$name'");
					$db->query("insert into user_charge values('$name','$item1','$reward','1','$date')");
	
					$tpl->set("msg",$lang_sysmsg['viewpic']);
					$tpl->set("gourl","album.php?op=showpic&id=".$id);
					$tpl->set("timesup","1000");
					$tpl->set("main_middle","sysmsg.html");
				}
				elseif($view==2)//如果查看资料收费
				{
					$item = sprintf($lang_sysmsg['buyinfo'],$name);
					$date = date("Y-m-d H:i:s");
					//更新用户的积分
					upPoint($user,"Contact",$item);
					//更新被浏览资料用户的积分
					$item1 = sprintf($lang_sysmsg['beview'],$user);
					$reward = ($cost*$conf[2]);//$conf[2]为回报率
					$db->query("insert into user_charge values('$name','$item1','$reward','1','$date')");
					$db->query("update friends_user set money=money+'$reward',click=click+1 where username='$name'");
					$result = $db->query("select email,realname,address,zipcode,tel,otherinfo from friends_user where username='$name'");
					$info = $db->fetch_array($result);
					$tpl->set("column",$nav["contact"]);
					$tpl->set("who",$name);
					$tpl->set("email",$info["email"]);
					$tpl->set("realname",$info["realname"]);
					$tpl->set("address",$info["address"]);
					$tpl->set("zipcode",$info["zipcode"]);
					$tpl->set("tel",$info["tel"]);
					$tpl->set("otherinfo",$info["otherinfo"]);
					$tpl->set("main_middle","contactinfo.html");
				}
			}
		}

		$tpl->parse("main.html");
	}

	function onPoint()
	{
		$tpl = & $this->tpl;
		$db  = & $this->db;
		$ds  = & new DataSet($db);

		require_once($this->sys_lang->getLangfile());

		$user = $_COOKIE['loginname'];
		if($user == '')
		{
			$tpl->set("msg",$lang_sysmsg['nologin']);
			$tpl->set("gourl","index.php");
			$tpl->set("timesup","2000");
			$tpl->set("main_middle","sysmsg.html");
		}
		else
		{
			$arr = $db->fetch_array($db->query("select money from friends_user where username='$user'"));
			$mymoney = $arr["money"];
			/*
			统计支出总额、收入总额、充值总额
			查询语句
			*/
			$str1 = "SELECT SUM( num ) AS out FROM user_charge WHERE account ='0' AND username = '$user'";
			$arr1 = $db->fetch_array($db->query($str1));
			$out = (!$arr1["out"])?0:$arr1["out"];
			$str2 = "SELECT SUM( num ) AS reward FROM user_charge WHERE account ='1' AND username = '$user'";
			$arr2 = $db->fetch_array($db->query($str2));
			$in = (!$arr2["reward"])?0:$arr2["reward"];
			$str3 = "SELECT SUM( num ) AS buy FROM user_charge WHERE account ='2' AND username = '$user'";
			$arr3 = $db->fetch_array($db->query($str3));
			$buy = (!$arr3["buy"])?0:$arr3["buy"];
			$str = "select * from user_charge where username='$user'";
			$coObj = $ds->getList($str,20);

			$coObj->navchar=$lang_nav;
			$tpl->set("navbar",$coObj->navbar(10));
			$tpl->set("arr",$coObj->field);
			$tpl->set("pagejump",$coObj->pagejump());
			$tpl->set("mymoney",$mymoney);
			$tpl->set("username",$user);
			$tpl->set("out",$out);
			$tpl->set("in",$in);
			$tpl->set("buy",$buy);
			$tpl->set("column",$nav["mypoint"]);
			$tpl->set("main_middle","mypoints.html");
		}
		$tpl->parse("main.html");
	}

	function onShowPoint()
	{
		$tpl = & $this->tpl;
		require_once("function.php");
		require_once($this->sys_lang->getLangfile());
		$conf=getConf();
		$tpl->set("contact",abs($conf[0]));
		$tpl->set("viewpic",abs($conf[1]));
		$tpl->set("recontact",100*$conf[2]);
		$tpl->set("reviewpic",100*$conf[3]);
		$tpl->set("login",$conf[4]);
		$tpl->set("modify",$conf[5]);
		$tpl->set("search",$conf[6]);
		$tpl->set("savepic",$conf[7]);
		$tpl->set("column",$nav["points"]);
		$tpl->set("main_middle","points.html");
		$tpl->parse("main.html");
	}
	
	function onBuyPoint()
	{
		$tpl = & $this->tpl;
		require_once($this->sys_lang->getLangfile());
		$tpl->set("column",$nav["buypnt"]);
		$tpl->set("main_middle","buypoints.html");
		$tpl->parse("main.html");
	}
	
}//end class
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -