"; global $wpdb; // Check if form has been submitted if (isset($_POST['submit'])) { // Get email addresses and expiration from input area $email_list = $_POST['email_list']; // Replace with the name of your input field $emails = explode("\n", $email_list); // Split input into an array of email addresses //echo "
";print_r( $emails ); echo "
"; $delimiter = "/[\s\t]+/"; // Regular expression to match one or more spaces or tabs // Checking data $clean_data = array(); // The array holds clean or sanitized data. $error_data = array(); // The array holds error data. $pattern = "/^\d{4}-\d{2}-\d{2}$/"; foreach ($emails as $email) { $ary_email_expiration = preg_split($delimiter, $email); [$email,$expiration,$event] = array_slice($ary_email_expiration, 0 ,3); //echo $email ." " .$expiration ."
"; $email = trim($email); // Remove any leading or trailing whitespace $email = strtolower($email);//converts an email address to lowercase $expiration = trim($expiration);// Check expiration format is YYYY-mm-dd $replay_conf2023=0; //$replay_summer=0; // Validation email if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ $error_data[]=array($email, $expiration, $replay_conf2023/*, $replay_summer*/); continue; } // Validation expiration if (!preg_match($pattern, $expiration)) { $error_data[]=array($email, $expiration, $replay_conf2023/*, $replay_summer*/); continue; } //Check event if(strpos("conf2023",$event)!==false){ $replay_conf2023=1; } /*if(strpos("夏",$event)!==false){ $replay_summer=1; }*/ // Data is clean $clean_data[]=array($email, $expiration, $replay_conf2023/*, $replay_summer*/); } //echo "clean_data:
";print_r( $clean_data ); echo "
"; //echo "error_data:
";print_r( $error_data ); echo "
"; //if error_data not empty then die; if(count($error_data)>0){ echo "資料有誤,請檢查後重新匯入( 返回上一頁 )
"; foreach($error_data as $row){ echo '' .implode("\t",$row) ."
"; } die(); }; //insert data and check email duplicate foreach ($clean_data as $row) { [$email, $expiration, $replay_conf2023/*, $replay_summer*/] = $row; $hash_email = substr(hash('sha256', $email), 0, 40); $wpdb->insert( 'conf2023_purchaser_online_replay', array( 'email' => $hash_email, 'expiration' => $expiration, 'replay_conf2023' => $replay_conf2023, //'replay_summer' => $replay_summer, ), array( '%s','%s','%d','%d' ) ); if (empty($wpdb->last_error)) { // Insertion was successful echo "成功匯入\t" .$email ."\t" .$hash_email ."\t" .$expiration."
"; } else { // Duplicate key error or other error occurred echo " 匯入失敗, Email: " .$email ." 已經被使用或是其他錯誤發生( 錯誤提示: " .$wpdb->last_error ." )
"; } } // Display success message echo '

所有 Email 皆已處理完

'; echo ' 返回上一頁 '; die(); } ?>

輸日 Email 及 有效期限

一列一筆資料,每筆資料包含 郵件 有效日期 ( 格式:YYYY-mm-dd ) 場次(conf2023/) ,以 tab 或 空格連接。範例如下:

abc123@gmail.com 2023-06-30 conf2023
def456@gmail.com 2023-06-30 conf2023


Email 查詢

一列一筆 Email:

abc123@gmail.com
def456@gmail.com


";print_r($hash_email_list);echo ""; // echo $sql_where_string; $results = $wpdb->get_results("SELECT * FROM conf2023_purchaser_online_replay". $sql_where_string); //echo "
";print_r($resultes) ;echo "999
"; if ($results) { foreach ($results as $row) { //取得 hash_email $hash_email_list[$row->email][2] = $row->expiration; $hash_email_list[$row->email][3] = $row->replay_conf2023; //$hash_email_list[$row->email][4] = $row->replay_summer; } } //echo "
";print_r($hash_email_list);echo "
"; } ?>
hash_Email Email 到期日 conf2023