﻿£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
<?php

require_once "include/db.inc.php";
require_once "include/form.inc.php";
require_once "include/user.inc.php";

class LoginForm extends Form
{
	public $email = "";
	public $password = "";
	public $key = "";
	public $remember = FALSE;

	function FillFromPost()
	{
		ObjectFromArray($this, $_REQUEST);
		if (IsEmpty($this->key) && NotEmpty($this->password))
			$this->key = md5($this->password);
	}

	function Validate($app_login = 'N')
	{
		global $SITE_NAME;
		
		if (IsEmpty($this->email))
			$this->AddError("Please enter your email address.", "email");

		if (IsEmpty($this->key))
			$this->AddError("Please enter your password.", "password");

		if ($this->IsValid())
		{
			$u = User::LoadByEmail($this->email);
			if ($u === FALSE)
				$this->AddError("Oops, you have entered an invalid email address.", "email");
			else
			if (md5($u->password) != $this->key)
				$this->AddError("Oops, you have entered an invalid password.", "password");
			else
			if ($u->del_in == 1)
				$this->AddError("Sorry, your account has been deleted.");
			else
			if ($u->enabled == 0)
				$this->AddError("Sorry, your account has been disabled. Please contact us at <a target='_blank' href='http://www.topnetsolutions.net/'>www.TopNetSolutions.net</a> to have your account re-activated.");
			else
			if ($u->paidtill < date("Y-m-d"))
				$this->AddError("Oops! It looks like your account has expired and you need to renew your membership in order to continue publishing videos.<br/>To renew your membership please follow the instructions in the email that was sent to you, or contact us at <a target='_blank' href='http://www.topnetsolutions.net/'>www.TopNetSolutions.net</a>.<br/>If you do not renew your existing videos will be deleted from our servers.<br/><br/>Once you have renewed this message will disappear.");
			else
			{
				$used_space = DbQuery("SELECT SUM(SPACE) FROM videos WHERE userid=" . $u->id);
				$used_gb = $used_space / (1024 * 1024 * 1024);

				if ($u->storage_cap > $used_gb || $app_login == 'N') {
					if ($this->remember) {
						setcookie("email", $this->email, time() + 60 * 60 * 24 * 30);
						setcookie("key", $this->key, time() + 60 * 60 * 24 * 30);
					}
					$_SESSION["user"] = $u;
				}
				else
				{
					$this->AddError("Sorry, Your account's storage limit is exceeded. Please upgrade your ".$SITE_NAME." membership.");
				}
			}
		}
		return $this->IsValid();
	}

	function Save()
	{
	}
}

?>