- Jan 06 Fri 2023 13:35
-
Day 1 在Windows安裝Python,並撰寫第一個程式
- Sep 09 Thu 2021 13:51
-
Day 2 在Windows安裝Composer
- Sep 08 Wed 2021 17:48
-
Day 1 使用XAMPP在Windows安裝PHP環境
- Jun 21 Tue 2022 20:02
-
【食譜】紅燒番茄牛肉麵 | 紅小萬料理
- Jun 05 Sun 2022 22:00
-
【開箱】Roborock S7 MaxV Ultra | 掃地機界真王者 | 自動集塵 補水 洗拖布 抬升拖布風乾 | 真正解放雙手

「科技始終來自於惰性」,石頭科技於2022年推出全新的掃拖機器人 S7 MaxV Ultra,擁有五項全自動、六合一清潔座、5100Pa吸力,稱為掃地界真王者一點也不為過。
因為是第一批倒數的名單,在社團中看到許多人已經分享心得,有些人因為物流關係只先收到一箱,心想這也太難熬了。幸運的是於周六一早順利收到兩箱,收到商品後迫不及待進行開箱,馬上進行配對、充電 (注意商品第一次使用要先充飽電)。
- Sep 09 Thu 2021 17:24
-
判斷網址是否有效
$url = 'https://moyunhost.pixnet.net';
$executeTime = ini_get('max_execution_time');
ini_set('max_execution_time', 0);
$headers = @get_headers($url);
ini_set('max_execution_time', $executeTime);
if($headers){
$head = explode(' ', $headers[0]);
if(!empty($head[1]) && intval($head[1]) < 400) $return = true;
}else{
$return = false;
}
$executeTime = ini_get('max_execution_time');
ini_set('max_execution_time', 0);
$headers = @get_headers($url);
ini_set('max_execution_time', $executeTime);
if($headers){
$head = explode(' ', $headers[0]);
if(!empty($head[1]) && intval($head[1]) < 400) $return = true;
}else{
$return = false;
}
- Sep 09 Thu 2021 17:07
-
根據ip判斷地區(採用第三方ip-api)
protected function CheckIP(){
$ch = curl_init();
$timeout = 5;
$ip = $_SERVER['HTTP_HOST'];
$url = "http://ip-api.com/json/{$ip}?fields=country";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$fileContents = curl_exec($ch);
curl_close($ch);
$fileContents = json_decode($fileContents, true);
if($fileContents["country"] == 'Taiwan') show_404();
}
$ch = curl_init();
$timeout = 5;
$ip = $_SERVER['HTTP_HOST'];
$url = "http://ip-api.com/json/{$ip}?fields=country";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$fileContents = curl_exec($ch);
curl_close($ch);
$fileContents = json_decode($fileContents, true);
if($fileContents["country"] == 'Taiwan') show_404();
}
- Sep 09 Thu 2021 16:55
-
資料庫編碼轉換
一、資料庫一次轉換所有資料表編碼
$conn = new MySQLi("localhost","資料庫帳號","資料庫密碼","資料庫名稱");
if($conn->connect_errno){
echo mysqli_connect_error();
exit;
}
$res=$conn->query("show tables") or die($conn->error);
while($tables=$res->fetch_array()){
$conn->query("ALTER TABLE $tables[0] CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci") or die($conn->error);
}
echo "The collation of your database has been successfully changed!";
$res->free();
$conn->close();
$conn = new MySQLi("localhost","資料庫帳號","資料庫密碼","資料庫名稱");
if($conn->connect_errno){
echo mysqli_connect_error();
exit;
}
$res=$conn->query("show tables") or die($conn->error);
while($tables=$res->fetch_array()){
$conn->query("ALTER TABLE $tables[0] CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci") or die($conn->error);
}
echo "The collation of your database has been successfully changed!";
$res->free();
$conn->close();
- Sep 09 Thu 2021 16:34
-
SESSION轉換為COOKIE
ini_set('session.use_cookies','1');
ini_set('session.gc_divisor','1');
ini_set('session.cookie_path', '/');
ini_set('session.cookie_lifetime','2592000');
ini_set('session.gc_maxlifetime','2592000');
$lifetime = 60*60*24*30; //單位秒,3600秒=1小時
session_save_path($_SERVER['DOCUMENT_ROOT'].'/sessions');//主機需將session轉移到我們自己設定的目錄儲存
if (isset($_COOKIE['PHPSESSID'])) {
session_id($_COOKIE['PHPSESSID']);// 重置該頁面的ssesion_id
session_set_cookie_params($lifetime);
@session_start();
}else{
@session_start();
setcookie(session_name(), session_id(), time() + $lifetime);
}
ini_set('session.gc_divisor','1');
ini_set('session.cookie_path', '/');
ini_set('session.cookie_lifetime','2592000');
ini_set('session.gc_maxlifetime','2592000');
$lifetime = 60*60*24*30; //單位秒,3600秒=1小時
session_save_path($_SERVER['DOCUMENT_ROOT'].'/sessions');//主機需將session轉移到我們自己設定的目錄儲存
if (isset($_COOKIE['PHPSESSID'])) {
session_id($_COOKIE['PHPSESSID']);// 重置該頁面的ssesion_id
session_set_cookie_params($lifetime);
@session_start();
}else{
@session_start();
setcookie(session_name(), session_id(), time() + $lifetime);
}
1



