user_login){
die('Please login this website first.');
}
/*
# get_all_google_spreadsheet_for_courses.php
$a = [];
foreach(get_posts('category='.CALENDAR_CAT_ID.'&posts_per_page=-1')as$v){
$s = $v->post_content;
preg_match_all('/\[week_course .*]/', $s, $m);
if(!isset($m[0]) or !$m[0]){continue;}
foreach($m[0] as$_){
preg_match_all('/ d=.*?[ \]]/', $_, $x);
preg_match_all('/ gid=.*?[ \]]/', $_, $y);
if(!isset($x[0][0]) or !$x[0][0] or !isset($y[0][0]) or !$y[0][0]){continue;}
$doc = trim($x[0][0]); $doc = substr($doc,2);
$gid = trim($y[0][0]); $gid = substr($gid,4);
$doc = str_replace(['"', "'", ']'], '', $doc);
$gid = str_replace(['"', "'", ']'], '', $gid);
$a[] = $doc.'```'.$gid;
}
}
$a = array_unique($a);
print_r($a);
echo'';
*/
?>
更新課程表表格內容 Update calendar table
Please input d and gid!';
}else{
//
//$spreadsheetId = '1-YDHd-5o0fbHFBbmVgOz792m_V8j9s9FfSgR1AepdTc';
//$range = '課程總覽!A:G';
// $response = $service->spreadsheets_values->get($spreadsheetId, $range);
// $values = $response->getValues();
// print_r($values);
// foreach ($values as $row) {
// // 對讀取的每一行進行處理
// print_r($row);
// }
#echo $doc; echo $gid;
$ary_gid = explode(',', $gid);
foreach($ary_gid as $gid){
if(0===preg_match('/^[0-9]+$/',$gid)){continue;}
//$url = 'https://docs.google.com/spreadsheets/d/'.$doc.'/export?format=csv&gid='.$gid;
$fn = __DIR__ . '/cache4calendar/'.$doc.'```'.$gid.'.cache';
require_once 'google_apiclient/vendor/autoload.php';
$client = new Google_Client();
$client->setAuthConfig("/data/www/google_service_account_key__+-?e1/aia-courses-d87ec0f4cbdf.json");
$client->addScope(Google_Service_Sheets::SPREADSHEETS);
$service = new Google_Service_Sheets($client);
require_once "google_apiclient/google_api_connection.php";
get_sheet_name_by_gid($service,$doc,$gid,$fn);
//$s = file_get_contents($url);
//file_put_contents($fn, $s);
echo'Updated for gid='.$gid.'
';
}
echo'Updated! Please review and re-check the '.$_SERVER['SERVER_NAME'].'/calendar-XXXXX/ webpage. If still fail, please contact Web Developer.
';
}
}else{
$doc = isset($_GET['d']) ? $_GET['d'] : '';
$gid = isset($_GET['gid']) ? $_GET['gid'] : '';
}
?>
[您現正在 站 ](測試中)
使用本頁,你可以不再公開試算表的權限。。
更新 站 之課程表表格內容 Update calendar table:
請輸入 d 與 gid。 Please input the d and gid.
For example, if the one sheet you edited just now is https://docs.google.com/spreadsheets/d/vD2XA8j14FNfWvD4wvNgs7X-uXdICpEuo/edit#gid=689479925,
then the blue text is for "d" and the green text is for "gid"
-------------------------------
created at 2021.1.30