<?php
	require_once "pageBase.php";
	require_once "../dal/userDAL.php";
	require_once "../bin/web/repeater.php";
	require_once "../bin/system/utility.php";
	class _myLineJoinSend extends pageBase {
		public function load() {
			$this->limitID = "72";
			if (!parent::chkUserLimit()) {
				$this->alertMsg = "您沒有使用此頁面的權限!如有疑問請洽主管理者!";
				$this->locationHref = "index.php";
			} else {
				parent::isPostBack() ? $this->saveData() : $this->loadData();
			}
			parent::loadTemplateFile(dirname(__FILE__) . "/templates/myLineJoinSend.html");
			parent::load();
		}
		
		public function loadData() {
			$dal = new userDAL();
			$dal->UserID = parent::getCurrentUserID();
			$dal->loadRecord();
    
			parent::addParameter("pathName", $dal->PathName);
			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 . "join/");
			} else {
				$this->alertMsg = "很抱歉，目前第三方平台忙線中!如有疑問請洽主管理者!";
				$this->locationHref = "index.php";
			}
			
			parent::loadData();
		}
	}

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