-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
119 lines (102 loc) · 5.07 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
require_once('markov.php');
require('mecabp.php');
require('data.php');
$summarizer = new Markov;
$words = array();
$stary = explode("\n", $string);
$stary = array_map('trim', $stary);
$stary = array_filter($stary, 'strlen');
$seed = htmlspecialchars($_GET["hash"]);
if ($seed == "") {
$seed = (float)microtime() * 10000000;
$url = ''.$seed;
$ua = $_SERVER['HTTP_USER_AGENT'];
if (!preg_match('/Twitterbot/',$ua) && !preg_match('/facebookexternalhit/',$ua)) {
header("Location: {$url}");
exit;
}
}
//echo $seed;
srand($seed);
shuffle($stary);
$string = implode("", $stary);
$mecab = new Mecabp;
$ary = $mecab->parse($string);
for ($i = 0; $i < count($ary); $i++) {
$str = $ary[$i]["word"];
array_push($words, $str);
}
array_push($words, "EOS");
?>
<!DOCTYPE html>
<html lang="ja">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TehuTehu連鎖 - Tehu君の名言をマルコフ連鎖で自動生成</title>
<meta name="description" content="Tehu君の名言をマルコフ連鎖で自動生成">
<meta property="fb:app_id" content="283781975031992" />
<meta property="og:title" content="TehuTehu連鎖" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://vps1.liverty.biz/hbkr/tefu/" />
<meta property="og:image" content="http://vps1.liverty.biz/hbkr/tefu/tehuogp.png" />
<meta property="og:site_name" content="TehuTehu連鎖" />
<meta property="og:locale" content="ja_JP" />
<meta property="og:description" content="Tehu君の名言をマルコフ連鎖で自動生成" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:description" content="Tehu君の名言をマルコフ連鎖で自動生成" />
<meta name="twitter:site" content="@hbkr" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.2/normalize.min.css" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic,700,700italic">
<link rel="stylesheet" href="custom.css">
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/ja_JP/sdk.js#xfbml=1&version=v2.5&appId=283781975031992";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="container">
<header>
<h1>TehuTehu連鎖</h1>
<p class="desc">Tehu君の名言をマルコフ連鎖で自動生成します</p>
</header>
<main>
<div id="chat-frame">
<p class="chat-talk">
<span class="talk-icon">
<img src="tehuimg.jpg" alt="tartgeticon" width="50" height="50"/>
</span>
<span class="talk-content">
<?php
$summary = $summarizer->summarize($words, 3);
echo $summary;
?>
<br />
<a href="https://twitter.com/share" class="twitter-share-button"{count} data-text="<?php echo mb_strimwidth($summary, 0, 200, '…', 'UTF-8') ?>">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</span></div>
<div style="margin-top:20px"><a href=".">名言を再度作成する</a></div>
<hr>
</main>
<footer>
<div class="fb-like u-pull-left" style="line-height:1" data-href="http://vps1.liverty.biz/hbkr/tefu" data-layout="button" data-action="like" data-show-faces="true" data-share="true"></div>
<div class="u-pull-left" style="margin-left:5px;">
<a href="https://twitter.com/share" class="twitter-share-button"{count} data-via="hbkr">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>
<div class="u-pull-left" style="margin-left:5px;">
<a href="http://b.hatena.ne.jp/entry/http://vps1.liverty.biz/hbkr/tefu" class="hatena-bookmark-button" data-hatena-bookmark-title="TehuTehu連鎖" data-hatena-bookmark-layout="simple" title="このエントリーをはてなブックマークに追加"><img src="https://b.st-hatena.com/images/entry-button/[email protected]" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a><script type="text/javascript" src="https://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script>
</div>
<div class="u-cf">
<a href="https://github.com/hbkr/tefutefu">github</a> / <a href="http://twitter.com/hbkr">twitter</a> / <a href="http://vps1.liverty.biz/hbkr/muji">無印連鎖</a> kazuma ieiri
</div>
</footer>
</div>
</body>
</html>