Google網頁翻譯套件

<div id="google_translate_element"></div><script type="text/javascript">

function googleTranslateElementInit() {

new google.translate.TranslateElement({pageLanguage: 'zh-TW', includedLanguages: 'en,ja,zh-TW', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');

}

</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

想拿掉小icon可以增加css

<style type="text/css">
	#google_translate_element img {
		display: none;
	}
</style>

如果想客製化自己的外觀 可參考

<div id="google_translate_element"> </div>
<div class="menu-traslate-header">
<ul>
  <li><a href="#googtrans/en">English</a></li>
  <li><a href="#googtrans/zh-TW">繁體中文</a></li>
  <li><a href="#googtrans/zh-CN">簡體中文</a></li>
  <li><a href="#googtrans/es">Español</a></li>
  <li><a href="#googtrans/vi">Việt</a></li>
  <li><a href="#googtrans/ru">Русский</a></li>
  <li><a href="#googtrans/sq">SHQIP</a></li>
  <li><a href="#googtrans/km">ខ្មែរ</a></li>
  <li><a href="#googtrans/fr">Français</a></li>
  <li><a href="#googtrans/ar">عربي</a></li>
</ul>
</div>
 <script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en', 
    includedLanguages: 'ar,en,es,fr,km,ru,sq,vi,zh-CN', 
    layout: google.translate.TranslateElement.InlineLayout.SIMPLE, 
    multilanguagePage: true, 
    gaTrack: true, 
  }, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
 <script type="text/javascript">
jQuery(document).ready(function($) {
  $('.menu-traslate-header ul li a').click(function(event) {
      window.location = $(this).attr('href');
      location.reload();
  });
});
</script>

資料來源: https://neohsuxoops.blogspot.com/2018/12/googlejs.html
資料來源: https://stackoverflow.com/questions/10486833/implementing-google-translate-with-custom-flag-icons/12999313#12999313

phpbb3 google recaptcha 機器人驗證

最近實在是被機器人 煩到受不了 三天兩頭就來給我洗整面的廣告 遺憾的事情是 phpbb3 防禦實在是無效 已經被破解光了 只好加個 google 機器人驗證了
有點硬改 沒有依照 phpbb的玩法下去 就參考吧

打開 styles/prosilver/template/ucp_register.html

搜尋
<!-- INCLUDE {CAPTCHA_TEMPLATE} --> 
後面添加

	<div class="panel">
		<div class="inner">
			<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20src%3D'https%3A%2F%2Fwww.google.com%2Frecaptcha%2Fapi.js'%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
			<div class="g-recaptcha" data-sitekey="你的htmlkey"></div>
		</div>
	</div>
打開 includes/ucp/ucp_register.php

搜尋
if ($submit)
{
後面添加

$recaptcha_secret = '你的私鑰';
$gRecaptchaResponse = request_var('g-recaptcha-response', '');
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $recaptcha_secret . "&response=" . $gRecaptchaResponse);
$response = json_decode($response, true);
if ($response["success"] !== true) {
	echo 'google recaptcha error.';
	exit;
}

申請api方式: google reCAPTCHA 機器人驗證

參考文章:
https://phpbb-tw.net/phpbb/viewtopic.php?f=176&t=54145