示例#1
0
function fonts_GetGoogleFonts()
{
    global $pdo;
    global $xmlroot;
    global $request;
    try {
        /*
        $pq = $pdo->prepare('select value from options where name="google_api_key"');
        $pq->execute();
        $r = $pq->fetchAll();
        $key = $r[0]['value'];
        */
        $key = get_option("googleapikey");
        if (strlen($key)) {
            $url = "https://www.googleapis.com/webfonts/v1/webfonts?key={$key}";
            $data = GetDataFromURL($url);
            $data = str_replace("http://", "https://", $data);
            //enforce https
            return json_decode($data, true);
        } else {
            $xmlroot->addChild("htmlAdminContent", "<p>The Google API key is not set. Please visit <a href='https://code.google.com/apis/console/' target='_blank'>https://code.google.com/apis/console/</a> to obtain an API key.</p>");
        }
    } catch (PDOException $e) {
        $error = $e->getMessage();
        $xmlroot->addChild("htmlAdminContent", "<div class='error'>DB ERROR: {$error}</div>");
    }
}
function Authenticate()
{
    /* Get Global Variable */
    global $LineLoginURL;
    global $LineAuthorizeURL;
    global $LineGetRSA;
    global $LineAccountEmail;
    global $LineAccountPassword;
    /* Line Authentication Zone */
    $LineLogin = GetDataFromURL($LineLoginURL, null, null);
    $LineLoginForm = ExtractFormByNameNoName($LineLogin);
    $GetLineRSAKey = GetDataFromURL($LineGetRSA . '?_=' . time(), null, $LineLoginURL);
    $GetLineRSAKey = json_decode($GetLineRSAKey, true);
    $LineRSAKey = explode(',', $GetLineRSAKey['rsa_key']);
    /* 
    	-----------------------------------------------
    	NEVER LINE RSA Algorithrm (Removed)
    	-----------------------------------------------
    */
    $LineLoginForm['userId'] = $LineAccountEmail;
    $LineLoginForm['id'] = $LineRSAKey[0];
    $LineLoginForm['password'] = $PasswordEncoded;
    $LineLoginForm['idProvider'] = 1;
    unset($LineLoginForm['tid']);
    unset($LineLoginForm['tpasswd']);
    unset($LineLoginForm['0']);
    unset($LineLoginForm['captcha']);
    $LineAuthorize = GetDataFromURL($LineAuthorizeURL, $LineLoginForm, $LineLoginURL);
}
示例#3
0
function fonts_AdminGetGoogleFonts()
{
    global $pdo;
    global $request;
    global $xmlroot;
    if (isset($_POST['googleapikey'])) {
        update_option("googleapikey", $_POST['googleapikey']);
    }
    if (isset($request[5]) && $request[5] == "install") {
        $gfid = $request[6];
        $font = $_SESSION['googlefonts']['items'][$gfid];
        if (isset($font['files']['regular'])) {
            $url = $font['files']['regular'];
        } else {
            if (isset($font['files']['400'])) {
                $url = $font['files']['400'];
            } else {
                $url = $font['files'][0];
            }
        }
        $pq = $pdo->prepare("select family from fonts");
        $pq->execute();
        $r = $pq->fetchAll();
        foreach ($r as $installedfont) {
            if ($font['family'] == $installedfont['family']) {
                $xmlroot->addChild("htmlAdminContent", "Error: a font named " . $font['family'] . " is already installed");
                return;
            }
        }
        if (isset($url)) {
            $type = explode(".", $url);
            $type = $type[count($type) - 1];
            $pq = $pdo->prepare("insert into fonts (family, type) values (:family,:type)");
            $pq->execute(array(":family" => $font['family'], ":type" => $type));
            $fontId = $pdo->lastInsertId();
            $data = GetDataFromURL($url);
            //$filename = realpath(dirname(__FILE__)) . "/data/$fontId.$type";
            $filename = realpath(dirname(__FILE__)) . "/data/{$fontId}";
            $fd = fopen($filename, "w");
            if ($fd) {
                fwrite($fd, $data);
                fclose($fd);
                $xmlroot->addChild("htmlAdminContent", $font['family'] . " installed.");
            } else {
                $xmlroot->addChild("htmlAdminContent", "Error saving {$filename}. Please check file permissions");
            }
        } else {
            $xmlroot->addChild("htmlAdminContent", "url missing");
        }
    } else {
        require_once "google.php";
        if (!isset($_SESSION['googlefonts'])) {
            $_SESSION['googlefonts'] = fonts_GetGoogleFonts();
        }
        $googlefonts = $_SESSION['googlefonts'];
        $googleapikey = get_option("googleapikey");
        $googleapikeyform = "<form method='post'><table><tr><td>Google API key</td>" . "<td><input name='googleapikey' value='{$googleapikey}'> </td>" . "<td><input type='submit' value='Save'></td>" . "</tr></table>";
        $xmlroot->addChild("htmlAdminContent", $googleapikeyform);
        if (isset($request[5]) && $request[5] == "page") {
            if (isset($request[6])) {
                $offset = ($request[6] - 1) * 10;
            } else {
                $offset = 0;
            }
        } else {
            $offset = 0;
        }
        for ($i = 1; $i - 1 < ceil(count($googlefonts['items']) / 10); $i++) {
            $navigator .= "  <a href='/admin/render/fonts/google/page/{$i}'>{$i}</a>";
        }
        $xmlroot->addChild("htmlAdminContent", $navigator);
        for ($i = $offset; $i < $offset + 10 && $i < count($googlefonts['items']); $i++) {
            $googlefont = $googlefonts['items'][$i];
            $family = $googlefont['family'];
            if (isset($googlefont['files']['regular'])) {
                $url = $googlefont['files']['regular'];
            } else {
                if (isset($font['files']['400'])) {
                    $url = $googlefont['files']['400'];
                } else {
                    $url = $googlefont['files'][0];
                }
            }
            $style = "@font-face { font-family : '{$family}'; src: url({$url}); }";
            $quote = "The quick brown fox jumps over the lazy dog.";
            $xmlroot->addChild("htmlAdminContent", "<div class='fontpreview'>");
            $xmlroot->addChild("htmlAdminContent", "<style>{$style}</style><div class='fontname'>{$family}</div>");
            $xmlroot->addChild("htmlAdminContent", " <a class='fontinstall' href='/admin/render/fonts/google/install/{$i}' class='font'>Install</a>");
            $xmlroot->addChild("htmlAdminContent", "<div style='font-size:24px; font-family: \"{$family}\"'>{$quote}</div>");
            $xmlroot->addChild("htmlAdminContent", "</div>");
        }
        $xmlroot->addChild("htmlAdminContent", $navigator);
    }
}
示例#4
0
                $RegisterFormData_Step4 = ExtractFormByID($RegisterToStep4, 'aspnetForm');
                $RegisterFormData_Step4['ctl00$ctl00$mainContent$PageContent$gvPendingEnroll$ctl02$ddlSection'] = SelectSubjectSection($RegisterFormData_Step3['ctl00$ctl00$mainContent$PageContent$UcFindSubject1$GridView1$ctl02$Button1'], $Subject_To_Register[$i]['SubjectSec']);
                echo "[" . getTimeNow() . "] Register Information : Select Section and Fetch Subject Status " . $Subject_To_Register[$i]['SubjectCode'] . "\n";
                $RegisterFormData_Step4['ctl00$ctl00$mainContent$PageContent$gvPendingEnroll$ctl02$ddlRegistType'] = $Subject_To_Register[$i]['SubjectCredit'];
                extractSecInfo($RegisterToStep4, $Subject_To_Register[$i]['SubjectSec']);
                unset($RegisterFormData_Step4['ctl00$ctl00$mainContent$PageContent$btnCancel']);
                $RegisterToStep5 = GetDataFromURL($SIS_URL . '/WebRegist2005/Enroll/' . $RegisterFormData_Step3['ctl00$ctl00$mainContent$PageContent$UcFindSubject1$GridView1$ctl02$Button1'], $RegisterFormData_Step4);
                $chkErrorBeforeReg = str_get_html($RegisterToStep5);
                $chkErrorBeforeSave = $chkErrorBeforeReg->find('span[id=ctl00_ctl00_mainContent_PageContent_UcAttention1_lblAttention]')[0]->innertext;
                if (!empty($chkErrorBeforeSave)) {
                    echo "[" . getTimeNow() . "] [" . $Subject_To_Register[$i]['SubjectCode'] . "] Register Error Message : (Before Confirm Register) " . explode('<br>', $chkErrorBeforeSave)[0] . "\n";
                    $failure++;
                } else {
                    echo "[" . getTimeNow() . "] Register Information : Finally enroll to subject " . $Subject_To_Register[$i]['SubjectCode'] . "\n";
                    $SemiFinalRegister = GetDataFromURL($SIS_URL . '/WebRegist2005/Enroll/EnrollDetail.aspx', null);
                    $SemiFinalFormRegister = ExtractFormHided($SemiFinalRegister, 'aspnetForm');
                    $SemiFinalFormRegister['ctl00$ctl00$mainContent$PageContent$btnConfirm'] = 'Confirm The Registration';
                    $FinalRegister = GetDataFromURL($SIS_URL . '/WebRegist2005/Enroll/EnrollDetail.aspx', $SemiFinalFormRegister);
                    echo "[" . getTimeNow() . "] [" . $Subject_To_Register[$i]['SubjectCode'] . "] Register Information : Complete!\n";
                    $success++;
                }
            }
            echo "------------------------------------------------------------------------\n";
            echo "[" . getTimeNow() . "] Registration finished :: Success: {$success} : Failure: {$failure} ::\n";
            echo "------------------------------------------------------------------------\n";
            break;
        }
    }
} else {
    echo "[" . getTimeNow() . "] Invalid PSU Passport Username or PSU Passport Password";
}