67839487 by root

Merge branch 'deployment/production'

2 parents 4545836d a4667007
1 {"hash":"79e2df35bd0c42235cbe191d12011b0d"}
...\ No newline at end of file ...\ No newline at end of file
1 {"hash":"360be1890c5847863fce614473b73e8d"}
...\ No newline at end of file ...\ No newline at end of file
No preview for this file type
1 <?php
2 $url = "https://api.researchmap.jp/SNI/education";
3 // $url = "https://api.researchmap.jp/erad_id:20724818/published_papers";
4 // $url = "https://api.researchmap.jp/20724818/profile";
5 $token = "3bd6cbdc59adfbecd96bdb759b7d32e310cfba7e";
6
7 $header = array(
8 "Authorization: Bearer $token",
9 "Accept: application/ld+json,application/json;q=0.1",
10 "Accept-Encoding: gzip",
11 "Content-Type: application/json;"
12 );
13
14 $curl = curl_init($url);
15 // curl_setopt($curl, CURLOPT_POST, TRUE);
16 curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
17 // curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
18 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
19 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
20 curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
21 curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie');
22 curl_setopt($curl, CURLOPT_COOKIEFILE, 'tmp');
23 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
24 $api_responese = curl_exec($curl);
25
26 header('Content-Type: application/json; charset=utf8');
27 header('Access-Control-Allow-Origin: *');
28 echo $api_responese;
29 ?>
1 <?php
2 declare(strict_types=1);
3
4 use \Firebase\JWT\JWT;
5
6 require __DIR__ . '/vendor/autoload.php';
7
8 // .storeフォルダにアクセストークン、エラーログを出力する
9 // .storeの権限を設定する必要あり(apache or www-data)
10 $store_folder = "/var/www/.store/";
11 // 研究者番号
12 $erad_id = null;
13 if (array_key_exists('erad_id', $_GET)){
14 $erad_id = $_GET['erad_id'];
15 }
16 if (is_null($erad_id)) {
17 header('Content-Type: application/json; charset=utf8');
18 header('Access-Control-Allow-Origin: https://www.nifs-k.ac.jp');
19 print(json_encode([], JSON_FORCE_OBJECT));
20 exit;
21 }
22
23 $type = $_GET["type"];
24 $start = $_GET["start"];
25 $limit = 1000;
26
27 function api_request (string $url, array $header, string $method, ?array $post_params = null) {
28 global $store_folder;
29
30 $curl = curl_init($url);
31 $setopt_array = [
32 CURLOPT_RETURNTRANSFER => true,
33 CURLOPT_CUSTOMREQUEST => $method,
34 CURLOPT_URL => $url,
35 CURLOPT_HTTPHEADER => $header,
36 ];
37 $post_fields = '';
38 if (is_null($post_params) === false) {
39 $post_fields = http_build_query($post_params);
40 $setopt_array[CURLOPT_POSTFIELDS] = $post_fields;
41 }
42 curl_setopt_array($curl, $setopt_array);
43 $api_responese = curl_exec($curl);
44 if ($api_responese === false) {
45 // 失敗
46 $errno = curl_errno($curl);
47 $error = curl_error($curl);
48
49 $ymd = date('Ymd');
50 $file = $store_folder . "error_{$ymd}.txt";
51
52 $error_message = '[' . date('Y-m-d H:i:s') . ']'
53 . 'ErrorNo:' . $errno . "\n"
54 . 'Error:' . $error . "\n"
55 . 'URL:' . $url . "\n"
56 . 'Method:' . $method . "\n"
57 . 'header:' . print_r($header, true) . "\n"
58 . 'post_fields:' . $post_fields . "\n";
59 file_put_contents($file, $error_message, FILE_APPEND | LOCK_EX);
60 }
61 // ステータスコード取得
62 $http_status_code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
63 if (($http_status_code < 200) || ($http_status_code >= 300)) {
64 $ymd = date('Ymd');
65 $file = $store_folder . "error_{$ymd}.txt";
66 $error_message = '[' . date('Y-m-d H:i:s') . ']'
67 . 'HTTP Status Code:' . $http_status_code . "\n"
68 . 'response:' . $api_responese . "\n"
69 . 'URL:' . $url . "\n"
70 . 'Method:' . $method . "\n"
71 . 'header:' . print_r($header, true) . "\n"
72 . 'post_fields:' . $post_fields . "\n";
73 file_put_contents($file, $error_message, FILE_APPEND | LOCK_EX);
74 return false;
75 }
76 return $api_responese;
77 }
78
79 // アクセストークン
80 $access_token = null;
81 // 保存している情報からアクセストークン取得
82 $access_token_file = $store_folder . "access_token.txt";
83 if (file_exists($access_token_file)) {
84 $access_token_text = file_get_contents($access_token_file);
85 $access_token_json = json_decode($access_token_text, true);
86 if (is_null($access_token_json) === false) {
87 $expire = $access_token_json['expire'];
88 $expiration = (new DateTime())->format('U');
89 // 有効期限確認
90 if ($expiration < $expire) {
91 $access_token = $access_token_json['access_token'];
92 }
93 }
94 }
95 if (is_null($access_token)) {
96 // トークン取得URL
97 $url = 'https://api.researchmap.jp/oauth2/token';
98 // キー取得
99 $client_key = file_get_contents('/var/www/.rmap_keys/rmap_client_id.key');
100 $client_key = rtrim($client_key);
101 $private_key = file_get_contents('/var/www/.rmap_keys/rmap_jwt_private.key');
102
103 // JWTの発行時間と有効期限を設定
104 $date_time = new DateTime(date('Y-m-d H:i:s'));
105 $date_time->setTimezone(new DateTimeZone('UTC'));
106 // JWTの発行時間
107 $iat = $date_time->format('U');
108 // JWTの有効期限
109 $expiration = $date_time->modify('+30 minutes')->format('U');
110
111 $claim = [
112 'iss' => $client_key,
113 'aud' => $url,
114 'sub' => "0",
115 'exp' => $expiration,
116 'iat' => $iat
117 ];
118
119 $jwt = JWT::encode($claim, $private_key, 'RS256');
120
121 $post_params = [
122 "grant_type" => "urn:ietf:params:oauth:grant-type:jwt-bearer",
123 "assertion" => $jwt,
124 "version" => "2"
125 ];
126
127 $header = [
128 "Content-Type: application/x-www-form-urlencoded;"
129 ];
130
131 $api_responese = api_request($url, $header, 'POST', $post_params);
132 if ($api_responese) {
133 $response = json_decode($api_responese, true);
134 $access_token = $response['access_token'];
135 $response['expire'] = $expiration;
136 file_put_contents($access_token_file, json_encode($response));
137 }
138 }
139 // プロフィール情報取得
140 $profile = [];
141 if (is_null($access_token) === false) {
142 $url = "https://api.researchmap.jp/erad_id:{$erad_id}";
143 if (!empty($type)) {
144 $url = $url . '/' . $type . '?limit=' . $limit;
145 };
146
147 if (!empty($start)) {
148 $url = $url . '&start=' . $start;
149 }
150
151 $header = array(
152 "Authorization: Bearer $access_token",
153 "Accept: application/ld+json,application/json;q=0.1",
154 "Accept-Encoding: gzip",
155 // "X-HTTP-Method-Override: GET",
156 // "Content-Type: application/json;"
157 // "Content-Type: application/x-www-form-urlencoded;"
158 );
159 $api_responese = api_request($url, $header, 'GET', null);
160 if ($api_responese) {
161 $profile = json_decode($api_responese, true);
162 }
163 }
164 header('Content-Type: application/json; charset=utf8');
165 header('Access-Control-Allow-Origin: https://www.nifs-k.ac.jp');
166 print(json_encode($profile, JSON_FORCE_OBJECT));
1 <?php
2 require_once('./vendor/autoload.php');
3
4 use \Firebase\JWT\JWT;
5
6 $url = 'https://api.researchmap.jp/oauth2/token';
7 $client_key = file_get_contents('/var/www/.rmap_keys/rmap_client_id.key');
8 $client_key = rtrim($client_key);
9 $private_key = file_get_contents('/var/www/.rmap_keys/rmap_jwt_private.key');
10
11 # 時刻
12 $now = time();
13 $hour = date('H', $now);
14 $min = date('m', $now);
15 $sec = date('s', $now);
16 $year = date('Y', $now);
17 $month = date('m', $now);
18 $day = date('d', $now);
19 $date = mktime($hour, $min, $sec, $month, $day, $year);
20 $expiration = mktime(0, 0, 0, $month, $day+1, $year);
21
22 $claim = Array(
23 'iss' => $client_key,
24 'aud' => $url,
25 'sub' => "0",
26 'exp' => $expiration,
27 'iat' => $date
28 );
29
30 $jwt = JWT::encode($claim, $private_key, 'RS256');
31
32 $data = Array(
33 "grant_type" => "urn:ietf:params:oauth:grant-type:jwt-bearer",
34 "assertion" => $jwt,
35 // "scope" => "researchers write",
36 "version" => "2"
37 );
38
39 $header = array(
40 "Content-Type: application/x-www-form-urlencoded;"
41 );
42
43 $curl = curl_init($url);
44 curl_setopt($curl, CURLOPT_POST, TRUE);
45 curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
46 curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
47 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
48 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
49 curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
50 curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie');
51 curl_setopt($curl, CURLOPT_COOKIEFILE, 'tmp');
52 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
53 $api_responese = curl_exec($curl);
54
55 header('Content-Type: application/json; charset=utf8');
56 header('Access-Control-Allow-Origin: *');
57 echo $api_responese;
58 ?>
1 <!DOCTYPE html>
2 <html lang="en">
3
4 <head>
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>Document</title>
8 <script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
9 crossorigin="anonymous"></script>
10 </head>
11
12 <body>
13
14 </body>
15 <script>
16 const tokenUrl = 'https://www.nifs-k.ac.jp/rmap/getToken.php';
17 let rmToken = JSON.parse(localStorage.getItem('rmToken'));
18
19 // トークン未取得 or 有効期限切れ
20 if (!rmToken) {
21 getToken();
22 } else {
23 const expDate = new Date(rmToken.exp);
24 const now = new Date();
25 if (expDate > now) {
26 getToken();
27 } else {
28 console.log(rmToken);
29 }
30 }
31
32 function getToken() {
33 $.ajax({
34 type: 'GET',
35 url: tokenUrl,
36 dataType: 'json',
37 headers: {
38 // 'Authorization': `Bearer ${token}`,
39 // 'Accept': 'application/ld+json,application/json;q=0.1',
40 // 'Accept-Encoding': 'gzip',
41 'Content-Type': 'application/json;'
42 },
43 success: function (data) {
44 const now = new Date();
45 const exp = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes() + 55);
46 rmToken = {
47 token: data.access_token,
48 exp: exp
49 };
50 localStorage.setItem('rmToken', JSON.stringify(rmToken));
51 console.log(rmToken);
52 }
53 });
54 }
55
56 </script>
57
58 </html>
...\ No newline at end of file ...\ No newline at end of file
...@@ -608,6 +608,7 @@ if ($this->params->get('logoFile')) { ...@@ -608,6 +608,7 @@ if ($this->params->get('logoFile')) {
608 <li><a href="/outline/feel-approach-program/sports-performance.html" title="スポーツパフォーマンス研究">スポーツパフォーマンス研究</a></li> 608 <li><a href="/outline/feel-approach-program/sports-performance.html" title="スポーツパフォーマンス研究">スポーツパフォーマンス研究</a></li>
609 <li><a href="/outline/feel-approach-program/nifisa.html" title="スポーツ・アカデミー形成支援事業">スポーツ・アカデミー形成支援事業</a></li> 609 <li><a href="/outline/feel-approach-program/nifisa.html" title="スポーツ・アカデミー形成支援事業">スポーツ・アカデミー形成支援事業</a></li>
610 <li><a href="/outline/feel-approach-program/ap-program.html" title="大学教育加速プログラム">大学教育加速プログラム</a></li> 610 <li><a href="/outline/feel-approach-program/ap-program.html" title="大学教育加速プログラム">大学教育加速プログラム</a></li>
611 <li><a href="/outline/feel-approach-program/discretion/discretion.html" title="重点プロジェクト事業経費(学長裁量経費)">重点プロジェクト事業経費<br>(学長裁量経費)</a></li>
611 <li><a href="/outline/feel-approach-program/past-efforts.html" title="過去の取組">過去の取組</a></li> 612 <li><a href="/outline/feel-approach-program/past-efforts.html" title="過去の取組">過去の取組</a></li>
612 </ul> 613 </ul>
613 <div class="title"><a href="public/bid.html">入札情報等</a></div> 614 <div class="title"><a href="public/bid.html">入札情報等</a></div>
...@@ -821,6 +822,10 @@ if ($this->params->get('logoFile')) { ...@@ -821,6 +822,10 @@ if ($this->params->get('logoFile')) {
821 <li><a href="/faculties/thesis/exam.html" title="論文博士の論文提出に係る外国語試験の実施について">論文博士の論文提出に係る外国語試験の実施について</a></li> 822 <li><a href="/faculties/thesis/exam.html" title="論文博士の論文提出に係る外国語試験の実施について">論文博士の論文提出に係る外国語試験の実施について</a></li>
822 <li><a href="/faculties/thesis/degrees.html" title="論文博士の学位論文について">論文博士の学位論文について</a></li> 823 <li><a href="/faculties/thesis/degrees.html" title="論文博士の学位論文について">論文博士の学位論文について</a></li>
823 </ul> 824 </ul>
825 <div class="title"><a href="/faculties/questionnaire.html">大学教育の満足度アンケート調査結果</a></div>
826 <ul>
827 <li><a href="/faculties/questionnaire/questionnaire.html" title="アンケート調査結果">アンケート調査結果</a></li>
828 </ul>
824 </div> 829 </div>
825 <!-- ▲4列目 --> 830 <!-- ▲4列目 -->
826 831
...@@ -1040,6 +1045,7 @@ if ($this->params->get('logoFile')) { ...@@ -1040,6 +1045,7 @@ if ($this->params->get('logoFile')) {
1040 <div class="title"><a href="/property/ssc.html">スポーツサイエンスキャンプ</a></div> 1045 <div class="title"><a href="/property/ssc.html">スポーツサイエンスキャンプ</a></div>
1041 <div class="title"><a href="/property/tokyo-satellite-campus.html">東京サテライトキャンパス</a></div> 1046 <div class="title"><a href="/property/tokyo-satellite-campus.html">東京サテライトキャンパス</a></div>
1042 <div class="title"><a href="property/workshop.html">教員免許状更新講習プログラム 詳細</a></div> 1047 <div class="title"><a href="property/workshop.html">教員免許状更新講習プログラム 詳細</a></div>
1048 <div class="title"><a href="/property/open-project.html">大学開放事業</a></div>
1043 <!-- ▲4列目 --> 1049 <!-- ▲4列目 -->
1044 1050
1045 </div> 1051 </div>
......
...@@ -2213,7 +2213,7 @@ body.itemid-101 #c_wrap { ...@@ -2213,7 +2213,7 @@ body.itemid-101 #c_wrap {
2213 /* ▼スマホで横長テーブルが切れるのを回避する */ 2213 /* ▼スマホで横長テーブルが切れるのを回避する */
2214 .scroll { 2214 .scroll {
2215 overflow: auto; 2215 overflow: auto;
2216 /*white-space: nowrap;*/ 2216 white-space: nowrap;
2217 } 2217 }
2218 .scroll::-webkit-scrollbar{  /*tableにスクロールバーを追加*/ 2218 .scroll::-webkit-scrollbar{  /*tableにスクロールバーを追加*/
2219 height: 5px; 2219 height: 5px;
......
...@@ -47,7 +47,7 @@ JHtml::_('script', 'template.js', array('version' => 'auto', 'relative' => true) ...@@ -47,7 +47,7 @@ JHtml::_('script', 'template.js', array('version' => 'auto', 'relative' => true)
47 JHtml::_('script', 'jui/html5.js', array('version' => 'auto', 'relative' => true, 'conditional' => 'lt IE 9')); 47 JHtml::_('script', 'jui/html5.js', array('version' => 'auto', 'relative' => true, 'conditional' => 'lt IE 9'));
48 48
49 // Add Stylesheets 49 // Add Stylesheets
50 JHtml::_('stylesheet', 'template.css', array('version' => '20200625001', 'relative' => true)); 50 JHtml::_('stylesheet', 'template.css', array('version' => '20201104001', 'relative' => true));
51 51
52 52
53 // Use of Google Font 53 // Use of Google Font
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!