back');}
$name=isset($_POST['name']) ? trim($_POST['name']) : '';
$email=isset($_POST['email']) ? normalize_aia_email($_POST['email']) : '';
if(!$class or !$name or !$email){
die('請輸入所有欄位。上一頁');
}
$name_hashed = AmIStudent::get_username_encodehash($name);
$email_hashed = AmIStudent::get_email_encodehash(trim(strtolower($email))); #MUST lowercase email
$row = $wpdb->get_row('SELECT * FROM '.TBL_AM_I_STUDENT.' WHERE `name_hashed`="'.$name_hashed.'" AND `email_hashed`="'.$email_hashed.'" AND xlass="'.$class.'"');
if(!$row){
die('找不到紀錄。若您確定有報名「'.$ary[$class]['txt'].'」,請來信 '.$ary[$class]['_contact'].' 確認您的報名Email與報名姓名。');
}
$doc = $ary[$class]['doc'];
$gid = $ary[$class]['gid'];
$spreadsheet_content = file_get_contents('https://docs.google.com/spreadsheets/d/'.$doc.'/export?format=tsv&gid='.$gid);
$ary_spreadsheet_content = preg_split("/(\r\n|\n|\r)/",$spreadsheet_content);
foreach($ary_spreadsheet_content as$k=>$v){
$n = $k+1;
if($n==$row->row_position){
$_ = explode("\t", $v);
$name_public = $row->name_public;
$status = $_[0]; break;
}
}
} // end if($_POST)
?>
學生查詢錄取/備取/不錄取
$v){
if($k==$class){
$class_txt = $v['txt'];
$class_place = $v['_place'];
$class_num = $v['_num'];
$class_type = $v['_type'];
$class_contact = $v['_contact'];
break;
}
}
echo'';
echo'Hi '.$name_public.', 您報名「'.$class_txt.'」的錄取/備取/未錄取狀態:
';
$CAT_ID = 0;
if(strpos($status,'P')!==false and strpos($status,'B')===false){
echo '恭喜已錄取。
';
$CAT_ID = PASS_STUDENT_CAT_ID;
}elseif(strpos($status,'F')!==false){
echo '非常抱歉,我們無法在本期錄取您。
';
$CAT_ID = FAIL_STUDENT_CAT_ID;
}elseif(strpos($status,'B')!==false){
preg_match('/B([0-9]+)/', $status, $m);
if(!$m or !$m[1]){
echo'unknow, please contact hi@aiacademy.tw';
}else{
$num_of_passed_B = 0;
foreach($ary_spreadsheet_content as$v){
$_ = explode("\t", $v);
$_0 = $_[0];
if(strpos($_0, 'B')!==false and strpos($_0, 'P')!==false){
$num_of_passed_B++;
}
}
echo '目前備取進度: '.$num_of_passed_B.'
';
echo '您的備取號碼: '.$m[1].'
';
$CAT_ID = BACKUP_STUDENT_CAT_ID;
if($num_of_passed_B>=$m[1]){
echo'--目前備取已備到,等同錄取-- (您已被通知遞補,若未收到通知信件,請即與我們聯繫 '.$class_contact.'。)
';
$CAT_ID = PASS_FROM_BACKUP_STUDENT_CAT_ID;
}
}
}
#
$posts = get_posts(array('category'=>$CAT_ID, 'fields'=>'ids','post_status'=>'private'));
$post_content = null;
foreach($posts as$post_id){
if($class_place==get_post_meta($post_id, 'class_place',true)
and $class_num==get_post_meta($post_id,'class_num',true)
and $class_type==get_post_meta($post_id,'class_type',true)
){
$post = get_post($post_id);
if($post){$post_content = $post->post_content;}
break;
}
}
if($post_content){
echo$post_content;
}else{
echo'No more content.';
}
#echo'#'.$status.''; #debug code
exit;
} ?>
查詢報名審核結果: