return FALSE;
}
+
+
+ /**
+ * 死亡場所を更新する
+ *
+ * @param integer $score_id 死亡場所を更新するスコアのscore_id
+ * @param string|FALSE $dead_place 死亡場所を表す文字列。
+ * FALSEの場合はなにもしない。
+ *
+ * @return integer 更新した行数。
+ */
+ public function update_dead_place($score_id, $dead_place)
+ {
+ if ($dead_place === FALSE) {
+ return FALSE;
+}
+ $stmt = $this->dbh->prepare(
+ <<<EOM
+UPDATE scores
+SET dead_place = :dead_place
+WHERE score_id = :score_id
+EOM
+ );
+
+ $result = $stmt->execute(
+ [':score_id' => $score_id,
+ ':dead_place' => $dead_place,
+ ]
+ );
+
+ return $result;
+ }
}
}
}
+
+ /**
+ * キャラクタダンプから死んだ場所を得る
+ *
+ * @return string|FALSE 死んだ場所を表す文字列。
+ * 死んだ場所が得られなかった場合FALSE。
+ */
+ public function get_dead_place()
+ {
+
+ $death_reason_detail = $this->get_death_reason_detail();
+ if ($death_reason_detail === FALSE) {
+ return FALSE;
+ }
+ $places = implode("|", [
+ "階", "荒野", "地上", "街",
+ "辺境の地", "モリバント", "アングウィル", "テルモラ", "ズル",
+ "クエスト「.+」", "クエスト",
+ ]);
+
+ if (preg_match("/^(.*(?:{$places})\s*)で.+$/u",
+ $death_reason_detail, $matches)) {
+ return $matches[1];
+ } else {
+ return FALSE;
+ }
+ }
+
+
private static function browser_accept_encodings()
{
$accept_encoding = filter_input(INPUT_SERVER, 'HTTP_ACCEPT_ENCODING');
exit;
}
+// 登録成功、HTTPレスポンスコード 200 OK を返す
+http_response_code(200);
+
$dumpfile = new DumpFile($score_id);
$dumpfile->save('dumps', 'txt', $split_contents[1]);
if (validate_screen_dump($split_contents[2])) {
$dumpfile->save('screens', 'html.bad', $split_contents[2]);
}
-// 登録成功、HTTPレスポンスコード 200 OK を返す
-http_response_code(200);
+$dead_place = $dumpfile->get_dead_place();
+$db->update_dead_place($score_id, $dead_place);
exec("nohup python tools/tweet_score.py -c tools/tweet_score.cfg -l tweet_score.log -s {$score_id} > /dev/null &");