CGI
1sub head{ 2print "Content-type: text/html; charset=Shift_JIS\n\n"; 3print <<EOM; 4<html> 5<head> 6<link rel=stylesheet type=text/css href="$stylepath"> 7<title>$main_title</title> 8</head> 9<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> 10<script> 11 (adsbygoogle = window.adsbygoogle || []).push({ 12 google_ad_client: "ca-pub-9262824574470102", 13 enable_page_level_ads: true 14 }); 15</script> 16EOM 17if($background){ print"<body background=\"$background\">\n"; } 18else{ print"<body>\n"; } 19}
テンプレcgiに広告を追加したいのですが、以上のようにやってもうまく表示できません。どうしたら良いでしょうか。よろしくお願いします。
cgi
1# ------------ # 2# HTMLヘッダー # 3# ------------ # 4sub head{ 5print "Content-type: text/html; charset=Shift_JIS\n\n"; 6print <<EOM; 7<html> 8<head> 9<link rel=stylesheet type=text/css href="$stylepath"> 10<title>$main_title</title> 11</head> 12EOM 13if($background){ print"<body background=\"$background\">\n"; } 14else{ print"<body>\n<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> 15<script> 16 (adsbygoogle = window.adsbygoogle || []).push({ 17 google_ad_client: "ca-pub-8262824574470102", 18 enable_page_level_ads: true 19 }); 20</script>"; } 21} 22 23 24# -------------- # 25# HTMLフッターー # 26# -------------- # 27sub foot{ 28# 著作権表示です 29print <<EOM 30<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> 31<script> 32 (adsbygoogle = window.adsbygoogle || []).push({ 33 google_ad_client: "ca-pub-8262824574470102", 34 enable_page_level_ads: true 35 }); 36</script><DIV ALIGN="RIGHT"><SMALL><A HREF="http://www.minicgi.net/" target="_top">Miniりすと $ver</A></SMALL></DIV> 37</body> 38</html> 39EOM 40}
にしたらInternal Server Errorになってしまいました。
テンプレcgi とは、何でしょうか?
特定の環境の場合、環境を具体的に記載してください。
うまく表示できないとはどのような状況でしょうか?
Web ブラウザのデベロッパーツール等で確認すると どのような HTML が出力されていますか?
テンプレcgiは、miniりすと(https://www.minicgi.net/cgi2/list.html)というものです。このcgiに広告を挿入したいということです。
うまく表示できないとは、アップロードしても広告が表示されないということです。cgi自体は動作しています。
</head>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-9262824574470102",
enable_page_level_ads: true
});
</script>
<body>
と、なっていました!
あなたの回答
tips
プレビュー