public function getAddHtmlAction() { //session_start(); $VTs = new clsSystem(); $VTs->initialization(); //-----BI開始----- typeunit 單位表IUD頁面 $type = $_GET["type"]; switch ($type) { case '0': $path = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\include\\pageSetting\\styles\\editor\\typeunit_addlist.html"; $html = $VTs->GetHtmlContent($path); $data = $VTs->json2data($VTs->UrlDataGet("http://127.0.0.1:88/editor/getdbdata?page=type_a")); $str = ''; foreach ($data as $opData) { $str .= '<option value=' . $opData->uid . '>' . $opData->name . '</option>'; } $html = str_replace('@@select@@', $str, $html); break; } $pageContent = $html . $VTs->CreateFinishOptionBtn(["uid" => 1], 'test/tw', 'inputClass', 'contentClass'); //-----BI結束----- //關閉資料庫連線 $VTs->DBClose(); //釋放 $VTs = null; $this->viewContnet['pageContent'] = $pageContent; return new ViewModel($this->viewContnet); }
public function editPageAction() { $VTs = new clsSystem(); $VTs->initialization(); try { //-----BI開始----- $pathString = dirname(__DIR__) . "\\..\\..\\..\\..\\public\\include\\pageSetting"; if (empty($_SESSION)) { $pagePath = $pathString . "\\index\\login_page.html"; $pageContent = $VTs->GetHtmlContent($pagePath); } else { if (!empty($_POST)) { $apurl = "http://211.21.170.18:99"; //$apurl = "http://127.0.0.1:99"; $action = $_POST["action"]; // echo $action; $editPagePath = $pathString . "\\employeemanage\\newPage.html"; $editPage = $VTs->GetHtmlContent($editPagePath); switch ($action) { case "insertData": $basicInfoPagePath = $pathString . "\\employeemanage\\basicInfo.html"; break; case "updateData": $basicInfoPagePath = $pathString . "\\employeemanage\\basicInfo_edit.html"; break; default: } $basicInfoPage = $VTs->GetHtmlContent($basicInfoPagePath); $addressPagePath = $pathString . "\\employeemanage\\address.html"; $addressPage = $VTs->GetHtmlContent($addressPagePath); $communicationPagePath = $pathString . "\\employeemanage\\communication.html"; $communicationPage = $VTs->GetHtmlContent($communicationPagePath); $dataArr = ["userName" => $_SESSION["userName"], "basicInfo" => $basicInfoPage, "address" => $addressPage, "communication" => $communicationPage]; $editPage = $VTs->ContentReplace($dataArr, $editPage); switch ($action) { case "insertData": $optionData = $VTs->json2data($VTs->UrlDAtaGet($apurl . "/employeemanage/getdata?type=relationOption")); // $VTs->debug($option); $selectElement = "<select id='relation'><option value='0'>-請選擇-</option>"; if (!empty($optionData)) { foreach ($optionData->dataList as $data) { $optionElement = "<option value='" . $data->uid . "'>" . $data->relation . "</option>"; $selectElement .= $optionElement; } } else { // echo "AP Action getdata has problem."; } $selectElement .= "</select>"; //basicInfo $dataArr = ["name" => "", "sid" => "", "birthday" => ""]; $editPage = $VTs->ContentReplace($dataArr, $editPage); //address $dataArr = ["zip" => "", "city" => "", "area" => "", "vil" => "", "verge" => "", "road" => "", "addr" => ""]; $editPage = $VTs->ContentReplace($dataArr, $editPage); //communication $dataArr = ["belong" => "", "relation" => $selectElement, "relation1" => "", "mobile" => "", "tel_h" => "", "tel_o" => "", "tel_ext" => "", "email" => ""]; $editPage = $VTs->ContentReplace($dataArr, $editPage); //function arg $dataArr = ["action" => $action, "uid" => ""]; $editPage = $VTs->ContentReplace($dataArr, $editPage); $pageContent = $editPage; break; case "updateData": $uid = $_POST["uid"]; // echo "uid: ".$uid; $arr = $VTs->json2data($VTs->UrlDataGet($apurl . "/employeemanage/getdata?uid=" . $uid . "")); if ($arr->status) { // $VTs->debug($arr); $optionData = $VTs->json2data($VTs->UrlDAtaGet($apurl . "/employeemanage/getdata?type=relationOption")); $selectElement = "<select id='relation'><option value='0'>-請選擇-</option>"; foreach ($optionData->dataList as $data) { if ($arr->dataList[0]->relation == $data->relation) { $optionElement = "<option value='" . $data->uid . "' selected>" . $data->relation . "</option>"; } else { $optionElement = "<option value='" . $data->uid . "'>" . $data->relation . "</option>"; } $selectElement .= $optionElement; } $selectElement .= "</select>"; //basicInfo $basicDataArr = ["name" => $arr->dataList[0]->name, "sid" => $arr->dataList[0]->sid, "sex" => $arr->dataList[0]->sex, "birthday" => $arr->dataList[0]->birthday]; $editPage = $VTs->ContentReplace($basicDataArr, $editPage); //address $addressDataArr = ["zip" => $arr->dataList[0]->zip, "city" => $arr->dataList[0]->city, "area" => $arr->dataList[0]->area, "vil" => $arr->dataList[0]->vil, "verge" => $arr->dataList[0]->verge, "road" => $arr->dataList[0]->road, "addr" => $arr->dataList[0]->addr]; $editPage = $VTs->ContentReplace($addressDataArr, $editPage); //commonication $communicatonDataArr = ["belong" => $arr->dataList[0]->belong, "relation" => $selectElement, "relation1" => $arr->dataList[0]->relation1, "mobile" => $arr->dataList[0]->mobile, "tel_h" => $arr->dataList[0]->tel_h, "tel_o" => $arr->dataList[0]->tel_o, "tel_ext" => $arr->dataList[0]->tel_ext, "email" => $arr->dataList[0]->email]; $editPage = $VTs->ContentReplace($communicatonDataArr, $editPage); //function arg $dataArr = ["action" => $action, "uid" => ", '" . $uid . "'"]; $editPage = $VTs->ContentReplace($dataArr, $editPage); $pageContent = $editPage; } else { $pageContent = "Query has error!"; } break; default: $pageContent = "EditPage action has error!"; } } } //----BI結束---- } catch (Exception $error) { //依據Controller, Action補上對應位置, $error->getMessage()為固定部份 $VTs->WriteLog("EmployeemanageController", "editPageAction", $error->getMessage()); } $VTs = null; $this->viewContnet['pageContent'] = $pageContent; return new ViewModel($this->viewContnet); }
public function facebooksigninAction() { $VTs = new clsSystem(); //先初始化 $VTs->initialization('oauth'); //-----------BI開始------------ //設定資訊陣列 $uidInfo = array(); $uidInfo["status"] = false; //接收已於Google驗證好的資料 if ($_POST["authResponse"]["accessToken"]) { //1. 先與Google做AccessToken的認證 $url = "https://graph.facebook.com/v2.5/me?access_token=" . $_POST["authResponse"]["accessToken"]; $facebookLoginInfo = $VTs->Json2Data($VTs->UrlDataGet($url)); $facebookUserID = $facebookLoginInfo->id; $facebookUserName = $facebookLoginInfo->name; //$VTs->debug($facebookLoginInfo); //exit(); //1-1. 確認認證無誤 if ($facebookUserID) { //2. 執行查詢看資料庫是否已有新增過 //執行查詢 $strSQL = "select * from thirdparty_oauth where thirdparty_uid = '" . $facebookUserID . "'"; $data = $VTs->QueryData($strSQL); //2-1. 沒有新增過,準備新增 if (empty($data)) { //執行新增 $strSQL = "insert into thirdparty_oauth(thirdparty_uid,userName,oauth_type, approveCode, approveStatus) values('" . $facebookUserID . "','" . $facebookUserName . "',1,'1234',0)"; $VTs->ExecuteNonQuery($strSQL); //2-2. 重新執行查詢,並取得UUID $strSQL = "select * from thirdparty_oauth where thirdparty_uid='" . $facebookUserID . "'"; $data = $VTs->QueryData($strSQL); } $uuid = $data[0]["uuid"]; //驗證USER是否已存在Token $strSQL = "select uuid from token where uuid='" . $uuid . "'"; $TokenData = $VTs->QueryData($strSQL); //產生Token,會回傳Login_Code、Access_Token $loginArr = $VTs->CreatLoginCodeAndToken($uuid); //存到Token資料表中,以供後續Oauth使用 if ($uuid) { if (empty($TokenData)) { $strSQL = "insert into token(uuid,login_code,access_token,login_from,login_type) values('" . $uuid . "','" . $loginArr["Login_Code"] . "','" . $loginArr["Access_Token"] . "','" . $_SERVER["REMOTE_ADDR"] . "',1)"; } else { $strSQL = "update token set login_code='" . $loginArr["Login_Code"] . "',access_token='" . $loginArr["Access_Token"] . "',login_from='" . $_SERVER["REMOTE_ADDR"] . "',login_date='" . date("Y-m-d H:i:s") . "' where uuid='" . $uuid . "'"; } } else { echo "System error"; exit; } //確定存取Token到資料表中 $VTs->QueryData($strSQL); //紀錄SESSION $_SESSION["uuid"] = $uuid; $_SESSION["name"] = $data[0]["userName"]; $_SESSION["mail"] = $data[0]["userMail"]; $_SESSION["LoginCode"] = $loginArr["Login_Code"]; $uidInfo["LoginCode"] = $loginArr["Login_Code"]; $uidInfo["status"] = true; } else { //1-2. 未通過驗證 $uidInfo["error"] = 'The Accound is not Sing up!'; $uidInfo["code"] = '6'; } } else { $uidInfo["error"] = 'You did not have Facebook access token!'; $uidInfo["code"] = '5'; } $this->viewContnet['pageContent'] = $VTs->Data2Json($uidInfo); //-----------BI結束------------ //關閉資料庫連線 $VTs->DBClose(); //釋放 $VTs = null; return new ViewModel($this->viewContnet); }