<?php
	require_once "pageBase.php";
	require_once "../dal/userDAL.php";
	require_once "../bin/web/repeater.php";
	require_once "../bin/system/utility.php";
	class _lineGearingSend extends pageBase {
		public function load() {
			$this->limitID = "68";

			$currentDate = new DateTime();
			$endDate = new DateTime('2025-03-20');
			if ($currentDate > $endDate) {
				$this->alertMsg = "Line Notify 已經停止服務!";
				$this->locationHref = "index.php";
			} else {
				if (!parent::chkUserLimit()) {
					$this->alertMsg = "您沒有使用此頁面的權限!如有疑問請洽主管理者!";
					$this->locationHref = "index.php";
				} else {
					$this->loadData();
				}
			}
			parent::loadTemplateFile(dirname(__FILE__) . "/templates/lineGearingSend.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 . "notify/");
			} else {
				$this->alertMsg = "很抱歉，目前第三方平台忙線中!如有疑問請洽主管理者!";
				$this->locationHref = "index.php";
			}

			parent::loadData();
		}
	}

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