<?php
	require_once "pageBase.php";
	require_once "../dal/userDAL.php";
	require_once "../dal/line_gearingDAL.php";
	require_once "../bin/system/utility.php";
	require_once "../bin/web/tables/sends.php";

	class _lineLogin extends pageBase {
		public function load(){
			$this->loadData();
			parent::loadTemplateFile(dirname(__FILE__) . "/templates/lineLoginSend.html");
			parent::load();
		}

		public function loadData() {
			$myLink = parent::getProtocol() . "://" . $_SERVER['HTTP_HOST'] . "/iweb/login.php";
			
			if ($_SERVER["HTTP_REFERER"] == $myLink) {
				parent::addParameter("link", $_SERVER['HTTP_HOST']);
				
				//檢查登入站是否可以使用
				$txtJ = file_get_contents("./line/srever.json");
				$aryU = json_decode($txtJ);
				$flag = 0;
				$link = "";
				foreach ($aryU as $url) {
					if (parent::chklink($url)) {
						$flag = 1;
						$link = $url;
						break;
					}
				}
				if ($flag == 1) {
					parent::addParameter("url", $link . "login/");
				} else {
					$this->alertMsg = "很抱歉，目前第三方平台忙線中！如有疑問請洽主管理者！";
					$this->locationHref = "index.php";
				}
			} else {
				$this->alertMsg = "網址目標錯誤！";
				$this->locationHref = "index.php";
			}
			
			parent::loadData();
		}
	}

	$page = new _lineLogin();
	$page->load();
	$page->render();
?>