document.write("width:"+screen.width+"<br>"); document.write("height:"+screen.height+"<br>");
書き方を変えます。
var screen = screen.width +"x" + screen.height; document.write(screen);
iphone xの場合
jsに入れる
繋げる
いいんじゃない
まずtopページは大体こんな感じ。
次はトラッキングコードの画面
随机应变 ABCD: Always Be Coding and … : хороший
document.write("width:"+screen.width+"<br>"); document.write("height:"+screen.height+"<br>");
書き方を変えます。
var screen = screen.width +"x" + screen.height; document.write(screen);
iphone xの場合
jsに入れる
繋げる
いいんじゃない
まずtopページは大体こんな感じ。
次はトラッキングコードの画面
google.comのhost名をgethostbyaddrを使うと、
$url = "www.google.com"; $ip = "172.217.161.196"; $host = gethostbyaddr($ip); echo $host;
きたー、ラリー・ページの10^100
なんか知らんが嬉しいね
www.nttdocomo.co.jp
ip:163.49.61.185
gethostbyaddr:185.61.49.163.static.iijgio.jp
え、iij使ってるの?
www.fsa.go.jp
ip:151.101.101.14
gethostbyaddr:151.101.101.14
金融庁、財務省、などはgethostbyaddrでipしか表示されない。
rakuten->deploy.static.akamaitechnologies.com
nttdata(184.27.113.234)->a184-27-113-234.deploy.static.akamaitechnologies.com
ん?どういうこと、これ?akamaitechnologiesってそんなにいいの?
gaだと、service providerは細かく表示されているので、恐らくプロバイダーのデータベースを持ってると思うんだが、、
あれ?
GeoIP ISP Edition
https://www.maxmind.com/ja/geoip2-isp-database
やっぱり。。しかしip周りの領域は、なにかとmaxmindと被るな。
service providerは、DBないとかなりキツイな~、というか関数自作は無理がある。。
ので、
$ip = "192.168.33.1"; $host = gethostbyaddr($ip); if($host == $ip){ $gethost = "(not set)"; } else { $gethost = $host; } echo $gethost;
よしよしよし
次は画面サイズ(screen resolution)
これはjsでいけると思います。
<script src="platformjs/platform.js"></script> <script type="text/javascript"> document.write(platform.name + "<br>"); document.write(platform.version + "<br>"); document.write(platform.os + "<br>"); </script>
うーん、gaだと、windowsまでだが、osのバージョンまで出てしまう。。。
consoleでみると、jsonのfamilyで入っているので、
<script src="platformjs/platform.js"></script> <script type="text/javascript"> // document.write(platform.name + "<br>"); // document.write(platform.version + "<br>"); document.write(platform.os['family'] + "<br>"); </script>
芸が細かいな。。
$.getScript("../platformjs/platform.js", function(){ a.push(['browser',platform.name]); a.push(['os',platform.os['family']]); });
ほい!
最後は謎の”service provider”
geoip_isp_by_nameは動かない。。
プロバイダ:インターネットへの接続サービスを提供する事業者。
->ゲートウェイ?
どうやらgethostbyaddr($ip);っぽいですな。
na.jsはjqueryを読み込んでいるので、GETリクエストでplatform.jsを読み込みコールバック関数で実行
$.getScript("../platformjs/platform.js", function(){ a.push(['browser',platform.name]); });
chromeを取得できてますね。
ieだと、ブラウザ情報がIEになってます。
mongoDBにも、”browser” : “IE”で入ってます! OKOK!
{ "_id" : ObjectId("5ae48224e13823435337fd94"), "date" : "2018-04-28 23:16:04", "ip" : "192.168.33.1", "cookie" : "y28mw6ppl3", "visit" : "New User", "referrer" : "", "session" : "y28mw6ppl3", "page" : "/wwwroot/view.php", "browser" : "IE", "continent" : "Asia", "contry" : "Japan", "city" : "Komagatani" }
そのままの勢いでviewも作ります。
良し!Nice!
次はOS
platform.js
https://github.com/bestiejs/platform.js
作った方
John-David Dalton
JavaScript tinkerer, bug fixer, & benchmark runner • Creator of Lodash • Former Chakra Perf PM • Current Web Platform DX PM @Microsoft
出たー、@Microsoft!
またかよ、このパターン。。。
それはさておき、git cloneします。
[vagrant@localhost cookie]$ git clone https://github.com/bestiejs/platform.js.git Cloning into 'platform.js'... remote: Counting objects: 2138, done. remote: Compressing objects: 100% (2/2), done. remote: Total 2138 (delta 2), reused 1 (delta 1), pack-reused 2135 Receiving objects: 100% (2138/2138), 3.69 MiB | 880.00 KiB/s, done. Resolving deltas: 100% (1276/1276), done. Checking connectivity... done.
入りました。
早速使ってみます。
<script src="platformjs/platform.js"></script> <script type="text/javascript"> document.write(platform.name + "<br>"); document.write(platform.version + "<br>"); </script>
これこれ、求めてたの!
IEで見てみると、
素晴らしい!
ついでに、platform.jsの中身もざっと見てみます。このへんで、labelingしてます。
/* Detectable browser names (order is important). */ var name = getName([ 'Adobe AIR', 'Arora', 'Avant Browser', 'Breach', 'Camino', 'Electron', 'Epiphany', 'Fennec', 'Flock', 'Galeon', 'GreenBrowser', 'iCab', 'Iceweasel', 'K-Meleon', 'Konqueror', 'Lunascape', 'Maxthon', { 'label': 'Microsoft Edge', 'pattern': 'Edge' }, 'Midori', 'Nook Browser', 'PaleMoon', 'PhantomJS', 'Raven', 'Rekonq', 'RockMelt', { 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' }, 'SeaMonkey', { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' }, 'Sleipnir', 'SlimBrowser', { 'label': 'SRWare Iron', 'pattern': 'Iron' }, 'Sunrise', 'Swiftfox', 'Waterfox', 'WebPositive', 'Opera Mini', { 'label': 'Opera Mini', 'pattern': 'OPiOS' }, 'Opera', { 'label': 'Opera', 'pattern': 'OPR' }, 'Chrome', { 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' }, { 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' }, { 'label': 'Firefox for iOS', 'pattern': 'FxiOS' }, { 'label': 'IE', 'pattern': 'IEMobile' }, { 'label': 'IE', 'pattern': 'MSIE' }, 'Safari' ]);
line79-81に以下のように書かれています。
// Platform tokens are defined at:
// http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
// http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
これまた凄いな、ホントに。
http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
<script type="text/javascript"> document.write(navigator.appCodeName + "<br>"); document.write(navigator.appName + "<br>"); document.write(navigator.appVersion + "<br>"); document.write(navigator.platform + "<br>"); document.write(navigator.userAgent + "<br>"); </script>
chromeで見てるから、chromeと出力させたいんだが、何故mozilla、Netscapeなんだ????
仕組みが分からん。
getパラメーターの値で表示を切り替えます。
<table> <?php if($_GET["selectedDimension"] == 'continent'): ?> <th>Continent</th><th>Users</th> <?php $i = 0; foreach($c1 as $key => $value){ if($i < 10){ echo "<tr>"; echo "<td>".$key."</td><td>".$value."</td>"; echo "</tr>"; } $i++; } ?> </table> <?php elseif($_GET["selectedDimension"] == 'country'): ?> <th>Country</th><th>Users</th> <?php $i = 0; foreach($c2 as $key => $value){ if($i < 10){ echo "<tr>"; echo "<td>".$key."</td><td>".$value."</td>"; echo "</tr>"; } $i++; } ?> </table> <?php elseif($_GET["selectedDimension"] == 'city'): ?> <th>City</th><th>Users</th> <?php $i = 0; foreach($c3 as $key => $value){ if($i < 10){ echo "<tr>"; echo "<td>".$key."</td><td>".$value."</td>"; echo "</tr>"; } $i++; } ?> </table> <?php else: ?> <th>Page</th><th>PageView</th> <?php $i = 0; foreach($data as $key => $value){ if($i < 10){ echo "<tr>"; echo "<td>".$key."</td><td>".$value."</td>"; echo "</tr>"; } $i++; } ?> </table> <?php endif; ?>
continent
country
city
一人デバックしてるなー
というか、これ、ページビュー単位ではなくて、cookie単位しないと駄目だ
うおおおおおおお、結構複雑だ
cookieに重複がない場合だけ、ipの地域を取得するに変更
foreachの前で$cookie=array();と宣言します。
$cookie = array(); foreach ($cursor as $document) { $pv[] = $document->date; if(!in_array($document->cookie, $cookie)){ if(!is_null($document->continent)){ $c1[] = $document->continent; } if(!is_null($document->contry)){ $c2[] = $document->contry; } if(!is_null($document->city)){ $c3[] = $document->city; } } $cookie[] = $document->cookie; $session[] = $document->session; if(!is_null($document->referrer)){ $avgtime[] = $document->avgtime; } if(!is_null($document->referrer)){ $referrer[] = $document->referrer; } $visit[] = $document->visit; $access[] = substr($document->date, 11, 2); $page[] = $document->page; }
continent, country, cityがuniqueになりました。
よっしゃ、ip周りはOKそう。
次は、browser, os, service provider
これ、js、phpでとれるんか?
取れなければ、スキップとしたい。が、GAでは必ず見る項目ではある。。
日付のパラメーターがついていた場合には、それに地域パラメータを加えてリンクさせる。
if(isset($_GET['_udate00'])&&isset($_GET['_udate01'])) { $date1 = $_GET['_udate00']; $date2 = $_GET['_udate01'] . " 23:59:59"; $continent = "?_udate00".$_GET['_udate00']."&_udate01=".$_GET['_udate01']."&selectedDimension=continent"; $contry = "?_udate00".$_GET['_udate00']."&_udate01=".$_GET['_udate01']."&selectedDimension=contry"; $city = "?_udate00".$_GET['_udate00']."&_udate01=".$_GET['_udate01']."&selectedDimension=city"; } else { $date1 = date("Y-m-d", strtotime("-10 day")); $date2 = date("Y-m-d H:i:s"); $continent = "?selectedDimension=continent"; $contry = "?selectedDimension=contry"; $city = "?selectedDimension=city"; } if(isset($_GET['selectedDimension'])){ $c = $_GET['selectedDimension']; }
datepickerのformでは、hiddenでipの地域データをsubmitさせます。
<form method="GET" name="form" action=""> <input name="_udate00" type="text" id="datepicker" value="<?php echo $date1; ?>"> ~ <input name="_udate01" type="text" id="datepicker2" value="<?php echo $date2; ?>"> <input type="hidden" name="selectedDimension" value="<?php echo $c; ?>"> <input type="submit" class="submit" value="apply"> </form>
両方ついています。
192.168.33.1だとgeoliteがエラーになるので、198.7.31.23にします。
$data = array("date"=>date("Y-m-d H:i:s")); $audience = $_POST['userdata']; $mongo = "app.na".$audience[0][1]; $audience = array_splice($audience, 1); $ip_addr = $audience[0][1]; if($ip_addr == "192.168.33.1"){ $ip_addr = "198.7.31.23"; } foreach($audience as $value){ $data += array($value[0]=>$value[1]); } require_once '../geolite/vendor/autoload.php'; use GeoIp2\Database\Reader; $reader = new Reader('../geolite/GeoLite2-City.mmdb'); $record = json_decode(json_encode($reader->city($ip_addr))); $continent = $record->continent->names->en; $contry = $record->country->names->en; $city = $record->city->names->en; $data = $data + array('continent'=>$continent, 'contry'=>$contry, 'city'=>$city); var_dump($data); $mng = new MongoDB\Driver\Manager("mongodb://localhost:27017"); $bulk = new MongoDB\Driver\BulkWrite; $bulk->insert($data); $mng->executeBulkWrite($mongo, $bulk); echo "finished!!!";
取得できています。
mongoDBにもはいってます。
-geoliteがエラーの時の為に、try catch (Exception $e) に変えると、以下の分岐条件は削除できます。
if($ip_addr == "192.168.33.1"){ $ip_addr = "198.7.31.23"; }
ipの地理情報はmongoDBには入りません。
因みに、Chrom extensionでBetternet Unlimited Free VPN ProxyやHotspot Shieldなどを使うとIPアドレスを偽造できるようです。
次は、表示側を作ります。
flexを入れ子にしたレイアウトにします。
プロでなければ、普通に写真撮る分にはiphoneで十分、と誰かにお聞きしたんだが、
前から気になっていた、iphoneと一眼レフでどれ位性能違うの?
iphone
6s
-live photos(シャッターを切る前後1.5秒ずつの動画も含めて記録する)
-位相差AFセンサー
-手ぶれ補正
-動画画質 4K/30p(フルHDの4倍の情報量)
-有効画素数 1200万画素
X
-1200万画素
-連写速度 約10コマ/秒
-シャッター速度 1/8000~30秒
-4Kビデオ作成
-wifi bluetooth, gps 〇
-レンズF値 広角:1.8, 望遠:2.4
-レンズカバー距離 28-57mm
-174g
Cannon
EOS630(1989年129,700円)
-シャッター1/2000~30秒
-AF方式:TTL位相差検出方式(ズレ検出)、AFモードはワンショット式 /動体予測AIサーボAF、AF検出範囲はEV1~18(ISO100)
-ファインダー:ペンタ固定アイレベル式、倍率0.8倍、視野率94%、交換スクリーン7種完備
-測光・露出制御:複合型SPC素子使用、TTL開放測光シャッタースピード優先式AE/絞り優先式AE/インテリジェントプログラムAE、定点連動マニュアル、オートブラケティング(1/2段±5段階露光可能)、9回まで予約可能の多重露出可能、測光感度分布特性=画面6分割評価測光/中央部分(画面中央約6.5%部)測光(AEロック機能付き)、露出補正±5EV(1/2ステップ)可能、測光連動範囲はEV-1~ 20(ISO100:F1.4)、フィルム使用感度域はISO6~6400、イメージセレクト=AF、AE、巻き上げ、プログラムの組み合わせ7種、カスタムファンクション=7種設定可能
EOS-1D X Mark II(547,800円!?)
-CFカード(タイプI準拠、UDMAモード7対応)CFastカード(CFast 2.0対応)
-約35.9×23.9mm
-CMOSセンサー
-約2020万画素
-DCF2.0 PEG、RAW
-ピクチャースタイル:オート、スタンダード、ポートレート、風景、ディテール重視、ニュートラル、忠実設定、モノクロ、ユーザー設定1~3
-ホワイトバランス
-画像の明るさ自動補正,高輝度側・階調優先,レンズ光学補正
-ファインダー ペンタプリズム使用、アイレベル式 約0.76倍(50mmレンズ・∞・-1m-1)
-オートフォーカス 専用AFセンサーによるTTL二次結像位相差検出方式
-露出制御:約36万画素RGB+IR測光センサー使用、216分割TTL開放測光
-多重露出撮影
-シャッター 電子制御式、フォーカルプレーンシャッター 1/8000~30秒
-ドライブ関係 1枚撮影、高速連続撮影、低速連続撮影、1枚:ソフト動作、ソフト高速連続撮影、ソフト低速連続撮影、セルフタイマー:10秒、セルフタイマー:2秒 高速連続撮影
-外部ストロボ EXシリーズスピードライト E-TTL II 自動調光
-ライブビュー撮影機能
-動画撮影機能 MOV、MP4
-液晶モニター
-再生機能
-有線LAN機能
….
機能が想像以上にあるな。。1989年のEOS630ですら、まだキャッチアップでんぞ。。。
とりあえずシャッター速度は変わらんよう。
画素は2200万だからEOSは倍。1200万でも相当凄いんだろうけど。。よーわからんが。
明るさや、露出補正はなんとなく馴染みやすいが、手振れ補正のアルゴリズムが良くわかりませんね。
手振れ補正は、色々なアルゴリズムの研究が世界中であるようです。
https://library.naist.jp/mylimedio/dllimedio/showpdf2.cgi/DLPDFR008578_P1-93
光学式:カメラの動きをジャイロセンサで検出して、その動きがキャンセルされるようにレンズ、撮影素子を駆動する
電子式:画像処理
->光学式は、カメラそのもの動きを計算しているんですね。
自動運転は画像認識の技術が入っているので、当然カメラと連動した写真系のサービスつくらないと駄目ってことですね。(どれ位掘らないといけないのか、現段階では想像つきません)
呑気に「一眼レフ買って撮影会に行きたい」なんて言ってる場合ではないことは確か。