OSDN Git Service

PTLにおけるスパム非表示。ユーザ一覧でユニークにまとめるようにした。一部マークアップとスタイルの変更。トップページのホットキーワード表示を廃止。画像表示モードをGETパ...
authorKana Koda <kodakana@users.sourceforge.jp>
Fri, 24 Oct 2014 03:49:48 +0000 (12:49 +0900)
committerKana Koda <kodakana@users.sourceforge.jp>
Fri, 24 Oct 2014 03:49:48 +0000 (12:49 +0900)
25 files changed:
.directory [new file with mode: 0644]
README [new file with mode: 0644]
about.php [new file with mode: 0644]
agpl-3.0.txt [new file with mode: 0644]
agpl-3.0_ja.txt [new file with mode: 0644]
apple-touch-icon.png [new file with mode: 0644]
coco.php [new file with mode: 0644]
common_functions.php [new file with mode: 0644]
config.php [new file with mode: 0644]
configurable_variables.php [new file with mode: 0644]
entries.php [new file with mode: 0644]
entry.php [new file with mode: 0644]
entry_processor.php [new file with mode: 0644]
favicon.ico [new file with mode: 0644]
footer_include.php [new file with mode: 0644]
index.php [new file with mode: 0644]
init_processor.php [new file with mode: 0644]
keywords.php [new file with mode: 0644]
keywords_processor.php [new file with mode: 0644]
login.php [new file with mode: 0644]
login_processor.php [new file with mode: 0644]
post.php [new file with mode: 0644]
post_processor.php [new file with mode: 0644]
product_definitions.php [new file with mode: 0644]
style.php [new file with mode: 0644]

diff --git a/.directory b/.directory
new file mode 100644 (file)
index 0000000..020420f
--- /dev/null
@@ -0,0 +1,7 @@
+[Dolphin]
+SortOrder=1
+SortRole=date
+Sorting=2
+Timestamp=2014,10,16,21,23,27
+Version=3
+ViewMode=1
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..30732ae
--- /dev/null
+++ b/README
@@ -0,0 +1,50 @@
+This document is written in Japanese(UTF-8).
+
+#YANMAH2:Yet ANother Mobile Accelerated HatenaHaiku
+
+ (c)2012 YANMAH2 project: http://yanmah2.sourceforge.jp/
+
+##これは何か
+
+ YANMAH2(Yet ANother Mobile Accelerated HatenaHaiku)は、はてなのミニブログ [はてなハイク](http://h.hatena.ne.jp) のコンテンツを携帯端末向けに小さく表示する PHP プログラムです。低速回線や処理性能に余裕がない端末でも、ハイクをサクサクと読めるようことをめざして設計されています。
+
+ 詳しくは、[YANMAH2 project](http://yanmah2.sourceforge.jp/) を参照してください。要望や不具合報告などは、[YANMAH2でひとこと - はてなハイク](http://h.hatena.ne.jp/keyword/YANMAH2)に書き込んでいただいても YANMAH2 project に届きます。
+
+##配布物一覧
+
+       * about.php     …プログラム本体(YANMAH2 についての情報を表示する)
+       * agpl-3.0.txt  …Affero GPL v3 本文
+       * agpl-3.0_ja.txt       …Affero GPL v3 参考訳
+       * apple-touch-icon.png  …最近のスマートフォンでショートカットに使われるアイコン
+       * CHANGELOG     …更新履歴
+       * coco.php      …プログラム本体(検索してイマココ)
+       * common_functions.php  …プログラム本体(共通関数)
+       * config.php    …プログラム本体(一般ユーザ向け設定変更ページ)
+       * configurable_variables.php    …ユーザ変数設定用ファイル
+       * entries.php   …プログラム本体(エントリー一覧)
+       * entry.php     …プログラム本体(個別エントリ表示)
+       * entry_processor.php   …プログラム本体(エントリ表示処理)
+       * favicon.ico   …デフォルトの favicon
+       * footer_include.php …プログラム本体(共通フッタ)
+       * index.php     …プログラム本体(インデックス)
+       * init_processor.php    …プログラム本体(各ページの初期化)
+       * keywords.php  …プログラム本体(キーワード一覧/検索)
+       * keywords_processor.php        …プログラム本体(キーワード一覧表示処理)
+       * login.php     …プログラム本体(ログインページ)
+       * login_processor.php   …プログラム本体(ログイン処理)
+       * post.php …プログラム本体(ポスト用)
+       * post_processor.php    …プログラム本体(ポスト処理)
+       * product_definitions   …共通変数設定用ファイル
+       * README        …この文書
+       * style.php     …スタイルシート(プログラム本体によって生成されるページの外観を定義する)
+
+##使用許諾
+
+ YANMAH2 は、フリーソフトウェアです。あなたはこれを、フリーソフトウェア財団によって発行された Affero GPL v3 の定める条件下で自由に利用、改変、再配布を行うことができます。
+
+ このプログラムは有用であることを願って頒布されますが、*全くの無保証* です。商業可能性の保証や特定の目的への適合性は、言外に示されたものも含め全く存在しません。詳しくは Affero GPL v3 本文をご覧ください。
+
+ YANMAH2 の配布物一式には、Affero GPL v3 本文が含まれているはずです。もし欠如している場合は、YANMAH2 project か、または[フリーソフトウェア財団](http://www.fsf.org/)に請求してください。
+
+----------------------------------------
+Kodakana<kodakana@users.sourceforge.jp>
diff --git a/about.php b/about.php
new file mode 100644 (file)
index 0000000..2738aa5
--- /dev/null
+++ b/about.php
@@ -0,0 +1,73 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+require_once 'init_processor.php';
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+//session_regenerate_id(TRUE);
+?>
+<?php
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+$self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}";
+if ($get_image == 'on'){
+               $self_anchor_with_imagemode = $self_anchor . '?image=on';
+} else {
+               $self_anchor_with_imagemode = $self_anchor . '?image=off';
+}
+$echo = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
+       <meta http-equiv="Content-Style-Type" content="text/css" />
+       <meta http-equiv="Content-Script-Type" content="text/javascript" />
+       <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
+       <title>{$product_name_abbr} について - {$site_name}</title>
+       <link rel="stylesheet" href="{$style_sheet}" />
+       <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" /></head>
+<body>
+<div id="page">
+EOL;
+$echo = $echo . echoCommonHeader('#com_footer', $self_anchor_with_imagemode) . "<hr />\n";
+$echo = $echo . <<<EOL
+<div id="header" class="about">
+<h1 id="about-head" class="head1">{$product_name_abbr} について</h1>
+</div>
+<div class="contents">
+<h2>はてなハイクとは何か?</h2>
+<p><a href="{$haiku_official_url}">はてなハイク</a>とは、ウェブサービス企業の<a href="http://mobile.hatena.ne.jp/">はてな</a>が運営しているミニブログです。詳しくは、<a href="{$haiku_official_url}help">はてなハイクのヘルプ</a>をご覧ください。</p>
+
+<h2>{$product_name_abbr} とは何か?</h2>
+<p>{$product_name_abbr}({$product_name_full})は、はてなのミニブログ「<a href="{$haiku_official_url}">はてなハイク</a>」のコンテンツを携帯端末向けに小さく表示する PHP プログラムです。低速回線や処理性能に余裕がない端末でも、ハイクをサクサクと読めるように設計されています。このウェブサイトには、<a href="{$admin_url}">{$admin_name}</a> が設置・管理しています。現在ここで動作している {$product_name_abbr} のヴァージョンは、{$product_version} です。</p>
+
+<p>{$product_name_abbr} は、フリーソフトウェアライセンスである Affero GPL v3 の条件下で使用許諾されています。あなたは、<a href="{$project_url}">{$project_name}</a> から {$product_name_abbr} のソースコードを入手し、 Affero GPL v3 の条件下で自由に利用、改変、再配布を行うことができます。{$project_name} では {$product_name_abbr} に関する文書を公開し、要望やバグ報告なども受け付けています。</p>
+
+<p>このサイトに設置されている {$product_name_abbr} が、設置者により独自に改変されたものである場合、あなたは {$admin_name} からそのソースコードを受け取ることができます。</p>
+</div>
+EOL;
+?>
+<?php
+$navi_paging = FALSE;
+$navi_imaging = FALSE;
+require 'footer_include.php';
+$echo = $echo . '</div></body></html>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+?>
\ No newline at end of file
diff --git a/agpl-3.0.txt b/agpl-3.0.txt
new file mode 100644 (file)
index 0000000..dba13ed
--- /dev/null
@@ -0,0 +1,661 @@
+                    GNU AFFERO GENERAL PUBLIC LICENSE
+                       Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+  A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate.  Many developers of free software are heartened and
+encouraged by the resulting cooperation.  However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+  The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community.  It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server.  Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+  An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals.  This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU Affero General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Remote Network Interaction; Use with the GNU General Public License.
+
+  Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software.  This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time.  Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source.  For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code.  There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+<http://www.gnu.org/licenses/>.
diff --git a/agpl-3.0_ja.txt b/agpl-3.0_ja.txt
new file mode 100644 (file)
index 0000000..f45be76
--- /dev/null
@@ -0,0 +1,226 @@
+This is an unofficial translation of the GNU Affero General Public License into Japanese. It was not published by the Free Software Foundation, and does not legally state the distribution terms for software that uses the GNU AGPL--only the original English text of the GNU AGPL does that. However, we hope that this translation will help japanese speakers understand the GNU AGPL better.
+
+(訳: 以下はGNU Affero General Public Licenseの非公式な日本語訳です。これはフリーソフトウェア財団によって発表されたものではなく、 GNU AGPL を使ったソフトウェアの頒布条件を法的に有効な形で述べた ものではありません。頒布条件としては GNU AGPLの英語版テキストで 指定されているもののみが有効です。しかしながら、私たちは この翻訳が日本語を使用する人びとが GNU AGPLをより一層理解する助けとなることを望んでいます。)
+
+翻訳は2008年1月9日に、塚本牧生 <tsukamoto@gmail.com> が行いました。
+
+----
+
+                    GNU AFFERO 一般公衆利用許諾書
+                       バージョン3, 2007年11月19日
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ 本ライセンス文書の忠実な複製と配付は許されていますが,
+ 変更は許可されていません。
+
+                            はじめに
+
+GNU Affero 一般公衆利用許諾書は,ネットワークサーバソフトウェアに関するケースでコミュニティとの協力を確実にするように明確に設計された,ソフトウェアおよびその他の著作物について,フリーかつコピーレフトを主張するライセンスです。
+
+ソフトウェアやその他の実用的な著作物を対象とするライセンスの大半は,著作物を多くの者で共有したり著作物を変更する自由を奪い去るように作られています。これに対して,私達の一般公衆利用許諾書は,プログラムの全てのバージョンを共有し変更できる自由を保証すること,すなわち,ソフトウェアがユーザ全てにとってフリーであり続けることを保証することを目的としています。
+
+私たちがフリーソフトウェアについて語るとき,私たちは自由について言及しているのであって,価格は問題にしていません。私たちの一般公衆利用許諾書は,フリーソフトウェアの複製物を配付すること(有償も可),ソースコードを受領するか後から入手できること,ソフトウェアを修正すること,またはその一部を別のフリーなプログラムで利用できること,そしてこれらが可能であることをあなたが知り得ること,が確保されるよう構成されています。
+
+私達のGPLを利用する開発者は,あなたの権利を2段階の手順を踏んで守ります。その手順とは,(1)ソフトウェアに関する著作権を主張し,(2)ソフトウェアを複製,配付,または改変する法的な許諾をするものである本許諾書をあなたに提示する,というものです。 
+
+すべてのユーザの自由を守ることの副次的な利益は,広範囲での利用を受けることができれば,プログラムの他のバージョンで行われた改良が,他の開発者にも取り込むことが可能になることです。フリーソフトウェアの多くの開発者が,この結果として起こる協力に励まされ,支援されます。しかしながら,ネットワークサーバで使用されるソフトウェアの場合では,こうした結果は生じないかもしれません。GNU一般公衆利用許諾書は,変更されたバージョンを作成し,公衆にソースコードを公開することなく,公衆にアクセスさせることを許しています。
+
+GNU Affero 一般公衆利用許諾書は,このような場合に,変更されたソースコードがコミュニティに利用可能になることを保障するために設計されています。これはネットワークサーバのオペレータに,そこで稼動している変更されたバージョンのソースコードを,サーバの利用者に提供することを要求します。したがって,公衆がアクセス可能なサーバ上での,変更されたバージョンの公衆利用は,変更されたバージョンのソースコードへの公衆アクセスも与えます。
+
+Afferoから発行されていたAffero 一般公衆利用許諾書と呼ばれていた,より古いライセンスは,同様の目標を達成するように設計されました。これはAffero GPLのバージョンではなく,異なったライセンスですが,Afferoはこのライセンスの下で再認可することを可能にするAffero GPLの新しいバージョンをリリースしました。
+
+複製,配付,改変に関する詳細な利用条件は以下のとおりです。
+
+                       利用条件
+
+0. 定義
+
+「本許諾書」(The License)とは,GNU Affero 一般公衆利用許諾書のバージョン3をいう。
+
+本許諾書において「著作権」(Copyright)とは,著作権法だけでなく,半導体マスク等に適用される著作権法類似の法(に基づく権利)も意味する。
+
+「本プログラム」(The Program)とは,著作権により保護されており,本許諾書に基づいてライセンスされる著作物をいう。各ライセンシーを 「あなた」という。「ライセンシー」及び「受領者」(recipients)は,個人でも組織でもよい。
+
+著作物の「改変」(modify)とは,著作権の許諾を受けることを要する態様で著作物の全体または一部を複製又は翻案する行為をいう。ただし,完全に同一の複製物を作成する行為は除く。改変後の著作物は,元の著作物の「改変バージョン」(modified version),または,元の著作物に「基づく」(based on) 著作物という。
+
+「対象著作物」(covered work)とは,改変されていない本プログラム及び本プログラムに基づく著作物をいう。
+
+著作物の「プロパゲート」(propagate)とは,準拠法国の著作権法上,権利者の許諾を得ずして行った場合に,権利侵害に基づく直接又は間接の責任を負うこととなる行為をいう。ただし,著作物をコンピュータ上で実行する行為,及び私的な改変行為を除く。プロパゲートは,複製,配付(改変の有無を問わない),及び公衆への利用可能化を含む。さらに,国によっては他の行為も含む場合がある。
+
+著作物の「コンベイ」(convey)とは,プロパゲートに当たる行為のうち第三者が複製すること又は複製物を受領することを可能にする行為をいう。ただし,コンピュータネットワーク上での単なるやりとりであって複製物の伝送を伴わない場合は,コンベイに当たらない。
+
+インタラクティヴなユーザインターフェースにより「適切な法律上の告知事項」(Appropriate Legal Notices)を表示する場合,当該インターフェースは,(1)著作権に関する適切な告知を表示すること,並びに(2)著作物に関して何らの保証もなされないこと (ただし,別段の定めにより保証がなされる場合を除く),ライセンシーは著作物を本許諾書の条件に基づいてコンベイしうること,及び本許諾書の内容を参照する方法を,容易かつ明確に読み取ることのできる機能を含むものとする。当該インターフェースがメニューのようなユーザコマンドやオプションのリストを表示するものの場合は,上記の項目が当該リストに明確に示されているならば,条件を満たすものとする。
+
+  1. ソースコード
+
+著作物の「ソースコード」(source code)とは,著作物を改変するのに好ましい形式(form)をいう。「オブジェクトコード」 (object code)とは,ソースコード以外の形式すべてをいう。
+
+「標準インターフェース」(Standard Interface)とは,標準化団体として認められている組織によって策定された公式の標準規格のインターフェース,及び特定のプログラミング言語用のインターフェースであって,当該言語を利用する開発者の間で広く用いられているものをいう。
+
+実行可能な著作物の「システムライブラリ」(System Libraries)とは,(a)「主要コンポーネント」(Major Component)のパッケージに通常含まれている,主要コンポーネント以外の著作物,並びに(b)著作物を主要コンポーネントにおいて利用可能とするためにのみ機能するもの,及び一般の利用者がソースコード形式で標準インターフェースを実装できるようにするためにのみ機能するもののすべてをいう。ただし,全体としての当該著作物そのものは除く。ここでいう「主要コンポーネント」とは,実行可能な著作物が動作する特定のオペレーティングシステムの主要な必須コンポーネント(カーネルやウィンドウシステムなど),著作物の生成に用いられるコンパイラ,著作物を実行するために用いられるオブジェクトコードインタプリタ等をいう。
+
+オブジェクトコード形式の著作物の「対応ソース」(Corresponding Source)とは,当該著作物の生成,インストール,(実行可能な著作物に関しては)オブジェクトコードの実行,及び著作物の改変に必要とされるソースコードのすべてをいう。これらの作業を制御するためのスクリプトも「対応するソース」に含まれる。ただし,当該著作物のシステムライブラリ,及び当該著作物以外の汎用ツール又は一般に利用可能なフリープログラムであって改変することなく上記の行為に用いられるものは含まない。例えば,対応ソースには,当該著作物のソースファイルと連携するインターフェース定義ファイル,並びに,共有ライブラリ,及び,動的リンクされるサブプログラムであって,当該著作物が特に必要とするように設計されているもの(例えば,サブプログラムと当該著作物の間の緊密なデータ通信(intimate data communication)又は制御フローに関するようなもの)のソースコードを含む。
+
+対応ソースには,対応ソースから自動的に生成できるものを含む必要はない。
+
+ソースコード形式の著作物の対応ソースは,当該著作物自体である。
+
+  2. 許諾の基本事項
+
+本許諾書に基づき許諾されるすべての権利は,本許諾書の定めに従うことを条件として,本プログラムの著作権の存続する期間許諾され,取消不能とする。本許諾書は,本プログラムを改変することなく実行することについて,無制限の許諾を明示的に認める。対象著作物の実行により得られた出力結果について,出力された内容が保護された著作物に該当する場合にのみ本許諾書が適用される。本許諾書は,著作権法の定めるフェアユースまたはそれと同等の権利を認める。
+
+あなたに対するライセンスが有効である限り,対象著作物を実行すること,及びコンベイすることなくプロパゲートすることは,無条件に認められる。第三者にあなた専用の改変を行わせることのみを目的とする場合,又は第三者に著作物を実行するための機能を提供させることのみを目的とする場合,あなたは本件許諾書適用著作物を当該第三者にコンベイすることができる。ただし,あなたが著作権を管理していない部分のコンベイに関しては,本許諾書の定めに従うことを要する。したがって,当該第三者すなわちあなたのために対象著作物を作成または実行する者は,あなたの管理監督下において,あなたとの関係の範囲外ではあなたが著作権を有する著作物の複製を禁止することを条件として,専らあなたのためにのみ上記の行為を行わなければならない。
+
+上記以外の場合におけるコンベイは,下記に定める条件の下でのみ許される。再許諾は,本第10条により不要であることから,認められていない。
+
+  3. 技術的保護手段の回避を禁ずる法律に対するユーザの法的権利の保護
+
+いかなる対象著作物も,WIPO著作権条約(1996年12月20日採択)第11条の定める義務を充足する準拠法,及びそれに類する技術的保護手段の回避を禁ずる法における「技術的保護手段」(effective technological measure)とは見なされないものとする。
+
+(訳注: WIPO著作権条約については,<http://www.cric.or.jp/db/article/wch.html> 等を参照せよ。) 
+
+あなたが対象著作物をコンベイする場合,あなたは,本許諾書に基づいて当該対象著作物に関する権利を行使することにより回避行為に影響を与える範囲において,技術的保護手段の回避を禁止する法的権利を放棄するものとする。また,あなたは,技術的保護手段回避の禁止に関わるあなた又は第三者の法的権利を行使する手段として,著作物の動作(operation)又は改変を制限意図を放棄するものとする。
+
+  4. 忠実な複製物のコンベイ
+
+あなたは,あなたが受領した本プログラムのソースコードと完全に同一の複製物を,いかなる媒体を用いるかにかかわらず,コンベイすることができる。ただし,著作権に関する適切な告知事項を個々の複製物に目立つように適切な方法で掲載すること,本許諾書及び本第7条に従い追加された非許可条項のすべてが当該複製物に適用される旨の告知をそのまま保持すること,いかなる保証もなされない旨の告知をそのまま保持すること,及び本プログラムと共に本許諾書を受領者に提供することを条件とする。
+
+あなたは,複製物をコンベイする際,それぞれの複製物に対していかなる対価をも課することができ,また無料でコンベイすることもできる。そして,有償でサポートや保証を提供することもできる。
+
+  5. 改変されたバージョンのソースのコンベイ
+
+あなたは,以下の条件のすべてを満たすことを条件として,本プログラムに基づく著作物,又は本プログラムに基づく著作物を本プログラムから作成するための改変点を,本第4条の定めに従って,ソースコード形式でコンベイすることができる。
+
+a)あなたが改変したこと,及びその日付を改変された著作物に目立つように記載すること。 
+
+b)改変された著作物が本許諾書及び本第7条に従って追加されたすべての条件に基づいて公開されていることを改変された著作物に目立つように記載すること。この条件は,告知をそのまま保持することを定めた本第4条を修正するものである。 
+
+c)改変された著作物の複製物を保有することとなった何人に対しても,改変された著作物の全体を一体として,本許諾書に基づきライセンスすること。したがって,改変された著作物の全体,及びそれがどのようにパッケージされているかに関わらず改変された著作物を構成する要素のすべてについて,本許諾書及び本第7条に基づいて追加されたすべての条項が適用されることになる。本許諾書は,上記以外の方法で改変された著作物をライセンスすることを認めない。ただし,あなたが本許諾書とは別に別途許諾を受けている場合は,当該許諾まで無効とするものではない。 
+
+d)改変された著作物がインタラクティヴなユーザインターフェースを有する場合,当該インターフェースにより適切な法律上の告知事項を表示すること。ただし,本プログラムのインタラクティヴなインターフェースが元々あって,それが法律上の適切な告知事項を表示するものでない場合は,改変された著作物においてそれを表示するようにする必要はない。
+
+対象著作物と他の別個独立の著作物を一つの記録媒体又はコンベイに用いる媒体の中に集めたものは,「集積物」(aggregate)という。ただし,集積物がその性質上当該対象著作物の拡張版でないこと,より大規模な一つのプログラムを構成するために組み合わされているのでないこと,並びに集積行為及び集積物についての著作権が,個々の著作物の許諾の範囲を超えて,当該集積物の利用者のアクセス又は法的権利を制限するために用いられないことを要する。対象著作物を集積物に含めたとしても,当該集積物の他の部分に本許諾書が適用されることはない。
+
+  6. ソース形式以外でのコンベイ
+
+あなたは,本第4条及び第7条の定めに従い,対象著作物をオブジェクトコード形式でコンベイすることができる。ただし,本許諾書の定めに従って,機械読み取り可能な対応ソースを以下の何れかの方法でコンベイすることを要する。
+
+a)オブジェクトコードを物理的な製品(コンベイに用いる物理的な媒体を含む)に格納又は組み込んでコンベイする場合,対応ソースをソフトウェアのやりとりで一般的に用いられる耐久性のある物理的媒体に固定して一緒にコンベイすること。 
+
+b)オブジェクトコードを物理的な製品(コンベイに用いる物理的な媒体を含む)に格納又は組み込んでコンベイする場合,最低3年間又は当該製品のモデルの補修用部品又はカスタマーサポートを提供している間のいずれか長い方の期間,オブジェクトコードを保有する者すべてに対して,請求に応じて,(1)当該製品に含まれるソフトウェアのうち本許諾書が適用されるソフトウェアすべてについて,ソフトウェアのやりとりで一般的に用いられる耐久性のある物理的媒体を使用して,物理的なコンベイに要する合理的なコストを超えない価格で対応ソースをコンベイすること,又は(2)ネットワークサーバから対応ソースを複製するためのアクセスを無料で提供することを記載した書面を添付すること。 
+
+c)請求があった場合に対応ソースを提供することを記載した書面を添付して,オブジェクトコードをコンベイすること。ただし,この方法は,あなたが本第6条b項に定める条件に従ってオブジェクトコードを受領した場合にのみ,予備的かつ非商業的に許される。 
+
+d)オブジェクトコードを所定の場所にアクセスして複製することによりコンベイする場合,対応ソースについても同じ場所から同様の方法でアクセスできるようにすること。ただし,オブジェクトコードのコンベイは無償でも有償でもよいが,対応ソースへのアクセスに対して追加的な対価を課すことはできない。受領者に対して,対応ソースをオブジェクトコードと一緒に複製することを義務づける必要はない。オブジェクトコードをネットワークサーバにアクセスして複製する場合,対応ソースは同等の複製機能をサポートする他のサーバ(あなた又は第三者が運用するもの)上にあっても良い。ただし,その場合は,対応ソースのある場所を示す記載をオブジェクトコードに隣接する箇所に明示しておかなければならない。いかなるサーバが対応ソースをホスティングするかに関わらず,これらの条件を充足する義務が存続している限り,あなたは,対応ソースにアクセス可能なよう保証する義務を負っている。 
+
+e)オブジェクトコードをピア・ツー・ピア伝送を用いてコンベイする場合,本第6条d項に従って当該オブジェクトコード及び対応ソースが無償で公開されている場所を他のピアに対して通知しておくこと。 
+オブジェクトコードの分離可能な部分であって,システムライブラリとしてそのソースコードが対応ソースから除外されている場合は,当該分離可能な部分は,オブジェクトコードの著作物のコンベイに含めなくともよい。
+
+「ユーザ製品」(User Product)とは,(1)「コンシューマ製品」(consumer product),すなわち,個人,家族,又は家庭により通常使用される個人用の有体物,又は(2)住宅に設置することを目的として設計又は販売されるもののすべてをいう。ある製品がコンシューマ製品に該当するか否か疑義がある場合は,コンシューマ製品に該当するものとする。また,特定のユーザが保有する特定の製品について,「通常使用される」(normally used)とは,その製品が属する分野における典型的又は一般的な使用方法を意味し,当該特定のユーザが置かれた状況,または当該特定のユーザが当該製品を実際にどのように使用しているかという事実,又はどのように使用することが予定されているかということには関わらない。当該製品に業務用,工業用または非コンシューマ的な利用形態がある場合でも,当該用途が当該製品の唯一の重要な利用形態でない限り,当該製品はコンシューマ製品に該当する。
+
+ユーザ製品の「インストール用情報」(Installation Information)とは,ユーザ製品に組み込まれている対象著作物の対応ソースを改変して作成した改変バージョンを当該ユーザ製品にインストールし実行するために必要とされる手法,手順,認証キー及びその他の情報のすべてをいう。当該情報は,改変されたオブジェクトコードの継続的な動作が,改変が為されたということによってのみ拒否されたり妨害されることが決してないことを保証するのに十分なものでなければならない。
+
+オブジェクトコードの著作物をユーザ製品に組み込んで,あるいはユーザ製品と共に,又はユーザ製品において使用されることを指定してコンベイする場合であって,当該ユーザ製品の所有及び使用にかかる権利を永久に又は一定期間譲渡する取引の一部として行われる場合は,取引の法的類型に関わらず,本条に基づいてコンベイされる対応ソースは,インストール用情報と共にコンベイされなければならない。ただし,あなた及びいかなる第三者もオブジェクトコードの修正版を当該ユーザ製品にインストールすることができない場合(例えば,著作物がROMに格納されている場合)は,この条件は適用されない。
+
+インストール用情報の提供に関する条件には,受領者が改変もしくはインストールした著作物,又は当該著作物が改変もしくはインストールされたユーザ製品に対して,保守サービス,保証,又はアップデートを提供し続けることは含まれない。改変自体がネットワークの運用に重大かつ有害な影響をもたらす場合,もしくはネットワーク上での通信に関する規約又はプロトコルに違反する場合には,ネットワークアクセスを拒否することは許される。
+
+本条に基づく対応ソースのコンベイ及びインストール用情報の提供は,文書化され一般に公開されているフォーマットにより(かつソースコード形式で一般に利用可能な実装方法で)なされなければならない。この場合,これらの圧縮展開,読み込み,又は複製に特別なパスワードやキーを必要としてはならない。
+
+  7. 追加的許諾条項
+
+「追加的許諾条項」(Additional permissions)とは,本許諾書の定める条項の例外を定めることにより,本許諾書の条項を補足する条項をいう。追加的許諾条項が本プログラムの全体に適用される場合,準拠法の下で有効とされる限り,追加的許諾条項は本許諾書に含まれているものとして(訳注:つまり本許諾書と一体のものとして)扱われるものとする。追加的許諾条項が本プログラムの一部分にのみ適用される場合は,当該部分に関しては当該追加的許諾条項に基づいて別途利用可能であるが,本プログラム全体については,追加的許諾条項の内容いかんに関わらず,本許諾書が適用される。
+
+対象著作物をコンベイする場合,あなたは,追加的許諾条項のいかなる条項についても,当該著作物の全体又は一部から削除することができる(追加的許諾条項は,所定の改変がなされた場合は当該追加的許諾条項自体を削除するように規定することもできる)。あなたは,あなたが対象著作物に加えた部分であって,あなたが著作権を許諾できる部分について,追加的許諾条項を定めることができる。
+
+本許諾書の他の規定に関わらず,対象著作物にあなたが加えた部分については(当該部分の著作権者が認める場合),本許諾書の条項に加え,以下の条項を追加することができる。
+
+a)本第15条および第16条の定めとは異なる内容の保証の否認又は責任の限定 
+
+b)追加した部分に含まれている,特定の合理的な法律上の告知事項又は作成者の記載,もしくは追加した部分を含む著作物によって表示される適切な法律上の告知事項中の同様の情報を,そのまま維持するよう要求すること 
+
+c)追加した部分の作成者について虚偽又は不正確な表示をすることを禁じること,もしくは,改変されたバージョンにオリジナルのバージョンとは異なっていることを合理的な方法で表示することを要求すること 
+
+d)追加した部分のライセンサー又は作成者の名前を,宣伝目的で利用することを制限すること 
+
+e)商品名,商標又はサービスマークの使用に関して,商標法に基づく権利の許諾を拒むこと 
+
+f)追加した部分(又は改変されたバージョン)をコンベイする者が受領者に対する契約上の責任を負ってコンベイする場合,ライセンサー及び著作者に直接的に課される責任を免責することを要求すること。 
+上記以外の追加的条項を定めることは許されず,そのような追加的条項は,本第10条が意味するところの「追加的制限」(further restrictions)とみなされる。あなたが受領した本プログラム又はその一部に,本許諾書に加えて追加的制限が適用される旨が記載されている場合,あなたは当該条項を削除することができる。追加的制限を含むライセンス文書が本許諾書に基づく再許諾又はコンベイを認めている場合,あなたは当該ライセンス文書の条項が適用される部分を対象著作物に追加することができる。ただしその場合,追加的制限は当該再許諾又はコンベイにおいては無効とされる。
+
+本条に基づいて条項を対象著作物に追加する場合,あなたは,ソースファイル中に,当該ファイルに適用される追加的条項の記載,又は適用される条項を参照できる場所を示す記載を含めなければならない。
+
+追加的条項は,それが本許諾書で認められるものであるか否かにかかわらず,本許諾書とは独立したライセンス文書の形式であってもよいし,本許諾書の例外規定として記述されるものであってもよい。ただし,本条の上記の定めは,いずれの場合にも適用される。
+
+  8. 終了
+
+あなたは,本許諾書で明示的に定められている場合を除いて,対象著作物をプロパゲートまたは改変することができない。それ以外に対象著作物をプロパゲートまたは改変しようとする試みはすべて無効であり,そのような試みをした場合は,本許諾書に基づくあなたの権利(本第11条第3パラグラフに基づいて許諾された特許ライセンスを含む)は自動的に消滅するものとする。
+
+ただし,本許諾書に違反する行為のすべてが中止された場合,特定の著作権者からあなたに供与されたライセンスは,(a)当該著作権者が当該ライセンスを終局的に終了させることを明示的に述べなるまでの間,暫定的に回復するものとし,(b)違反行為の中止後60日以内に,当該著作権者があなたに対して合理的な手段で違反の事実を告知しなかった場合は,恒久的に回復するものとする。
+
+また,当該著作権者があなたに対して合理的な手段で違反の事実を告知した場合において,それが本許諾書の違反(いかなる著作物に関するものであるかを問わない)に関する当該著作権者からの最初の告知であり,かつ当該告知受領後30日以内に違反を是正した場合は,当該著作権者からあなたに供与されたライセンスは,恒久的に回復するものとする。本条に基づいてあなたの権利が消滅した場合でも,本許諾書に基づいてあなたから複製物又は権利を受領または承継した者に対する許諾は,消滅しないものとする。あなたの権利が消滅し,恒久的に回復されないこととなった場合,同一のライセンス対象に対する新たなライセンスを本第10条に基づいて取得することもできなくなる。
+
+  9. 著作物の受領等に関する承諾の不要性
+
+本プログラムの受領又は実行については,本許諾書の承諾を必要としない。ピア・ツー・ピア伝送を使用して本プログラムを受領することに伴って生ずる対象著作物のプロパゲートについても,同様に承諾を必要としない。しかしながら,あなたに対して対象著作物のプロパゲート又は改変を許諾するものは,本許諾書をおいて他にない。これらの行為は,本許諾書を承諾しない限り,著作権を侵害することとなる。したがって,対象著作物を改変又はプロパゲートすることにより,あなたは当該行為を行うために本許諾書を承諾する旨の意思表示したことになる。
+
+  10. 下流の受領者に対する自動的な許諾
+
+対象著作物の受領者は,あなたが対象著作物をコンベイする都度,オリジナルのライセンサーから,本許諾書に基づいて当該著作物を実行,改変,及びプロパゲートする許諾を自動的に得るものとする。なお,あなたは,第三者に本許諾書の定めを遵守させる義務を負わない。
+
+「企業体取引」(entity transaction)とは,事業譲渡,会社分割,又は合併に関する取引をいう。企業体取引の結果として対象著作物のコンベイが生じた場合,当該著作物を受領した当事者は,譲渡当事者が本条前項に基づいて保有していた又は保有し得た許諾に係るすべてを承継するものとする。また,譲渡当事者が当該著作物の対応ソースを保有していた場合,又は合理的な努力により入手できる場合,受領当事者は,当該対応ソースを保有する権利もまた承継するものとする。
+
+あなたは,本許諾書に基づいて許諾され又は確認された権利の行使に対して,本許諾書が規定する以上のさらなる制限を課してはならない。例えば,あなたは,本許諾書に基づく権利の行使に対してライセンス料,ロイヤルティその他の対価を課してはならない。また,あなたは,本プログラムの全体又はその一部の作成,使用,譲渡,譲渡の申し出又は輸入が特許を侵害することを理由として,訴訟(交差請求及び反訴を含む)を提起してはならない。
+
+  11. 特許
+
+「コントリビュータ」(contributor)とは,本プログラム又は本プログラムに基づく著作物の使用を,本許諾書の下で許諾することのできる権利を保有する著作権者をいう。当該許諾された著作物を,当該コントリビュータによる「コントリビュータ・バージョン」(contributor version)という。
+
+コントリビュータの保有に係る「必須特許クレーム」(essential patent claims)とは,当該コントリビュータのコントリビュータ・バージョンに対して本許諾書で許諾されている行為を行った場合,すなわち作成,使用又は販売をした場合に侵害することとなる特許クレームのすべてをいう。当該特許クレームは,当該コントリビュータが保有しているもの及び支配権限を有しているものを含み,かつ取得済みのもの及び将来取得するものを含む。ただし,コントリビュータ・バージョンを他者が改変した結果,侵害されることとなる特許クレームは含まない。本項の定義において,「支配権限」は,本許諾書の条件を充たす態様で特許の再許諾をする権利も含むものとする。
+
+各コントリビュータはあなたに対して,コントリビュータ・バージョンの内容の作成,使用,譲渡,譲渡の申し出,又は輸入,並びに実行,改変,又はプロパゲートについて,当該コントリビュータ・バージョンで実施されている必須特許クレームを対象とする,非独占的かつ無償の全世界における特許ライセンスを許諾するものとする。
+
+以下の3つのパラグラフにおいて「特許ライセンス」とは,いかなる名称であるかを問わず,特許権を行使しないという明示的な契約又は誓約(特許の明示的な実施許諾,または特許侵害訴訟を提起しないことに合意する非係争条項等)のすべてをいう。当該特許ライセンスを「許諾する」(grant)とは,相手方当事者に対して特許権を行使しない旨の契約を締結し又は誓約をすることをいう。
+
+特許ライセンスに依拠していることを知りながら対象著作物をコンベイする場合において,当該著作物の対応ソースが公衆が利用可能なネットワークサーバ又は他の容易にアクセス可能な手段を通じて,無料でかつ本許諾書の定めに基づいて複製可能な状況におかれていない場合,あなたは,(1)対応ソースを上記の方法で利用可能とすること,(2)あなた自身,当該著作物に関して当該特許ライセンスにより得られる利益を享受しないようにすること,又は(3)本許諾書の定めに適合する条件で,下流の受領者にも特許ライセンスが適用されるようにすること,の何れかの措置をとらなければならない。ここで「特許ライセンスに依拠していることを知りながら」とは,ある国において特許ライセンスなくして対象著作物をコンベイし,又は受領者が当該著作物を使用すると,当該国における特定の特許権を侵害することとなること,及び当該特許が有効であると信ずべき合理的理由があることのいずれについても,あなたが現実に知っていることをいう。
+
+あなたが取引又は取り決めに基づいて,もしくはそれに関連して,対象著作物をコンベイし又はコンベイされた対象著作物を入手してプロパゲートする場合において,当該著作物を受領した当事者の一部に対して,当該著作物を使用,プロパゲート,改変,またはコンベイする権限を供与する特許ライセンスを許諾する場合,当該特許ライセンスは,当該著作物及び当該著作物に基づく著作物の受領者のすべてに対して,自動的に拡大されるものとする。
+
+特許ライセンスが「差別的」(discriminatory)であるとは,本許諾書の下で認められている権利が特許ライセンスで許諾される範囲に含まれていない場合,本許諾書の下で認められている権利の行使を禁止している場合,又は本許諾書の下で認められている権利の不行使を条件として課している場合をいう。あなたがソフトウェアの供給を業とする第三者との間で,対象著作物をコンベイする行為に対してあなたが当該第三者に対価を支払い,当該第三者はあなたから当該著作物を受領したすべての当事者に対して(a)あなたがコンベイした対象著作物(又は当該著作物から作成された複製物)を対象として,もしくは(b)対象著作物を含む特定の製品又は対象著作物を他のものと同梱したものを主たる対象として,又はそれらに関連して,差別的な特許ライセンスを供与する旨の合意をしている場合,あなたは対象著作物をコンベイすることができない。ただし,当該合意又は当該特許ライセンスの供与がなされた時が2007年3月28日より以前である場合は,この限りでない。
+
+本許諾書のいかなる条項も,黙示的ライセンス,その他準拠法国の特許法において認められ得る特許侵害に対する抗弁を否定し又は制限する趣旨に解釈されてはならない。
+
+  12. 他者の自由の放棄の禁止
+
+本許諾書と矛盾する条件があなたに課せられた場合(裁判所による命令,契約,その他を問わない)でも,あなたは本許諾書の義務を免れることはできない。本許諾書上の義務と他の義務の両方をともに満たすような形で対象著作物をコンベイすることができない場合,あなたは,当該著作物をコンベイすることは一切許されない。例えば,あなたが,あなたから対象著作物をコンベイされた者がさらにコンベイをする行為に対してロイヤルティを徴求する義務を負う条項に同意していた場合,当該条項と本許諾書の両方の要求を充足しうる唯一の方法は,本プログラムのコンベイを完全に中止することである。
+
+  13. リモートネットワーク上のインタラクション; GNU 一般公衆利用許諾書と共に利用する場合
+
+本許諾書の他の条項のいかんに関わらず,あなたがプログラムを変更したのであれば,あなたの変更したバージョンは,(あなたのバージョンがそのようなやりとりをサポートするのであれば)コンピュータネットワーク上での遠隔的なやりとりを行う全てのユーザに,ネットワークサーバから無料で,なんらかの標準的あるいはソフトウェアのコピーを容易にする通例の手段で,対応ソースへのアクセスが提供されており,あなたのバージョンの対応ソースを受け取る機会が明確に提供されていなければならない。この対応ソースは,以下のパラグラフによりGNU 一般公衆利用許諾書バージョン3が適用されるあらゆる著作物のための対応ソースも含むものとする。
+
+本許諾書の他の条項のいかんに関わらず,あなたは,対象著作物をGNU 一般公衆利用許諾書バージョン3に基づいて許諾された著作物とリンクまたは結合して単一の結合された著作物とすること,及びその結果として作成された著作物をコンベイすることができる。本許諾書の条項は,当該結合された著作物中の対象著作物の部分に対しては引き続き適用されるが,しかしこれが結合された著作物は引き続きGNU 一般公衆利用許諾書バージョン3の基にあるものとする。
+
+  14. 本許諾書の改訂バージョン
+
+フリーソフトウェア財団は,GNU Affero 一般公衆利用許諾書の改訂バージョン又は新バージョンを場合に応じて発行することができる。そのような新バージョンは,その精神においては現在のバージョンと似たものになるであろうが,細部については新たな問題や懸念を解決すべく異なったものになるであろう。
+
+それぞれのバージョンには,異なるバージョン番号が付与される。本プログラムに,特定のバージョン番号のGNU Affero 一般公衆利用許諾書「又は,それ以降のバージョンのいずれか」(or any later version)が適用される旨が規定されている場合,当該特定の番号のバージョン,又はそれ以降にフリーソフトウェア財団によって発行されたバージョンのいずれの利用条件に従うかを,あなたが選択することができる。本プログラムがGNU Affero 一般公衆利用許諾書のバージョン番号を指定していない場合,あなたは,フリーソフトウェア財団が発行済みのバージョンの中からいずれのバージョンも選択することができる。 
+
+(訳注: 日本語訳のバージョンは日付で管理している。冒頭を見よ。)
+
+本プログラムに,GNU Affero 一般公衆利用許諾書の将来のバージョンのうちどれが適用されうるかを代理人が決定できる旨が規定されている場合において,当該代理人があるバージョンを受諾する旨を公衆に対して表明した場合,あなたは本プログラムについてそのバージョンを選択したことになる。
+
+本許諾書の今後のバージョンでは,追加的な,または従来とは異なる許諾が与えられるかもしれない。ただし,あなたが今後のバージョンを選択した場合でも,作成者及び著作権者に対して義務が追加的に課せられることはない。
+
+  15. 保証の否認
+
+本プログラムは,準拠法の下で認められる限りにおいて何らの保証もなされない。これと異なる書面による定めがなさる場合を除き,著作権者及びその他の当事者は,本プログラムをそのままの状態(as is)で,いかなる保証(明示的か黙示的かに関わらず,また,販売見込み又は特定の目的への適合性に関する黙示的保証を含み,これらに限定されない)もすることなく提供するものとする。本プログラムの品質及び性能に関するリスクは,すべてあなたが負うものとする。本プログラムに瑕疵のあることが明らかになった場合でも,必要な保守点検,修補,又は修正に要する費用は,すべてあなたの負担とする。
+
+  16. 責任の限定
+
+準拠法において義務が課されている場合,又は書面による合意がない限り,著作権者又は上記の定めに従い本プログラムを修正又はコンベイした当事者は,たとえ損害が発生するおそれのあることを彼らが事前に知らされていたとしても,あなたの被った損害について何らの責任も負わない。当該損害には,本プログラムを使用したことによるものと本プログラムを使用できなかったことによるもの(データの消失,誤ったデータの生成,損害を被ったのがあなたである場合と第三者である場合,及び本プログラムが他のプログラムと連携して適切に動作しない場合を含み,これらに限定されない)を問わず,一般的,特殊的,偶発的,必然的な損害のすべてを含む。
+
+  17. 第15条と第16条の解釈について
+
+係争の生じた地の法律において,上記の保証の否認及び責任限定の定めが規定どおりの効力を認められない場合,その地の法律の中で,本プログラムに関する民事上の責任の絶対的な放棄に最も近い法が,事件を審理する裁判所により適用されるものとする。ただし,保証又は賠償責任の負担が対価を伴うものである場合は,この限りでない。
+
+以上
\ No newline at end of file
diff --git a/apple-touch-icon.png b/apple-touch-icon.png
new file mode 100644 (file)
index 0000000..e043497
Binary files /dev/null and b/apple-touch-icon.png differ
diff --git a/coco.php b/coco.php
new file mode 100644 (file)
index 0000000..8829f9a
--- /dev/null
+++ b/coco.php
@@ -0,0 +1,201 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+//coco.php?q=ADDRESS&return=URL
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+require_once 'init_processor.php';
+// var_dump($_SESSION);
+?>
+<?php
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+$safequery = htmlspecialchars($_SERVER["QUERY_STRING"], ENT_QUOTES);
+?>
+<?php //セキュリティのための前処理。
+?>
+<?php
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+?>
+<?php
+//検索処理
+if (isset($_GET['q'])){
+}
+?>
+<?php
+if (isset($_GET['q'])){
+  $get_q = htmlspecialchars($_GET['q'], ENT_QUOTES);
+  $get_q = mb_convert_encoding($get_q, 'UTF-8', $charcode);
+  $address = mb_convert_encoding($_GET['q'], 'UTF-8', $charcode);
+  $address = urlencode($address);
+  if (isset($_GET['return'])) $get_return = htmlspecialchars($_GET['return'], ENT_QUOTES);
+  $json_url = "http://maps.google.com/maps/api/geocode/json?address={$address}&language=ja&sensor=false";
+  $page_head = "{$get_q} でイマココ";
+  $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?q={$get_q}";
+  if (isset($_GET['return'])) $self_anchor = $self_anchor.'&amp;return='.$get_return;
+  $coco_mode = 'coco-result';
+} else {
+  if (isset($_GET['return'])) $get_return = htmlspecialchars($_GET['return'], ENT_QUOTES);
+  $page_head = "検索してイマココ";
+  $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}";
+  if (isset($_GET['return'])) $self_anchor = $self_anchor.'?return='.$get_return;
+  $coco_mode = 'coco-ready';
+}
+$self_anchor_possibly_with_pagenum = $self_anchor;
+if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != ''){
+  $relog_back = $self_anchor_possibly_with_pagenum . '&log=try';
+  $relogin = $self_anchor_possibly_with_pagenum . '&amp;with=haiku&amp;callback='.rawurlencode($relog_back);
+} else {
+  $relog_back = $self_anchor_possibly_with_pagenum . '?log=try';
+  $relogin = $self_anchor_possibly_with_pagenum . '?with=haiku&amp;callback='.rawurlencode($relog_back);
+}
+if (isset($_GET['image']) && $_GET['image'] == 'on'){
+       if (preg_match('/^image=on$/u', $_SERVER['QUERY_STRING'])){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '?image=on';
+       } elseif (isset($_GET['log']) && preg_match('/^log=(on|off)$/u', $_SERVER['QUERY_STRING'])){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '?image=on';
+       } elseif ($_SERVER["QUERY_STRING"] != ""){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '&amp;image=on';
+       } else {
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '?image=on';
+       }
+} else {
+       if (preg_match('/^image=off$/u', $_SERVER['QUERY_STRING'])){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '?image=off';
+       } elseif (isset($_GET['log']) && preg_match('/^log=(off|on)$/u', $_SERVER['QUERY_STRING'])){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '?image=off';
+       } elseif ($_SERVER["QUERY_STRING"] != ""){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '&amp;image=off';
+       } else {
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '?image=off';
+       }
+}
+
+?>
+<?php
+$echo = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
+       <meta http-equiv="Content-Style-Type" content="text/css" />
+       <meta http-equiv="Content-Script-Type" content="text/javascript" />
+       <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
+       <title>{$page_head} - {$site_name} {$site_name_caption}</title>
+       <link rel="stylesheet" href="{$style_sheet}" />
+       <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" /></head>
+<body>
+EOL;
+?>
+<?php
+$echo = $echo . echoCommonHeader('#navigation-menu', $self_anchor_with_imagemode) . "<hr />\n";
+$echo = $echo . "<div id=\"header\" class=\"{$coco_mode}\">\n";
+$echo = $echo . "<h1 id=\"entries-head\" class=\"head1\">{$page_head}</h1>\n<hr /></div>";
+?>
+<?php
+$echo = $echo . '<div class="coco-search">';
+$echo = $echo . '<form method="get" action="" enctype="application/x-www-form-urlencoded" accept-charset="'.$meta_charset.'">'."\n";
+$echo = $echo . '<label for="cocoq">場所:</label>';
+$echo = $echo . '<input type="text" id="cocoq" name="q" maxlength="256" value="" title="場所を入力" />';
+$echo = $echo . '<input type="hidden" id="toreturn" name="return" value="'.$get_return.'" />';
+$echo = $echo . '<input type="submit" id="cocos" value="検索" title="場所を検索" />';
+$echo = $echo . '</form>';
+$echo = $echo . '</div>';
+?>
+<?php
+if (isset($_GET['q'])){
+  $echo = $echo . '<div class="geo-result">';
+  $request_url = $json_url;
+  $json = getJson($request_url, FALSE);
+  if ($json['stat'] !== TRUE){
+       $contents = strip_tags($json['stat']);
+       $echo = $echo . "<p>Google Geocoding API からデータを取得できなかったような気がします。</p>\n";
+       $echo = $echo . "<blockquote>";
+       if (isset($json['http'])) $echo = $echo . "HTTP {$json['http']}<br />";
+       $echo = $echo . "{$json['stat']}<br />{$contents}</blockquote>\n";
+  } else {
+       $json_body = $json['body'];
+       $contents = json_decode($json_body);
+//     var_dump($contents);
+//     var_dump($contents->status);
+       if (!isset($contents->status)){
+         $error = 'json';
+//       $error_mes = libxml_get_last_error();
+         $echo = $echo . "<p>はわわ、何かのエラーです。</p>";
+         $echo = $echo . "<blockquote>{$json_body}</blockquote>";
+//       var_dump($error_mes);
+       } elseif ($contents->status != 'OK'){
+         $error = 'staus';
+         if ($contents->status == 'ZERO_RESULTS'){
+               $error_mes = $contents->status.': 住所が見つかりません。';
+         } elseif ($contents->status == 'OVER_QUERY_LIMIT'){
+               $error_mes = $contents->status.': 現在検索できません。';
+         } elseif ($contents->status == 'REQUEST_DENIED'){
+               $error_mes = $contents->status.': 要求が成立しませんでした。';
+         } elseif ($contents->status == 'INVALID_REQUEST'){
+               $error_mes = $contents->status.': クエリーが不正です。';
+         }
+       } else {
+         $error = 'noerror';
+       }
+       if ($error == 'json'){
+       } elseif ($error == 'status'){
+         $echo = $echo . '<p>'.$error_mes.'</p>';
+       } else {
+         $echo = $echo . '<ul class="coco-list">';
+         foreach ($contents->results as $val){
+               if (isset($_GET['return'])){
+                 $parsed_url = parse_url($_GET['return']);
+                 if ($parsed_url['query'] != ''){
+                       $return_base_url = $_GET['return'].'&amp;';
+                 } else {
+                       $return_base_url = $_GET['return'].'?';
+                 }
+               } else {
+                 $return_base_url = "./entries.php?";
+               }
+               $return_url = $return_base_url."body=".rawurlencode("{$val->formatted_address} にイマココ!\nmap:{$val->geometry->location->lat}:{$val->geometry->location->lng}").'&amp;from='.rawurlencode($val->address_components[0]->long_name);
+               $echo = $echo . '<li>';
+               $echo = $echo . "<p><a href=\"{$return_url}\" class=\"navigation-link\">";
+               $echo = $echo . $val->formatted_address . ' にイマココする';
+               $echo = $echo . '</a></p>';
+                 $echo = $echo . "<a href=\"http://www.google.co.jp/m/local?site=local&amp;q={$val->geometry->location->lat}%2C{$val->geometry->location->lng}\" class=\"external-link\">";
+               if ($get_image == 'on') {
+                 $echo = $echo . "<img src=\"http://maps.google.com/maps/api/staticmap?maptype=mobile&amp;markers={$val->geometry->location->lat}%2C{$val->geometry->location->lng}&amp;sensor=false&amp;size=140x140&amp;zoom=13\" width=\"140\" height=\"140\" />";
+               } else {
+                 $echo = $echo . "→Google Maps で確認";
+               }
+                 $echo = $echo . "</a>";
+               $echo = $echo . '</li>'."\n";
+         }
+         $echo = $echo . '</ul>';
+       }
+  }
+//   var_dump($error);
+  $echo = $echo . "</div>";
+}
+$echo = $echo . '<p class="credit">位置情報の取得には <a href="' . $mobile_gateway . 'http://code.google.com/intl/ja/apis/maps/documentation/geocoding/">Google Geocoding API</a> を利用しています。</p>'."\n".'<hr />';
+?>
+<?php
+$navi_paging = FALSE;
+$navi_imaging = TRUE;
+require 'footer_include.php';
+$echo = $echo . '</body></html>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+?>
\ No newline at end of file
diff --git a/common_functions.php b/common_functions.php
new file mode 100644 (file)
index 0000000..fea65dc
--- /dev/null
@@ -0,0 +1,277 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/ormodify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php defined("HELLO") or exit(); ?>
+<?php
+//NULL バイトの入力を弾く
+function checkNull($array){
+       if (is_array($array)){
+               return array_map('checkNull', $array);
+       }
+       if (preg_match('/\0/', $array)){
+               echo "NULL ぽ";
+               exit();
+       }
+}
+//正しいはてなID=アルファベットで始まり、アルファベットか数字で終わる3文字以上、32文字以内の半角英数字
+//2012-01-09: DSi の id にも対応。
+function checkId($element){
+       if (preg_match("/^[a-zA-Z1234567890]{1}[-_a-zA-Z1234567890@]{1,30}[a-zA-Z1234567890]{1} *$/u" ,$element) == 0){
+               echo "なにそれこわい\n(YANMAH2: はてなIDの指定に関するエラー)";
+               exit();
+       }
+}
+function checkHttpUrl($element){
+       if (preg_match("/^s?https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:@&=+$,%#]+$/u", $element) == 0){
+               echo ':return パラメータの値が不正の様な気がします。';
+               exit();
+       }
+}
+function checkKeyword($element){
+       if (strlen(bin2hex($element)) > 511){
+               echo "キーワードが長すぎて入らないです…\n(YANMAH2: キーワードの指定に関するエラー)";
+               exit();
+       }
+}
+//page=n は100までの数値であること。
+function checkPagenum($element){
+       if (preg_match("/^[1234567890]{1,3}$/u",$element) == 0){
+               echo "数字以外入れちゃだめ\n(YANMAH2: ページ数に関するエラー)";
+               exit();
+       }
+       if ($element > 100){
+               echo "ページ数が大きすぎです…\n(YANMAH2: ページ数に関するエラー)";
+               exit();
+       }
+}
+function checkImagemode($element){
+       if (!preg_match('/^(on|off)$/u', $element)){
+               echo 'んっ!? って思うパラメータは処理しないし。(YANMAH2: 画像モードに関するエラー)';
+               exit();
+       }
+}
+function checkAlbum($element){
+       if (strlen(bin2hex($element)) > 514){
+       echo "はうあ\n";
+       exit();
+}
+}
+function checkEntryid($element){
+       if (preg_match("/^[1234567890]+$/u",$element) === FALSE){
+               echo "エントリさーん、どこですかー\n(YANMAH2: Entry ID に関するエラー)";
+               exit();
+       }
+}
+function checkWord($element){
+       if (strlen(bin2hex($element)) > 511){
+               echo "キーワードが長すぎて入らないです…\n(YANMAH2: キーワードの指定に関するエラー)";
+               exit();
+       }
+}
+function echoHateBxml($object){
+  $ret = '<dl>';
+  $ret = $ret . '<dt><a href="';
+  foreach ($object->link as $val){
+       if ($val->attributes()->rel == 'related') $href = $val->attributes()->href;
+  }
+  $ret = $ret . $href;
+  $ret = $ret . '" class="external-link">'.$object->title.'</a></dt>';
+  $ret = $ret . '<dd>'. $object->author->name .'</dd>';
+  $ret = $ret . '<dd>'. $object->summary .'</dd>';
+  $ret = $ret . '<dd>'. $object->issued .'</dd>';
+  $ret = $ret . '</dl>';
+  return $ret;
+}
+function checkEntryData($data){
+  $contents = simplexml_load_string($data);
+  $error = libxml_get_last_error();
+  if ($error !== FALSE){
+       $ret['ercode'] = $error->code;
+       $ret['ermes'] = $error->message;
+       $ret['contents'] = $contents;
+       $ret['stat'] = FALSE;
+  } elseif (isset($contents->error)){
+       $ret['ercode'] = 'x';
+       $ret['ermes'] = $contents->error;
+       $ret['contents'] = $contents;
+       $ret['stat'] = FALSE;
+  } else {
+       $ret['contents'] = $contents;
+       $ret['stat'] = TRUE;
+  }
+  return $ret;
+}
+function echoCommonHeader($bottom = '#navigation-menu', $return = ''){
+  if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+       $common_header = '<div id="com-hdr"><span class="header-log"> <a href="./login.php?log=out" class="navigation-link">ログアウト</a></span> <span class="to-bottom"><a href="#navigation-menu" class="navigation-link" accesskey="#">[#]下へ</a></span></div>';
+  } else {
+       $common_header = '<div id="com-hdr"><span class="header-log"><a href="./login.php?return='.rawurlencode($return).'" class="navigation-link">ログイン</a></span> <span class="to-bottom"><a href="'.$bottom.'" class="navigation-link" accesskey="#">[#]下へ</a></span></div>';
+  }
+  return $common_header;
+}
+function echoCommonFooter($top = '#page'){
+  global $get_image;
+  $common_footer = '<div id="com-ftr"><span class="ftr-cnf"><a href="./config.php?image='.$get_image.'" class="navigation-link">設定</a></span> <span class="to-top"><a href="'.$top.'" class="navigation-link" accesskey="*">[*]上へ</a></span></div><hr />';
+  return $common_footer;
+}
+function pullLot($ary = array(0, 1)){
+  shuffle($ary);
+  return $ary[0];
+}
+function echoPhotozou($photo_id, $mgw){
+  $api = 'http://api.photozou.jp/rest/photo_info?photo_id='.$photo_id;
+  $get_xml = getJson($api, FALSE);
+  if ($get_xml['stat'] !== TRUE){
+       $ret = '.';
+       return $ret;
+  }
+  $xml = simplexml_load_string($get_xml['body']);
+  $error = libxml_get_last_error();
+  if ($error !== FALSE){
+       $ret = '..';
+  } elseif ($xml->attributes()->stat != 'ok'){
+       $ret = '...';
+  } else {
+       $thumb = $xml->info->photo->thumbnail_image_url;
+       $title = $xml->info->photo->photo_title;
+       $desc = $xml->info->photo->description;
+       $ret = "<img src=\"{$mgw}".rawurlencode($thumb)."\" alt=\"{$desc}\" />";
+  }
+  libxml_clear_errors();
+  return $ret;
+}
+?>
+<?php
+function getRequest($init_url, $callback_url, $scope, $conkey, $conkey_sec){
+  global $user_agent;
+  try{
+  require_once 'HTTP/OAuth/Consumer.php';
+  $oauth_con = new HTTP_OAuth_Consumer($conkey, $conkey_sec);
+  $req = new HTTP_Request2();
+  $req->setConfig('ssl_verify_peer', false);
+  $req->setHeader('User-Agent', $user_agent);
+  $con_req = new HTTP_OAuth_Consumer_Request;
+  $con_req->accept($req);
+  $oauth_con->accept($con_req);
+  $oauth_con->getRequestToken($init_url, $callback_url, array('scope' => $scope));
+  $ret = array();
+  $ret['token'] = $oauth_con->getToken();
+  $ret['secret'] = $oauth_con->getTokenSecret();
+  $ret['stat'] = TRUE;
+  } catch(Exception $e){
+  $ret['error'] = $e->getMessage();
+  $ret['stat'] = $ret['error'];
+  }
+  return $ret;
+}
+function getAccess($token_url, $reqtoken, $req_sec, $verifier, $conkey, $conkey_sec){
+  global $user_agent;
+  try{
+  require_once 'HTTP/OAuth/Consumer.php';
+  $oauth_con = new HTTP_OAuth_Consumer($conkey, $conkey_sec, $reqtoken, $req_sec);
+  $req = new HTTP_Request2();
+  $req->setConfig('ssl_verify_peer', false);
+  $req->setHeader('User-Agent', $user_agent);
+  $con_req = new HTTP_OAuth_Consumer_Request;
+  $con_req->accept($req);
+  $oauth_con->accept($con_req);
+  $oauth_con->getAccessToken($token_url, $verifier);
+  $lastreq = $req->getLastEvent();
+  $res = $lastreq['data'];
+//   $ret['ob'] = $oauth_con;
+  $ret['token'] = $oauth_con->getToken();
+  $ret['secret'] = $oauth_con->getTokenSecret();
+  $ret['body'] = $res->getBody();
+  $ret['stat'] = TRUE;
+  } catch(Exception $e){
+  $ret['trace'] = $e->getTrace();
+  $ret['error'] = $e->getMessage();
+  $ret['stat'] = $ret['error'];
+  }
+  return $ret;
+}
+function getJson($get_url, $use_oauth, $conkey = '', $conkey_sec = '', $acskey = '', $acskey_sec = ''){
+global $user_agent;
+if ($use_oauth === TRUE){
+  try {
+       require_once 'HTTP/OAuth/Consumer.php';
+       $oauth_con = new HTTP_OAuth_Consumer($conkey, $conkey_sec);
+       $req = new HTTP_Request2();
+       $req->setConfig('ssl_verify_peer', false);
+       $req->setHeader('User-Agent', $user_agent);
+       $con_req = new HTTP_OAuth_Consumer_Request;
+       $con_req->accept($req);
+       $oauth_con->accept($con_req);
+       $oauth_con->setToken($acskey);
+       $oauth_con->setTokenSecret($acskey_sec);
+       $res = $oauth_con->sendRequest($get_url);
+       $ret['http'] = $res->getStatus();
+       $ret['body'] = preg_replace('/[\x00-\x1f]/u', "", $res->getBody());
+       $ret['stat'] = TRUE;
+  } catch (Exception $e){
+       $ret['stat'] = $e->getMessage();
+  }
+  return $ret;
+} else {
+  try {
+       require_once "HTTP/Request2.php";
+       $req = new HTTP_Request2($get_url);
+       $req->setHeader('User-Agent', $user_agent);
+       $res = $req->send();
+       $ret['http'] = $res->getStatus();
+       $ret['body'] = preg_replace('/[\x00-\x1f]/u', "", $res->getBody());
+       $ret['stat'] = TRUE;
+  } catch (Exception $e){
+       $ret['stat'] = $e->getMessage();
+  }
+  return $ret;
+}
+}
+function postGeneric($api, $postdata = array(), $conkey, $conkey_sec, $acskey, $acskey_sec, $body = ''){
+  global $user_agent;
+  try {
+       require_once 'HTTP/OAuth/Consumer.php';
+       $oauth_con = new HTTP_OAuth_Consumer($conkey, $conkey_sec);
+       $req = new HTTP_Request2();
+       $req->setConfig('ssl_verify_peer', false);
+       $req->setHeader('User-Agent', $user_agent);
+       if ($body != '') $req->setBody($body);
+//     $req->addUpload('file', './apple-touch-icon.png');
+       $con_req = new HTTP_OAuth_Consumer_Request;
+       $con_req->accept($req);
+       $oauth_con->accept($con_req);
+//     $oauth_con->setSignatureMethod("HMAC-SHA1");
+       $oauth_con->setToken($acskey);
+       $oauth_con->setTokenSecret($acskey_sec);
+       $res = $oauth_con->sendRequest($api, $postdata, "POST");
+       $ret['http'] = $res->getStatus();
+//     var_dump($http);
+       $ret['body'] = $res->getBody();
+//     $ret['session'] = $_SESSION;
+       $ret['stat'] = TRUE;
+  } catch (Exception $e){
+       $ret['error'] = $e->getMessage();
+//     $ret['session'] = $_SESSION;
+       $ret['stat'] = FALSE;
+  }
+  return $ret;
+}
+
+function whatDevice($useragent){
+  if (preg_match("/willcom|mobilephone|ddipocket|pdxgw|astel|docomo|up\.browser|j-phone|vodafone|softbank/i", $useragent)){
+       return 'ktai';
+  } elseif (preg_match("/Opera Mobi/i", $useragent)){
+       return 'iphone';
+  } elseif (preg_match("/Android (1\.6|1\.5)/i", $useragent)){
+       return 'android-old';
+  } elseif (preg_match("/Android/i", $useragent)){
+       return 'android';
+  } elseif (preg_match("/Mobile.*Safari/i", $useragent)){
+       return 'iphone';
+  } else {
+       return 'generic';
+  }
+}
+?>
\ No newline at end of file
diff --git a/config.php b/config.php
new file mode 100644 (file)
index 0000000..f3048e4
--- /dev/null
@@ -0,0 +1,381 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+checkNull($_POST);
+// var_dump($_POST);
+if (isset($_POST['count']) && preg_match("/^[0123456789]{1,3}$/", $_POST['count'])){
+  $pcount = $_POST['count'];
+  $setck = 1;
+} else {
+  $pcount = '';
+  $setck = 0;
+}
+if (isset($_POST['showicon']) && preg_match("/^(yes|no)$/", $_POST['showicon'])){
+  $pshowicon = $_POST['showicon'];
+  $setck = 1;
+} else {
+  $pshowicon = '';
+  $setck = 0;
+}
+if (isset($_POST['disbr']) && preg_match("/^(yes|no)$/", $_POST['disbr'])){
+  $pdisbr = $_POST['disbr'];
+  $setck = 1;
+} else {
+  $pdisbr = '';
+  $setck = 0;
+}
+if (isset($_POST['starisjs']) && preg_match("/^(0|1)$/", $_POST['starisjs'])){
+  $pstarisjs = $_POST['starisjs'];
+  $setck = 1;
+} else {
+  $pstarisjs = '';
+  $setck = 0;
+}
+if (isset($_POST['elimit']) && preg_match("/^[0123456789]{1,3}$/", $_POST['elimit'])){
+  $pelimit = $_POST['elimit'];
+  $setck = 1;
+} else {
+  $pcount = '';
+  $setck = 0;
+}
+if (isset($_POST['hdomain']) && preg_match("/^(h|h1beta)(\.hatena\.ne\.jp|\.hatena\.com)$/", $_POST['hdomain'])){
+  $phdomain = $_POST['hdomain'];
+  $setck = 1;
+} else {
+  $phdomain = '';
+  $setck = 0;
+}
+if (isset($_POST['iscale']) && preg_match("/^[[:digit:]]{1}\.{0,1}[[:digit:]]{0,1}$/", $_POST['iscale'])){
+  $piscale = $_POST['iscale'];
+  $setck = 1;
+} else {
+  $piscale = '';
+  $setck = 0;
+}
+
+if ($setck == 1){
+  setcookie('y2config', 'count=' . $pcount . '&showicon=' . $pshowicon . '&disbr=' . $pdisbr . '&elimit=' . $pelimit . '&hdomain=' . $phdomain . '&iscale=' . $piscale . '&starisjs=' . $pstarisjs, time()+60*60*24*365);
+}
+?>
+<?php
+require_once 'init_processor.php';
+// var_dump($_SESSION);
+if (isset($_POST['count']) && preg_match("/^[0123456789]{1,3}$/", $_POST['count'])){
+  $y2count = $_POST['count'];
+} elseif (isset($y2config['count']) && $y2config['count'] != '' && preg_match("/^[0123456789]{1,3}$/", $y2config['count'])){
+  $y2count = $y2config['count'];
+} else {
+  $y2count = 'default';
+}
+if (isset($_POST['showicon']) && preg_match("/^(yes|no)$/", $_POST['showicon'])){
+  $showicon = $_POST['showicon'];
+} elseif (isset($y2config['showicon']) && $y2config['showicon'] != '' && preg_match("/^(yes|no)$/", $y2config['showicon'])){
+  $showicon = $y2config['showicon'];
+} else {
+  $showicon = 'default';
+}
+if (isset($_POST['disbr']) && preg_match("/^(yes|no)$/", $_POST['disbr'])){
+  $disbr = $_POST['disbr'];
+} elseif (isset($y2config['disbr']) && $y2config['disbr'] != '' && preg_match("/^(yes|no)$/", $y2config['disbr'])) {
+  $disbr = $y2config['disbr'];
+}else {
+  $disbr = 'default';
+}
+if (isset($_POST['starisjs']) && preg_match("/^(0|1)$/", $_POST['starisjs'])){
+  $starisjs = $_POST['starisjs'];
+} elseif (isset($y2config['starisjs']) && $y2config['starisjs'] != '' && preg_match("/^(0|1)$/", $y2config['starisjs'])) {
+  $starisjs = $y2config['starisjs'];
+}else {
+  $starisjs = '0';
+}
+if ($starisjs == 1){
+  $star_is_js = 'する';
+} else {
+  $star_is_js = 'しない';
+}
+if (isset($_POST['elimit']) && preg_match("/^[0123456789]{1,3}$/", $_POST['elimit'])){
+  $entry_limit = $_POST['elimit'];
+} elseif (isset($y2config['elimit']) && $y2config['elimit'] != '' && preg_match("/^[0123456789]{1,3}$/", $y2config['elimit'])){
+  $entry_limit = $y2config['elimit'];
+} else {
+  $entry_limit = $entry_limit;
+}
+if (isset($_POST['hdomain']) && preg_match("/^(h|h1beta)(\.hatena\.ne\.jp|\.hatena\.com)$/", $_POST['hdomain'])){
+  $hdomain = $_POST['hdomain'];
+} elseif (isset($y2config['hdomain']) && preg_match("/^(h|h1beta)(\.hatena\.ne\.jp|\.hatena\.com)$/", $y2config['hdomain'])){
+  $hdomain = $y2config['hdomain'];
+} else {
+  $hdomain = 'default';
+}
+if (isset($_POST['iscale']) && preg_match("/^[[:digit:]]{1}\.{0,1}[[:digit:]]{0,1}$/", $_POST['iscale'])){
+  $iscale = $_POST['iscale'];
+} elseif (isset($y2config['iscale']) && $y2config['iscale'] != '' && preg_match("/^[[:digit:]]{1}\.{0,1}[[:digit:]]{0,1}$/", $y2config['iscale'])){
+  $iscale = $y2config['iscale'];
+} else {
+  $iscale = '1';
+}
+?>
+<?php
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+?>
+<?php
+$page_head = 'YANMAH2 の設定';
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+$self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}";
+if ($get_image == 'on'){
+               $self_anchor_with_imagemode = $self_anchor . '?image=on';
+} else {
+               $self_anchor_with_imagemode = $self_anchor;
+}
+$echo = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
+       <meta http-equiv="Content-Style-Type" content="text/css" />
+       <meta http-equiv="Content-Script-Type" content="text/javascript" />
+       <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
+       <title>{$page_head} - {$site_name} {$site_name_caption}</title>
+       <link rel="stylesheet" href="{$style_sheet}" />
+       <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" /></head>
+<body>
+<div id="page">
+EOL;
+?>
+<?php
+// var_dump($_SESSION);
+//var_dump($_POST);
+//var_dump($_GET);
+$echo = $echo . echoCommonHeader('./login.php', $self_anchor_with_imagemode) . "<hr />\n";
+$echo = $echo . "<div id=\"header\" class=\"user_timeline\">\n";
+$echo = $echo . "<h1 id=\"entries-head\" class=\"head1\">{$page_head}</h1>\n<hr />";
+$echo = $echo . "</div>\n";
+?>
+<?php
+$echo = $echo . <<<EOL
+<div class="cnf-blk">
+<h2>現在の設定</h2>
+<ul>
+  <li>タイムライン一頁に表示するエントリの件数:$y2count</li>
+  <li>画像省略時もユーザのアイコンを表示する:$showicon</li>
+  <li>タイムラインで改行を減らす:$disbr</li>
+  <li>はてなスターを JavaScript で処理する:$star_is_js</li>
+  <li>各エントリの表示文字数制限の基準幅:$entry_limit</li>
+  <li>はてなハイクのドメイン:$hdomain</li>
+  <li>Viewport の initial-scale:$iscale</li>
+</ul>
+</div>
+<hr />
+EOL;
+?>
+<?php
+$echo = $echo . '<form method="post" action="">';
+$echo = $echo . <<<EOL
+<div class="cnf-blk">
+<h2>設定変更</h2>
+<div>
+<label for="entries-count">タイムライン一頁に表示するエントリの件数:</label>
+  <select name="count" id="entries-count">
+       <option value="1"
+EOL;
+if (isset($y2count) && $y2count == '1') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>1</option>
+       <option value="5"
+EOL;
+if (isset($y2count) && $y2count == '5') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>5</option>
+       <option value="10"
+EOL;
+if (isset($y2count) && $y2count == '10') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>10</option>
+       <option value="15"
+EOL;
+if (isset($y2count) && $y2count == '15') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>15</option>
+       <option value="20"
+EOL;
+if (isset($y2count) && ($y2count == '20' || $y2count == 'default')) $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>20</option>
+       <option value="25"
+EOL;
+if (isset($y2count) && $y2count == '25') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>25</option>
+       <option value="50"
+EOL;
+if (isset($y2count) && $y2count == '50') $echo = $echo . ' selected="selected"';
+$echo = $echo. <<<EOL
+>50</option>
+       <option value="100"
+EOL;
+if (isset($y2count) && $y2count == '100') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>100</option>
+  </select>
+</div>
+EOL;
+?>
+<?php
+$echo = $echo . <<<EOL
+<div>
+<label for="show-icon">画像省略時もユーザのアイコンを表示する:</label>
+  <select name="showicon" id="show-icon">
+       <option value="no"
+EOL;
+if (isset($showicon) && ($showicon == 'no' || $showicon == 'default')) $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>表示しない</option>
+       <option value="yes"
+EOL;
+if (isset($showicon) && $showicon == 'yes') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>表示する</option>
+  </select>
+</div>
+EOL;
+?>
+<?php
+$echo = $echo . <<<EOL
+<div>
+<label for="dis-break">タイムラインで改行を減らす:</label>
+  <select name="disbr" id="dis-break">
+       <option value="yes"
+EOL;
+if (isset($disbr) && ($disbr == 'yes' || $disbr == 'default')) $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>減らす</option>
+       <option value="no"
+EOL;
+if (isset($disbr) && $disbr == 'no') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>減らさない</option>
+  </select>
+</div>
+EOL;
+?>
+<?php
+$echo = $echo . <<<EOL
+<div>
+<label for="star-script">はてなスターを JavaScript で処理する:</label>
+  <select name="starisjs" id="star-script">
+       <option value="0"
+EOL;
+if (isset($starisjs) && ($starisjs == '0' || $starisjs == 'default')) $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>しない</option>
+       <option value="1"
+EOL;
+if (isset($starisjs) && $starisjs == '1') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>する</option>
+  </select>
+</div>
+EOL;
+?>
+<?php
+$echo = $echo . <<<EOL
+<div>
+<label for="trim-width">各エントリの表示文字数制限の基準幅:</label>
+  <input type="text" name="elimit" id="trim-width" value="{$entry_limit}" size="3" maxlength="3" />
+</div>
+EOL;
+?>
+<?php
+$echo = $echo . <<<EOL
+<div>
+<label for="haiku-domain">はてなハイクのドメイン:</label>
+  <select name="hdomain" id="haiku-domain">
+       <option value="h.hatena.ne.jp"
+EOL;
+if (isset($hdomain) && ($hdomain == 'h.hatena.ne.jp' || $hdomain == 'default')) $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>.ne.jp</option>
+       <option value="h.hatena.com"
+EOL;
+if (isset($hdomain) && $hdomain == 'h.hatena.com') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>.com</option>
+  </select>
+</div>
+EOL;
+//     <option value="h1beta.hatena.ne.jp"
+// EOL;
+// if (isset($hdomain) && $hdomain == 'h1beta.hatena.ne.jp') $echo = $echo . ' selected="selected"';
+// $echo = $echo . <<<EOL
+// >.ne.jp(beta)</option>
+//     <option value="h1beta.hatena.com"
+// EOL;
+// if (isset($hdomain) && $hdomain == 'h1beta.hatena.com') $echo = $echo . ' selected="selected"';
+// $echo = $echo . <<<EOL
+// >.com(beta)</option>
+?>
+<?php
+$echo = $echo . <<<EOL
+<div>
+<label for="ini-scl">Viewport の initial-scale:</label>
+  <select name="iscale" id="ini-scl">
+       <option value="1"
+EOL;
+if (isset($iscale) && ($iscale == '1' || $iscale == 'default')) $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>1</option>
+       <option value="0.8"
+EOL;
+if (isset($iscale) && $iscale == '0.8') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>0.8</option>
+       <option value="0.6"
+EOL;
+if (isset($iscale) && $iscale == '0.6') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>0.6</option>
+       <option value="0.4"
+EOL;
+if (isset($iscale) && $iscale == '0.4') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>0.4</option>
+       <option value="0.2"
+EOL;
+if (isset($iscale) && $iscale == '0.2') $echo = $echo . ' selected="selected"';
+$echo = $echo . <<<EOL
+>0.2</option>
+  </select>
+</div>
+EOL;
+?>
+<?php
+$echo = $echo . '<input type="submit" value="OK" id="config-save" /><label for="config-save">(設定を Cookie に保存します)</label>';
+$echo = $echo . "</form>\n</div>\n<hr />";
+?>
+<?php
+$navi_paging = FALSE;
+$navi_imaging = FALSE;
+require 'footer_include.php';
+$echo = $echo . '</div></body></html>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+if (isset($_SESSION['oauth_stat'])) unset($_SESSION['oauth_stat']);
+?>
\ No newline at end of file
diff --git a/configurable_variables.php b/configurable_variables.php
new file mode 100644 (file)
index 0000000..39ae625
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php defined("HELLO") or exit(); ?>
+<?php
+//****************************************************
+//このプログラムを設置・管理する責任者名を記入する。
+$admin_name = "ここに設置者の名前を記入";
+//上の設置者と連絡をとる手段、またはその情報を含む URLを記入する。
+$admin_url = "http://h.example.ne.jp/user/";
+//****************************************************
+//エントリの表示文字数制限の基準値(文字幅)
+$entry_limit = 700;
+//インクルードパスの設定。"default" でシステムの設定をそのまま使用する。
+//パスを記入するとそのパスが追加される。
+$extra_include_path = "default";
+//モバイルゲートウェイの URL
+$mobile_gateway = "http://www.google.co.jp/gwt/n?u=";
+//利用するハイクのホスト(h.hatena.ne.jp|h.hatena.com)
+$haiku_host = "h.hatena.ne.jp";
+//ハイク公式の URL
+$haiku_official_url = "http://{$haiku_host}/mobile/";
+//API のベース URL
+$api_base_url = "http://{$haiku_host}/api/";
+//OAuth コンシューマキー
+$conkey = "";
+//OAuth コンシューマキー・シークレット
+$conkey_sec = "";
+//設置するウェブサイト名称
+$site_name = "はてなハイク 非公式モバイル版";
+//サイト名のキャプション
+$site_name_caption = "";
+//セッションクッキーの有効期間(秒)
+$session_cookie_expire = 60 * 60 * 24 * 7;
+//セッションデータの有効期間(秒)
+$session_file_lifetime = $session_cookie_expire;
+//セッションデータの一時保存ディレクトリ
+$custom_session_save_path = 'default';
+//セッションファイルに対するガベージコレクタの作動率(array(分子, 分母))
+//array('default','default') ならサーバの設定が使われる。
+$session_gc_prob = array('1', '100');
+//画像縮小用のモバイルゲートウェイの URL
+$mobile_gateway_for_images = 'http://mgw.hatena.ne.jp/?';
+//スタイルシートへのパス
+$style_sheet = './style.php';
+//デフォルトの文字コード(UTF-8|SJIS|JIS|EUC-JP)
+$charcode = 'UTF-8';
+//****************************************************
+//各ページに共通のフッタを記入する。
+$footer = <<<EOL
+<div id="footer">
+<address>
+はてなハイク by <a href="http://mobile.hatena.ne.jp/">はてな</a><br />
+{$product_name_abbr} PHP scripts by <a href="{$mobile_gateway}{$project_url}">{$project_name}</a><br />
+設置者:<a href="{$mobile_gateway}{$admin_url}">$admin_name</a><br />
+<a href="./about.php">{$product_name_abbr} について</a>
+</address>
+</div>
+EOL;
+//ログインページに表示する注意書き。
+$login_notice = <<<EOL
+<div class="notice">
+<ul>
+<li>上のリンクを開き、{$product_name_abbr} に読み書きの許可を与えてください。</li>
+<li>OAuth 認証の仕組みを利用して、はてなから情報を読み書きするための権限を取得します。{$product_name_abbr} が要求する権限と用途は次の通りです。
+ <dl>
+  <dt>read_public</dt><dd>タイムラインの読み込みに使用します。</dd>
+  <dt>write_public</dt><dd>投稿と星を付けるために使用します。</dd>
+  <dt>write_private</dt><dd>はてなブックマークがプライベートに設定されている場合、{$product_name_abbr} からの追加機能を使うときに必要です。</dd>
+ </dl>
+</li>
+<li>セッション Cookie / サーバ側セッションデータの有効期間は {$session_cookie_expire} / {$session_file_lifetime} 秒に設定されています。</li>
+<li>取得した認証情報は、この {$product_name_abbr} が設置されているサーバに一時的に保存され、投稿などの際にはてなに送信されます。利用後、サーバから明示的に消去したい場合は、ログアウトしてください。</li>
+</ul>
+</div>
+EOL;
+?>
diff --git a/entries.php b/entries.php
new file mode 100644 (file)
index 0000000..a2fb9c6
--- /dev/null
@@ -0,0 +1,484 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2014 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+require_once 'init_processor.php';
+// var_dump($_SESSION);
+if (isset($_GET["reftime"]) && $_GET["reftime"] != '') {
+  header('Cache-Control: private, max-age=' . 60*60*24);
+}
+?>
+<?php
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+$safequery = htmlspecialchars($_SERVER["QUERY_STRING"], ENT_QUOTES);
+?>
+<?php //セキュリティのための前処理。
+//長すぎる keyword
+if (isset($_GET["keyword"])) checkKeyword($_GET["keyword"]);
+if (isset($_GET['word'])) checkKeyword($_GET['word']);
+if (isset($_GET['users'])) checkKeyword($_GET['users']);
+if (isset($_GET["user"])) {
+  checkId($_GET["user"]);
+  $_GET['user'] = preg_replace("/ +$/u", "", $_GET['user']);
+  }
+if (isset($_GET["following"])) {
+  checkId($_GET["following"]);
+  $_GET['following'] = preg_replace("/ +$/u", "", $_GET['following']);
+}
+//不正な page
+if (isset($_GET['page'])) checkPagenum($_GET['page']);
+if (isset($_GET['image'])) checkImagemode($_GET['image']);
+if (isset($_SESSION['image'])) checkImagemode($_SESSION['image']);
+if (isset($_GET['album'])) checkAlbum($_GET['album']);
+?>
+<?php
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+?>
+<?php
+//
+if (isset($_GET['with']) || isset($_GET['log'])){
+  require 'login_processor.php';
+}// if (isset($_SESSION['oauth_stat'])) session_regenerate_id(TRUE);
+
+//投稿処理の呼び出し。
+//var_dump($_POST);
+if (isset($_POST['posting'])){
+// if (isset($_SESSION['postkey']) && isset($_POST['postkey']) && md5($_SESSION['postkey']) == $_POST['postkey']){
+//   unset($_SESSION['postkey']);
+/*var_dump($_POST);
+exit();*/
+  require 'post_processor.php';
+// }
+}
+?>
+<?php
+//前置きはこのくらいにして、本題に入る!
+if (isset($_GET["keyword"]) && $_GET["keyword"] != ''){
+       $get_keyword = htmlspecialchars($_GET["keyword"], ENT_QUOTES);
+       $json_url = "{$api_base_url}statuses/keyword_timeline.xml?word=" . rawurlencode($_GET['keyword']) . "&body_formats=html_touch";
+       $page_head = $get_keyword . " でひとこと";
+       $official = "{$haiku_official_url}keyword/" . rawurlencode($_GET['keyword']);
+       $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?keyword=" . rawurlencode($_GET['keyword']);
+       $entries_mode = 'keyword_timeline';
+}      elseif (isset($_GET["user"]) && $_GET["user"] != ''){
+               $get_user = htmlspecialchars($_GET["user"], ENT_QUOTES);
+               $json_url = "{$api_base_url}statuses/user_timeline/".$_GET['user'].".xml?body_formats=html_touch";
+               $page_head = "{$get_user} のエントリー";
+               $official = "{$haiku_official_url}{$get_user}/";
+               $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?user=".rawurlencode($_GET['user']);
+               $entries_mode = 'user_timeline';
+}      elseif (isset($_GET["following"]) && $_GET["following"] != ''){
+               $get_following = htmlspecialchars($_GET["following"], ENT_QUOTES);
+               $json_url = "{$api_base_url}statuses/friends_timeline/".$_GET['following'].".xml";
+               if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE
+                   && $get_following == $_SESSION['hatenaid']){
+                   $json_url_noaouth = $json_url . "?body_formats=html_touch";
+                   $json_url = "{$api_base_url}statuses/friends_timeline.xml";
+               }
+               $json_url = $json_url . "?body_formats=html_touch";
+               $page_head = "{$get_following} のアンテナ";
+               $official = "{$haiku_official_url}{$get_following}/following";
+               $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?following=".rawurlencode($_GET['following']);
+               $entries_mode = 'friends_timeline';
+}      elseif (isset($_GET['album']) && $_GET['album'] != ''){
+       if ($_GET['album'] == 'public'){
+               $get_album = 'public';
+               $json_url = "{$api_base_url}statuses/album.xml?body_formats=html_touch";
+               $page_head = 'みんなのアルバム';
+               $official = $haiku_official_url . 'album';
+               $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?album=".rawurlencode($_GET['album']);
+               $entries_mode = 'album';
+       } else {
+               $get_album = htmlspecialchars($_GET['album'], ENT_QUOTES);
+               $json_url = "{$api_base_url}statuses/album.xml?word=".rawurlencode($_GET['album'])."&body_formats=html_touch";
+               $page_head = $get_album.'のアルバム';
+               $official = $haiku_official_url.'keyword/'.rawurlencode($_GET['keyword']).'?mode=album';
+               $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?album=public";
+               $entries_mode = 'album';
+       }
+}      elseif (isset($_GET['users']) && $_GET['users'] != ''){
+         if ($_GET['users'] == 'public'){
+               $get_users = htmlspecialchars($_GET['users'], ENT_QUOTES);
+               $json_url = $api_base_url.'statuses/public_timeline.xml?count=100&body_formats=html_touch';
+               $page_head = 'ユーザー一覧';
+               $official = $haiku_official_url;
+               $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?users=public";
+               $entries_mode = 'users';
+         } else {
+               $get_users = htmlspecialchars($_GET['users'], ENT_QUOTES);
+               $json_url = $api_base_url.'statuses/keyword_timeline.xml?word='.rawurlencode($_GET['users']).'&count=100&body_formats=html_touch';
+               $page_head = $get_users.' のユーザー一覧';
+               $official = "{$haiku_official_url}keyword/" . rawurlencode($_GET['users']);
+               $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?users=".rawurlencode($_GET['users']);
+               $entries_mode = 'keyword_users';
+         }
+}      elseif (isset($_GET['favours']) && $_GET['favours'] != ''){
+               $get_favours = htmlspecialchars($_GET['favours'], ENT_QUOTES);
+               $json_url = "{$api_base_url}statuses/friends_timeline/".$get_favours.".xml";
+               if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE
+                   && $get_favours == $_SESSION['hatenaid']){
+                   $json_url_noaouth = $json_url . "?count=100&body_formats=html_touch";
+                   $json_url = "{$api_base_url}statuses/friends_timeline.xml";
+               }
+               $json_url = $json_url . "?count=100&body_formats=html_touch";
+       $page_head = $get_favours.' のお気に入り';
+       $official = "{$haiku_official_url}following";
+       $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}?favours={$_GET['favours']}";
+       $entries_mode = 'favours';
+}      else {
+       $json_url = "{$api_base_url}statuses/public_timeline.xml?body_formats=html_touch";
+       $page_head = "みんなのエントリー";
+       $official = $haiku_official_url;
+       $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}";
+       $entries_mode = 'default';
+}
+//
+if (isset($_GET['page']) && $_GET['page'] != ''){
+       if ($entries_mode == 'default'){
+               $self_anchor_possibly_with_pagenum = $self_anchor . '?page=' . $_GET['page'];
+       } else {
+               $self_anchor_possibly_with_pagenum = $self_anchor . '&page=' . $_GET['page'];
+       }
+       $relog_back = $self_anchor_possibly_with_pagenum . '&log=try';
+       $relogin = $self_anchor_possibly_with_pagenum . '&with=haiku&callback='.rawurlencode(rawurldecode($relog_back));
+} else {
+       if ($entries_mode != 'default'){
+         $self_anchor_possibly_with_pagenum = $self_anchor.'&page=1';
+       } else {
+         $self_anchor_possibly_with_pagenum = $self_anchor.'?page=1';
+       }
+         $relog_back = $self_anchor_possibly_with_pagenum . '&log=try';
+         $relogin = $self_anchor_possibly_with_pagenum . '&with=haiku&callback='.rawurlencode(rawurldecode($relog_back));
+}
+//
+if ($get_image == 'on'){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '&image=on';
+} else {
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '&image=off';
+}
+$relog_back = $self_anchor_with_imagemode . '&log=try';
+$relogin = $self_anchor_with_imagemode . '&amp;with=haiku&amp;callback='.rawurlencode(rawurldecode($relog_back));
+?>
+<?php
+$echo = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
+       <meta http-equiv="Content-Style-Type" content="text/css" />
+       <meta http-equiv="Content-Script-Type" content="text/javascript" />
+       <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
+       <title>{$page_head} - {$site_name} {$site_name_caption}</title>
+       <link rel="stylesheet" href="{$style_sheet}" />
+       <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+
+EOL;
+if (isset($starisjs) && $starisjs == '1'){
+if ($entries_mode != 'users' && $entries_mode != 'keyword_users' && $entries_mode != 'favours'){
+  $echo = $echo . <<<EOL
+       <script type="text/javascript" src="http://s.hatena.ne.jp/js/HatenaStar.js"></script>
+       <script type="text/javascript">
+       Hatena.Star.SiteConfig = {
+         entryNodes: {
+               'div.entry': {
+                 uri: 'a.to-original-link',
+                 title: 'a.keyword',
+                 container: 'span.entry-head'
+               }
+         }
+       };
+       </script>
+
+EOL;
+}
+}
+$echo = $echo . <<<EOL
+</head>
+<body>
+<div id="page">
+EOL;
+?>
+<?php
+// var_dump($_SESSION);
+//var_dump($_POST);
+//var_dump($_GET);
+$echo = $echo . echoCommonHeader('#navigation-menu', $self_anchor_with_imagemode) . "<hr />\n";
+$echo = $echo . "<div id=\"header\" class=\"{$entries_mode}\">\n";
+$echo = $echo . "<h1 id=\"entries-head\" class=\"head1\">{$page_head} <a href=\"{$official}\" class=\"to-original-link\">&nbsp;‡&nbsp;</a></h1>\n<hr />";
+$echo = $echo . "</div>\n";
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+$echo = '';
+?>
+<?php
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  if ($device_who == 'ktai'){
+       $rows = '3';
+  } else {
+       $rows = '6';
+  }
+       $echo = $echo . '<div class="post-box">';
+       $echo = $echo . '<form method="post" action="./post.php" enctype="application/x-www-form-urlencoded" accept-charset="'.$meta_charset.'">';
+       if ($entries_mode == 'keyword_timeline'){
+               $echo = $echo . '<input type="hidden" id="post-keyword" name="keyword" value="' . $get_keyword . '" />';
+       } else {
+               $echo = $echo . '<input type="text" id="post-keyword" name="keyword" maxlength="255" value="';
+               if (isset($_GET['word'])) $echo = $echo . htmlspecialchars($_GET['word'],ENT_QUOTES);
+               $echo = $echo . '" title="キーワード" size="80" /><br />';
+       }
+       $echo = $echo . '<textarea id="post-text" name="status" rows="'. $rows .'" cols="80" title="本文">';
+       if (isset($_GET['body'])) $echo = $echo . htmlspecialchars($_GET['body']);
+       $echo = $echo . '</textarea><br />';
+       $echo = $echo . '<input type="hidden" name="posting" value="status" />';
+       $echo = $echo . '<input type="hidden" name="return" value="'.htmlspecialchars($self_anchor_possibly_with_pagenum,ENT_QUOTES).'" />';
+/*  $rand = mt_rand(); $_SESSION['postkey'] = $rand;
+  $rand_md5 = md5($rand);
+  echo "<input type=\"hidden\" name=\"postkey\" value=\"{$rand_md5}\" />";*/
+  if (isset($_GET['from']) && $_GET['from'] != ''){
+       $_SESSION['source'] = htmlspecialchars($_GET['from'], ENT_QUOTES);
+  }
+  if (isset($_SESSION['source']) && $_SESSION['source'] != ''){
+       $from = $_SESSION['source'];
+  } else {
+       $from = $product_name_abbr;
+  }
+  $echo = $echo . <<<EOL
+<input type="submit" id="post-haiku" value="Haiku!" />
+ <label for="post-from">from </label><input type="text" id="post-from" name="source" value="{$from}" maxlength="170" />
+ <a href="./coco.php?
+EOL;
+// if (isset($_GET['keyword'])) echo '?keyword='.rawurlencode($_GET['keyword']);
+$echo = $echo . "return=".htmlspecialchars($self_anchor_with_imagemode,ENT_QUOTES);
+$echo = $echo . '" class="navigation-link">イマココ</a>';
+$echo = $echo . '</form>';
+ if (isset($_SESSION['post_result']) && $_SESSION['post_result'] != ''){
+  $echo = $echo . '<div class="post-result">';
+//   var_dump($_SESSION);
+       if ($_SESSION['post_result'] === TRUE){
+//             var_dump($_SESSION['post_to']);
+               if ($_SESSION['post_to'] == 'hateb'){
+//               var_dump($_SESSION['post_body']);
+                 $echo = $echo . echoHateBxml(simplexml_load_string($_SESSION['post_body']));
+               } else {
+                 $json_body = $_SESSION['post_body'];
+                 $contents = checkEntryData($json_body);
+                 if (preg_match("/^oauth_problem=token_rejected$/", $json_body)){
+                     $echo = $echo . "<p>アクセストークンが無効になっています。<a href=\"{$relogin}\">再認証</a>を行なってください。</p>";
+                 } elseif ($contents['stat'] == FALSE && $contents['ercode'] != 'x'){
+                       $echo = $echo . "<p>何かのエラーです。</p>\n";
+                       $echo = $echo . print_r(strip_tags($contents['contents']));
+                       $echo = $echo . "<br />{$json_body}</blockquote>\n";
+                 } elseif ($contents['stat'] == FALSE && $contents['ercode'] == 'x'){
+                       $echo = $echo . "<p>何かのエラーですす。</p>\n";
+                       $echo = $echo . "<blockquote>{$contents['ermes']}</blockquote>\n";      
+                 } else {
+                       $echo = $echo . '<span>' . $_SESSION['post_result_mes'] . '</span>';
+                       $entry_processor_mode = "entry"; $eprocessor_sub_mode = 'presult';
+                       $val = $contents['contents'];
+                       require 'entry_processor.php';
+                       unset($eprocessor_sub_mode);
+                       $echo = $echo . "<hr />\n";
+/*               $val = $_SESSION['post_body'];
+                 require 'entry_processor.php';*/
+                 }
+                 $contents = '';
+               }
+       }
+       if ($_SESSION['post_result'] === FALSE){
+               $echo = $echo . '<span>' . $_SESSION['post_result_mes'] . '</span>';
+               $echo = $echo . "<blockquote>{$_SESSION['post_error']}</blockquote>";
+//             var_export($_SESSION['$post_session']);
+       }
+  $echo = $echo . '</div>';
+       $_SESSION['post_to'] = '';
+       $_SESSION['post_result'] = '';
+       $_SESSION['post_result_mes'] = '';
+       $_SESSION['post_error'] = '';
+       $_SESSION['post_body'] = '';
+       libxml_clear_errors();
+ }
+$echo = $echo . '</div>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+$echo = '';
+}
+if (isset($_SESSION['oauth_stat'])){
+  $echo = $echo . '<div class="oauth-res">'."\n";
+  if ($_SESSION['oauth_stat'] === TRUE) {
+       $echo = $echo . "<span>アクセストークンを更新しました。</span>\n";
+  } else {
+       $echo = $echo . "<span>アクセストークンを取得できませんでした。</span>\n";
+       $echo = $echo . "<blockquote>{$_SESSION['oauth_stat']}</blockquote>";
+  }
+  $echo = $echo . '</div>'."\n";
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+$echo = '';
+}
+?>
+
+<?php
+$echo = $echo . '<div class="contents">'."\n";
+function constRequest($json_url){
+  global $ecount, $entries_mode;
+  if (isset($_GET["reftime"]) && $_GET["reftime"] != '') {
+       $request_url = $json_url . '&reftime=' . rawurlencode($_GET['reftime']);
+  } elseif (!isset($_GET["page"])){
+         $request_url = $json_url;
+  }    else {
+         $request_url = $json_url.'&page='.$_GET["page"];
+  }
+  if (isset($ecount) && !preg_match("/users|keyword_users|favours/", $entries_mode)){
+       $request_url = $request_url . '&count=' . $ecount;
+  }
+  return $request_url;
+}
+$request_url = constRequest($json_url);
+// var_dump($entries_mode);
+// var_dump($request_url);
+// var_dump($request_url);
+// var_dump ($_GET);
+// var_dump($get_image);
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  $json = getJson($request_url, TRUE, $conkey, $conkey_sec, $_SESSION['acstoken'], $_SESSION['acs_sec']);
+} else {
+  $json = getJson($request_url, FALSE);
+}
+if (preg_match("/^oauth_problem=token_rejected$/", $json['body'])){
+    $echo = $echo . "<p class=\"oauth-res\">アクセストークンが無効になっています。<a href=\"{$relogin}\">再認証</a>を行なってください。</p>";
+    $json = getJson(constRequest($json_url_noaouth), FALSE);
+}
+if ($json['stat'] !== TRUE){
+  $contents = strip_tags($json['stat']);
+  $echo = $echo . "<p>はてなハイク API からデータを取得できなかったような気がします。</p>\n";
+  $echo = $echo . "<blockquote>";
+  if (isset($json['http'])) echo "HTTP {$json['http']}<br />";
+  $echo = $echo . "{$json['stat']}<br />{$contents}</blockquote>\n";
+  $timeline_putted = FALSE;
+} else {
+  $json_body = $json['body'];
+  $contents = checkEntryData($json_body);
+  if ($contents['stat'] == FALSE && $contents['ercode'] != 'x'){
+//   var_dump($contents);
+//   var_dump($json['body']);
+       $echo = $echo . "<p>はてなハイク API からデータを取得できなかったような気がします。</p>\n";
+       $echo = $echo . "<blockquote>HTTP {$json['http']}<br />";
+       $echo = $echo . 'XML error '.$contents['ercode'].':'.$contents['ermes'];
+       $echo = $echo . "<br />".strip_tags($json['body'])."</blockquote>\n";
+       $timeline_putted = FALSE;
+  } elseif ($contents['stat'] == FALSE && $contents['ercode'] == 'x'){
+       $echo = $echo . "<p>はてなハイク API からデータを取得できなかったような気がします。</p>\n";
+       $echo = $echo . "<blockquote>HTTP {$json['http']}<br />{$contents['ermes']}</blockquote>\n";    
+       $timeline_putted = FALSE;
+  } else {
+//     var_dump($contents);
+       $first_e = 'first';
+       if ($entries_mode == 'default' || $entries_mode == 'album'){ $dict = array(); $spam = 0; }
+       if ($entries_mode  == 'users' || $entries_mode == 'keyword_users' || $entries_mode == 'favours'){
+         $ustock = array();
+         $echo = $echo . "<dl class=\"users-list\">\n";
+       }
+       foreach ($contents['contents'] as $val){
+         echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+         $echo = '';
+         if ($entries_mode == 'users' || $entries_mode == 'keyword_users' || $entries_mode == 'favours'){
+               $entry_processor_mode = 'users';
+               require 'entry_processor.php';
+         } else {
+               $entry_processor_mode = "entries";
+               require 'entry_processor.php';
+               echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+               $echo = '';
+         }
+         $timeline_putted = TRUE;
+       }
+       if (isset($spam) && $spam > 0) $echo = "<p>{$spam} スパムっぽいのを表示しませんでした。</p>";
+       if ($entries_mode  == 'users' || $entries_mode == 'keyword_users' || $entries_mode == 'favours') {
+         $echo = $echo . "</dl>\n";
+//     var_dump($dict);
+         $echo = $echo . '<p>' . count($ustock) . '/' . count($contents['contents']) . 
+           ' unique</p>' . "\n";
+       }
+  }
+}
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+$echo = '';
+?>
+<?php
+// var_dump($contents);
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+if ($entries_mode == 'keyword_timeline' || $entries_mode == 'keyword_users'){
+  if (isset($timeline_putted) && $timeline_putted === TRUE){
+       $object_key = $contents['contents']->status[0]->keyword;
+       $object_title = $contents['contents']->status[0]->target->title;
+  } else {
+       if ($entries_mode == 'keyword_timeline'){
+         $object_key = $_GET['keyword'];
+         $object_title =$_GET['keyword'];
+       }
+       if ($entries_mode == 'keyword_users'){
+         $object_key = $_GET['users'];
+         $object_title = $_GET['users'];
+       }
+  }
+//   var_dump($status_0);
+  if (preg_match("/^{$http_url_regexp}$/u", $object_key)){
+       if (preg_match("/&/u", $object_key)){
+         $echo = $echo . '<p>URL: <a href="'.$mobile_gateway.rawurlencode(rawurldecode($object_key)).'" class="external-link">'.htmlspecialchars($object_title,ENT_QUOTES).'</a> を<a href="mailto:b@hatena.ne.jp?body='.rawurlencode(rawurldecode($object_key)).'">メールではてなブックマークに追加する。</a></p>';
+       } else {
+         $echo = $echo . '<form method="post" action="" enctype="application/x-www-form-urlencoded" accept-charset="'.$meta_charset.'" class="hateb-form">'."\n";
+         $echo = $echo .  '<label>URL: <a href="'.$mobile_gateway.rawurlencode(rawurldecode($object_key)).'" class="external-link">'.htmlspecialchars($object_title,ENT_QUOTES).'</a> をはてなブックマークに追加する。</label><br />';
+         $echo = $echo . '<label for="bcomment">コメント:</label>';
+         $echo = $echo . '<input type="text" id="bcomment" name="comment" maxlength="100" value="" title="ブックマークコメント" />';
+         $echo = $echo . '<input type="hidden" name="url" value="'.$get_keyword.'" />';
+         $echo = $echo . '<input type="hidden" name="posting" value="hateb" />';
+         $echo = $echo . '<input type="hidden" name="return" value="'.htmlspecialchars($self_anchor_possibly_with_pagenum, ENT_QUOTES).'" />';
+         $echo = $echo . '<input type="submit" id="post-hateb" value="[B!]" title="URL をはてなブックマークに追加する。" />';
+         $echo = $echo . '</form>';
+  //   echo "...";
+       }
+  } elseif (preg_match("/^(asin:)([[:alnum:]])+$/u", $object_key)){
+       $asin = preg_replace("/^(asin:)([[:alnum:]]+)$/u", "\${2}", $object_key);
+       $echo = $echo . '<p class="to-amazon"><a href="'.'http://www.amazon.co.jp/gp/aw/d.html/?a='.$asin.'" class="external-link">'.$object_title.' を Amazon.co.jp で見る。</a></p>';
+  } elseif (preg_match("/^id:[a-zA-Z1234567890]{1}[-_a-zA-Z1234567890@]{1,30}[a-zA-Z1234567890]{1} *$/u", $object_key)){
+  } else {
+         $echo = $echo . '<form method="post" action="" enctype="application/x-www-form-urlencoded" accept-charset="'.$meta_charset.'" class="hateb-form">'."\n";
+         $echo = $echo .  '<label>このハイクキーワードをはてなブックマークに追加する。</label><br />';
+         $echo = $echo . '<label for="bcomment">コメント:</label>';
+         $echo = $echo . '<input type="text" id="bcomment" name="comment" maxlength="100" value="" title="ブックマークコメント" />';
+         $echo = $echo . '<input type="hidden" name="url" value="http://'.$haiku_host.'/keyword/'.htmlspecialchars($get_keyword, ENT_QUOTES).'" />';
+         $echo = $echo . '<input type="hidden" name="posting" value="hateb" />';
+         $echo = $echo . '<input type="hidden" name="return" value="'.htmlspecialchars($self_anchor_possibly_with_pagenum, ENT_QUOTES).'" />';
+         $echo = $echo . '<input type="submit" id="post-hateb" value="[B!]" title="このハイクキーワードをはてなブックマークに追加する。" />';
+         $echo = $echo . '</form>';
+  }
+}
+}
+$echo = $echo . '</div>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+$echo = '';
+?>
+
+<?php
+$navi_paging = TRUE;
+$navi_imaging = TRUE;
+require 'footer_include.php';
+$echo = $echo . '</div></body></html>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+if (isset($_SESSION['oauth_stat'])) unset($_SESSION['oauth_stat']);
+?>
diff --git a/entry.php b/entry.php
new file mode 100644 (file)
index 0000000..4beb50f
--- /dev/null
+++ b/entry.php
@@ -0,0 +1,280 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+require_once "init_processor.php";
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+if (!isset($_SERVER['QUERY_STRING']) || $_SERVER['QUERY_STRING'] == '') {
+  echo 'nan nimo nai.';
+  exit();
+}
+$safequery = htmlspecialchars($_SERVER["QUERY_STRING"], ENT_QUOTES);
+?>
+<?php
+?>
+<?php
+//entry id
+if (isset($_GET['entry'])) checkEntryid($_GET['entry']);
+//不正なはてなID
+if (isset($_GET["user"])) checkId($_GET["user"]);
+//長すぎる keyword
+if (isset($_GET["keyword"])) checkKeyword($_GET["keyword"]);
+//
+if (isset($_GET['image'])) checkImagemode($_GET['image']);
+if (isset($_SESSION['image'])) checkImagemode($_SESSION['image']);
+?>
+<?php
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+?>
+<?php
+//
+if (isset($_GET['with']) || isset($_GET['log'])){
+  require 'login_processor.php';
+}
+// if (isset($_SESSION['oauth_stat'])) session_regenerate_id(TRUE);
+
+//投稿処理の呼び出し。
+if (isset($_POST['posting'])){
+  require 'post_processor.php';
+}
+?>
+<?php
+if ($_GET['entry'] != ''){
+       $get_entry = htmlspecialchars($_GET['entry'],ENT_QUOTES);
+       $json_url = "{$api_base_url}statuses/show/{$_GET['entry']}.xml?body_formats=html_touch";
+}
+if ($_GET['user'] != ''){
+       $get_user = htmlspecialchars($_GET['user'], ENT_QUOTES);
+       $get_keyword = htmlspecialchars($_GET['keyword'], ENT_QUOTES);
+       $page_head = $get_user . ' さんのエントリー';
+       $official = $haiku_official_url . $get_user . '/' . $get_entry;
+       $self_anchor = 'http://' . $_SERVER['SERVER_NAME'] . $selfcall . '?entry=' . rawurlencode($_GET['entry']) . '&user=' . rawurlencode($_GET['user']) . '&;keyword='. rawurlencode($_GET['keyword']);
+       $self_anchor_possibly_with_pagenum = $self_anchor;
+}      elseif ($_GET['user'] == ''){
+       $page_head = 'エントリー';
+       $official = $haiku_official_url . 'entry' . '/' . $get_entry;
+       $self_anchor = 'http://' . $_SERVER['SERVER_NAME'] . $selfcall . '?entry=' . rawurlencode($_GET['entry']);
+       $self_anchor_possibly_with_pagenum = $self_anchor;
+}
+  $relog_back = $self_anchor_possibly_with_pagenum . '&log=try';
+  $relogin = $self_anchor_possibly_with_pagenum . '&with=haiku&callback='.rawurlencode(rawurldecode($relog_back));
+if ($get_image == 'on'){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '&image=on';
+} else {
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '&image=off';
+}
+$relog_back = $self_anchor_with_imagemode . '&log=try';
+$relogin = $self_anchor_with_imagemode . '&amp;with=haiku&amp;callback='.rawurlencode(rawurldecode($relog_back));
+?>
+<?php
+$echo = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
+       <meta http-equiv="Content-Style-Type" content="text/css" />
+       <meta http-equiv="Content-Script-Type" content="text/javascript" />
+       <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
+       <title>{$page_head} - {$site_name} {$site_name_caption}</title>
+       <link rel="stylesheet" href="{$style_sheet}" />
+       <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+
+EOL;
+if (isset($starisjs) && $starisjs == '1'){
+  $echo = $echo . <<<EOL
+       <script type="text/javascript" src="http://s.hatena.ne.jp/js/HatenaStar.js"></script>
+       <script type="text/javascript">
+       Hatena.Star.SiteConfig = {
+         entryNodes: {
+               'div.entry': {
+                 uri: 'a.to-original-link',
+                 title: 'a.keyword',
+                 container: 'span.entry-head'
+               }
+         }
+       };
+       </script>
+
+EOL;
+}
+$echo = $echo . <<<EOL
+</head>
+<body>
+<div id="page">
+EOL;
+?>
+<?php
+//var_dump($_GET);
+$echo = $echo . echoCommonHeader('#navigation-menu', $self_anchor_with_imagemode) . "<hr />\n";
+$echo = $echo . "<div id=\"header\" class=\"entry_cat\">\n";
+$echo = $echo . "<h1 id=\"entries-head\" class=\"head1\">{$page_head} <a href=\"{$official}\" class=\"to-original-link\">&nbsp;‡&nbsp;</a></h1>\n<hr />";
+$echo = $echo . "</div>\n";
+  if (isset($_SESSION['post_result']) && $_SESSION['post_result'] === TRUE or FALSE){
+  $echo = $echo . '<div class="post-result">';
+//   var_dump($_SESSION);
+       if ($_SESSION['post_result'] === TRUE){
+//             var_dump($_SESSION['post_to']);
+                 $json_body = $_SESSION['post_body'];
+                 $contents = checkEntryData($json_body);
+                 if (preg_match("/^oauth_problem=token_rejected$/", $json_body)){
+                     $echo = $echo . "<p class=\"oauth-res\">認証情報が無効です。<a href=\"{$relogin}\">再認証</a>を行なってください。</p>";
+                 } elseif ($contents['stat'] == FALSE && $contents['ercode'] != 'x'){
+                       $echo = $echo . "<p>何かのエラーです。</p>\n";
+                       $echo = $echo . print_r(strip_tags($contents['contents']));
+                       $echo = $echo . "<br />{$json_body}</blockquote>\n";
+                 } elseif ($contents['stat'] == FALSE && $contents['ercode'] == 'x'){
+                       $echo = $echo . "<p>何かのエラーですす。</p>\n";
+                       $echo = $echo . "<blockquote>{$contents['ermes']}</blockquote>\n";      
+                 } else {
+                       $echo = $echo . '<span>' . $_SESSION['post_result_mes'] . '</span>';
+                 }
+
+       }
+       if ($_SESSION['post_result'] === FALSE){
+               $echo = $echo . '<span>' . $_SESSION['post_result_mes'] . '</span>';
+               $echo = $echo . "<blockquote>{$_SESSION['post_error']}</blockquote>";
+//             var_export($_SESSION['$post_session']);
+       }
+  $echo = $echo . '</div>';
+       $_SESSION['post_to'] = '';
+       $_SESSION['post_result'] = '';
+       $_SESSION['post_result_mes'] = '';
+       $_SESSION['post_error'] = '';
+       $_SESSION['post_body'] = '';
+       libxml_clear_errors();
+  }
+if (isset($_SESSION['oauth_stat'])){
+  $echo = $echo . '<div class="oauth-res">'."\n";
+  if ($oauth_stat === TRUE) {
+       $echo = $echo . "<span>アクセストークンを更新しました。</span>\n";
+  } else {
+       $echo = $echo . "<span>アクセストークンを取得できませんでした。</span>\n";
+       $echo = $echo . "<blockquote>{$oauth_stat}</blockquote>";
+  }
+  $echo = $echo . '</div>'."\n";
+}
+$echo = $echo . '<div class="contents">'."\n";
+?>
+
+<?php
+if (isset($_GET['image'])){
+       $_SESSION['image'] = $_GET['image'];
+}
+$request_url = $json_url;
+  $json = getJson($request_url, FALSE);
+if ($json['stat'] !== TRUE){
+  $contents = strip_tags($json['stat']);
+  $echo = $echo . "<p>はてなハイク API からデータを取得できなかったような気がします。</p>\n";
+  $echo = $echo . "<blockquote>{$contents}</blockquote>\n";
+} else {
+  $json_body = $json['body'];
+  $contents = simplexml_load_string($json['body']);
+  if (preg_match("/^oauth_problem=token_rejected$/", $json_body)){
+    $echo = $echo . "<p>認証情報が無効です。<a href=\"{$relogin}\">再認証</a>を行なってください。</p>";
+  } elseif (libxml_get_last_error() !== FALSE){
+       $contents = strip_tags($contents);
+       $echo = $echo . "<p>はてなハイク API からデータを取得できなかったような気がします。</p>\n";
+       $echo = $echo . "<blockquote>{$contents}</blockquote>\n";
+  } elseif (isset($contents['error'])){
+       $echo = $echo . "<p>はてなハイク API からデータを取得できなかったような気がします。</p>\n";
+       $echo = $echo . "<blockquote>{$contents['error']}</blockquote>\n";      
+  } else {
+       $entry_processor_mode = "entry";
+       $val = $contents;
+       require 'entry_processor.php';
+         if (isset($contents->replies) && $contents->replies[0]->id != ''){
+               $echo = $echo . '<dl><dt>リプライ</dt>';
+               $echo = $echo . '<dd>';
+               foreach($contents->replies as $val){
+                       $val->keyword = $_GET['keyword'];
+                       require 'entry_processor.php';
+               }
+               $echo = $echo . '</dd>';
+               $echo = $echo . '</dl>';
+         }
+  }
+}
+
+?>
+<?php
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  if ($device_who == 'ktai'){
+       $rows = '3';
+  } else {
+       $rows = '6';
+  }
+       $echo = $echo . '<dl class="post-box">';
+       $echo = $echo . '<dt>リプライする</dt><dd>';
+       $echo = $echo . <<<EOL
+<form method="post" action="./post.php" enctype="application/x-www-form-urlencoded" accept-charset="{$meta_charset}">
+EOL;
+       if (isset($_GET['keyword'])) $echo = $echo . '<input type="hidden" id="post-keyword" name="keyword" value="' . htmlspecialchars($_GET['keyword'], ENT_QUOTES) . '" />';
+       $echo = $echo . '<textarea id="post-text" name="status" rows="'. $rows .'" cols="40">';
+       if (isset($_GET['body'])) $echo = $echo . htmlspecialchars($_GET['body']);
+  $echo = $echo . <<<EOL
+</textarea><br />
+<input type="hidden" name="posting" value="status" />
+<input type="hidden" name="return" value="
+EOL;
+  $echo = $echo . htmlspecialchars($self_anchor_possibly_with_pagenum,ENT_QUOTES);
+  if (isset($_GET['from']) && $_GET['from'] != ''){
+       $_SESSION['source'] = htmlspecialchars($_GET['from'], ENT_QUOTES);
+  }
+  if (isset($_SESSION['source']) && $_SESSION['source'] != ''){
+       $from = $_SESSION['source'];
+  } else {
+       $from = $product_name_abbr;
+  }
+  $echo = $echo . <<<EOL
+" />
+<input type="hidden" name="in_reply_to_status_id" value="{$get_entry}" />
+<input type="submit" id="post-haiku" value="Haiku!" />
+ <label for="post-from">from </label><input type="text" id="post-from" name="source" value="{$from}" maxlength="170" />
+ <a href="./coco.php?
+EOL;
+  $echo = $echo . "return=".rawurlencode($self_anchor_with_imagemode);
+  $echo = $echo . '" class="navigation-link">イマココ</a>';
+  $echo = $echo . '</form>';
+  $echo = $echo . '</dd>';
+}
+$echo = $echo . "</div>\n";
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  if (isset($get_entry) && isset($get_user)){
+       $echo = $echo . '<form method="post" action="" enctype="application/x-www-form-urlencoded" accept-charset="'.$meta_charset.'" class="hateb-form">'."\n";
+       $echo = $echo .  '<label for="bcomment">このエントリをはてなブックマークに追加する。</label><br />';
+       $echo = $echo . '<label for="bcomment">コメント:</label>';
+       $echo = $echo . '<input type="text" id="bcomment" name="comment" maxlength="100" value="" title="ブックマークコメント" />';
+       $echo = $echo . '<input type="hidden" name="url" value="http://'.$haiku_host.'/'.$get_user.'/'.$get_entry.'" />';
+       $echo = $echo . '<input type="hidden" name="posting" value="hateb" />';
+       $echo = $echo . '<input type="hidden" name="return" value="'.htmlspecialchars($self_anchor_possibly_with_pagenum, ENT_QUOTES).'" />';
+       $echo = $echo . '<input type="submit" id="post-hateb" value="[B!]" title="このエントリをはてなブックマークに追加する。" />';
+       $echo = $echo . '</form>';
+  }
+}
+?>
+<?php
+$navi_paging = FALSE;
+$navi_imaging = TRUE;
+require 'footer_include.php';
+$echo = $echo . '</div></body></html>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+if (isset($_SESSION['oauth_stat'])) unset($_SESSION['oauth_stat']);
+?>
\ No newline at end of file
diff --git a/entry_processor.php b/entry_processor.php
new file mode 100644 (file)
index 0000000..8092b1c
--- /dev/null
@@ -0,0 +1,396 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2014 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php defined("HELLO") or exit(); ?>
+<?php
+if ((isset($entry_processor_mode) && ($entry_processor_mode == 'users' || $entry_processor_mode == 'keyword_users')) || (isset($entries_mode) && $entries_mode == 'favours')){
+//   echo "...";
+  if (in_array("{$val->user->id}", $ustock)) return;
+  $echo = $echo . "<dt>";
+  if ($get_image == 'on' || (isset($show_icon) && $show_icon == 'yes')){
+         $echo = $echo . '<img src="' . $val->user->profile_image_url . '" width="16" height="16" class="user-icon" alt="" /> ';
+  }
+  if (preg_match("/^(id:{1})([[:alpha:]]{1}[-_a-zA-Z1234567890]{1,30}[[:alnum:]]{1})$/u", $val->keyword)) {
+       $keyword_title = $val->keyword;
+  } else {
+       $keyword_title = $val->target->title;
+  }
+  $echo = $echo . "<a href=\"./entries.php?user={$val->user->id}";
+//   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
+  $echo = $echo . "\" class=\"hatena-id\">{$val->user->name} (id:{$val->user->id})</a></dt>\n";
+  $echo = $echo . "<dd><a href=\"./entries.php?keyword=".rawurlencode($val->keyword);
+//   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
+  $echo = $echo . "\" class=\"keyword\">".htmlspecialchars($keyword_title)."</a></dd>\n";
+  $ustock[] = "{$val->user->id}";
+} else {
+//タイムスタンプ-0
+  $unix_time = strtotime($val->created_at);
+  if (isset($first_e) && $first_e != '') $first_time = $unix_time; unset($first_e);
+  $entry_body = $val->html_touch;
+// $entry_body_text = $val->text;
+  if ($entries_mode == 'default' || $entries_mode == 'album'){
+    foreach ($dict as $dfn) {
+//       var_dump($dfn);
+//       $dkey = preg_quote("{$entry_body}", '/');
+      $dmt = preg_grep("/".preg_quote("{$entry_body}", '/')."/u", $dfn);
+//       var_dump($dmt);
+      if (isset($dmt["{$val->user->id}"])){ $spam = $spam + 1; return; }
+    }
+    $dict[] = array("{$val->user->id}" => "{$entry_body}");
+  }
+  if (($entries_mode == 'default'  || $entries_mode == 'album') && 
+      preg_match("/(^{$http_url_regexp}$)/u", "{$val->keyword}")){ $spam = $spam + 1;  return; }
+  if (preg_match("/^(id:{1})([[:alpha:]]{1}[-_a-zA-Z1234567890]{1,30}[[:alnum:]]{1})$/u", $val->keyword)) {
+       $keyword_title = $val->keyword;
+  } else {
+       $keyword_title = $val->target->title;
+  }
+$entry_body = preg_replace("/^([  ]*<br>){1,}/u", "", $entry_body);
+$entry_body = preg_replace("/(<br>){1,}$/u", "", $entry_body);
+$entry_body = preg_replace("/<br>/u", "<br />", $entry_body);
+$entry_body = preg_replace("/([  ]*<br \/>){3,}/u", "<br /><br />", $entry_body);
+$entry_body = preg_replace("/<br \/>/u", "<br />\n", $entry_body);
+// $entry_body = preg_replace("^[  ]<br \/>\n", "<br \/>\n", $entry_body);
+// var_dump($entry_body);
+// $entry_body = preg_replace("/([^.!?。!?…‥])\n{1}/u", "\${1}", $entry_body);
+// $entry_body = preg_replace("/(、)\n/u", "\${1}", $entry_body);
+// $entry_body = preg_replace("/(<br \/>){1,}$/u", "", $entry_body);
+//改行削減
+if (isset($disbr) && $disbr == 'no'){
+} elseif ($entries_mode == 'friends_timeline' || $entries_mode == 'default' || $entries_mode == 'keyword_timeline'){
+  $list_mark = "-1234567890一二三四五六七八九〇1234567890・*○●◎△▲▽▼□■◇◆×>#;#;";
+  $entry_body = preg_replace("/([  ]*<br \/>){2,}/u", "<br />", $entry_body);
+  $entry_body = preg_replace("/(^[{$list_mark}]{1,}.+|^&gt;.+)(<br \/>)/um", " \${1}\${2}<br />", $entry_body);
+  $entry_body = preg_replace("/<br \/>\n/u", "<br />", $entry_body);
+  $entry_body = preg_replace("/([^><」」』】\]]。.  ]{1})<br \/>([^{$list_mark}  ><「「『【\[[]{1})/u", "\${1} \${2}", $entry_body);
+//   var_dump($entry_body);
+  $entry_body = preg_replace("/([,、]{1})[ ]{1}/u", "\${1}", $entry_body);
+  $entry_body = preg_replace("/([  ]*<br \/>){2,}/u", "<br />", $entry_body);
+}
+//
+$entry_body = preg_replace("/(<br \/>)/u", "\n\${1}\n", $entry_body);
+//             var_dump($entry_body_temp);
+$entry_body = preg_replace("/\n+/u", "\n", $entry_body);
+$entry_body = preg_replace("/\n$/u", "", $entry_body);
+if (preg_match("/((<br \/>|\n)*&gt;&gt;(<br \/>|\n))(.+)((<br \/>\n)&lt;&lt;(<br \/>|\n)*)/us", $entry_body)) {
+  $bquote = "1";
+} else {
+  $bquote = "0";
+}
+//$entry_body = $entry_body . "\n";
+//echo htmlspecialchars(var_dump($entry_body));
+//文字数制限
+if ($entry_processor_mode == "entries" && !preg_match('/^(kalen_t|fumobot)$/u', $val->user->id)){
+//   if ($get_image == 'on'){
+//     $see_more = "<a href=\"./entry.php?entry={$val->id}&amp;user={$val->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"see-more\">(…)</a>";
+//   } else {
+  $see_more = "<a href=\"./entry.php?entry={$val->id}&amp;user={$val->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "\" class=\"see-more\">(…)</a>";
+//   }
+  $plain_body = strip_tags($entry_body);
+  $entry_width = mb_strwidth($plain_body);
+//   if ($entries_mode == 'default' && $entry_width < 9){ $spam = $spam + 1; return; }
+  if (($entries_mode == 'default'  || $entries_mode == 'album') && 
+      preg_match("/(^{$http_url_regexp}$)|(^{$http_path_regexp}$)|(^{$http_url_regexp}.+{$http_url_regexp}$)/us", $plain_body) && 
+      !preg_match("/<img[^>]+>/u", $entry_body)){ $spam = $spam + 1;  return; }
+  $tranc_width = $entry_limit - ($entry_limit/3);
+  if ($entry_width > ($entry_limit)){
+       $plain_body = mb_strimwidth($plain_body, 0, $tranc_width, '', "UTF-8");
+//     $entry_body = mb_strimwidth($entry_body, 0, $tranc_width, '', "UTF-8");
+  //           echo "...";
+       $text_a = explode("\n", $entry_body);
+       $plain_a = explode("\n", $plain_body);
+//     var_dump($text_a);
+       $tail = count($plain_a) - 1;
+       $text_a[$tail] = $plain_a[$tail];
+       $text_a = array_slice($text_a, 0, $tail + 1);
+/*     $text_a[$tail] = strip_tags($text_a[$tail]);
+       $text_a[$tail] = preg_replace("/<.*$/u", "", $text_a[$tail]);*/
+       $entry_body = implode("\n", $text_a) . $see_more;
+       //var_dump($entry_body_temp);
+  }
+}
+//引用記法
+// $entry_body = preg_replace("/(&gt;&gt;\n)(.+)(&lt;&lt;)/us", "<blockquote>\${2}</blockquote>", $entry_body);
+if ($bquote == 1) {
+       $entry_body = preg_replace("/(\n|<br \/>)*&gt;&gt;(\n|<br \/>)/us", "<blockquote>", $entry_body);
+       $entry_body = preg_replace("/(\n|<br \/>)&lt;&lt;(\n|<br \/>)*/us", "</blockquote>", $entry_body);
+       $entry_body = preg_replace("/(<blockquote>|<\/blockquote>)<br \/>/u", "\${1}", $entry_body);
+}
+if (preg_match("/<blockquote>/u", $entry_body) && !preg_match("/<\/blockquote>/u", $entry_body)){
+  $entry_body = $entry_body."</blockquote>";
+}
+// $entry_body = preg_replace("/(<blockquote>)(.+)(\n<<)/us", "\${1}\${2}\n</blockquote>", $entry_body);
+//
+// $entry_body = nl2br($entry_body);
+//for りおきゅん
+// if ($val->user->id == 'Rio_Baxxter' && $val->keyword == '地震情報'){
+//   $rio_a = explode("\n", $entry_body);
+//   $rio_b = array();
+//   foreach ($rio_a as $rio){
+//     $gmap = '';
+//     if (preg_match("/(http:\/\/maps\.google\.co\.*[^\/]+\/){$http_path_regexp}+/", $rio)) $gmap = mb_ereg_replace("(.*)(<a href=\")(http:\/\/maps\.google\.co\.*[^\/]+\/)({$http_path_regexp}*)(q=)(-*[[:digit:]]{1,3}\.[[:digit:]]+)(,)(-*[[:digit:]]{1,3}\.[[:digit:]]+)({$http_path_regexp}*)(\">)([^<]*)(<\/a>)(.*)", "<br />\nmap:\\6:\\8", $rio);
+//     $rio_b[] = $rio.$gmap;
+//   }
+//   $entry_body = implode("\n", $rio_b);
+// }
+//
+// if ($get_image == 'on'){
+// //  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/keyword\/([^\/\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}&amp;image=on\" class=\"keyword\">", $entry_body);
+//   $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/target\?word=([^\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}&amp;image=on\" class=\"keyword\">", $entry_body);
+// //  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/([^\/\"]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}&amp;image=on\" class=\"user\">", $entry_body);
+//   $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/([^\/]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}&amp;image=on\" class=\"user\">", $entry_body);
+//   if ($val->user->id == 'fumobot') $entry_body = preg_replace("/<a[^>]*href=\"(http:\/\/h[[:alnum:]]*\.hatena\.[^\/]+\/*)\/keyword\/([^\"]+)\"[^>]*>/u", "<a href=\"./entries.php?keyword=\${2}&amp;image=on\" class=\"keyword\">", $entry_body);
+//   $entry_body = preg_replace("/<a[^>]*href=\"(http:\/\/h[[:alnum:]]*\.hatena\.[^\/]+\/*)\/touch\/asin\/([[:alnum:]]+)\"[^>]*>/u", "<a href=\"./entries.php?keyword=asin%3A\${2}&amp;image=on\" class=\"keyword\">", $entry_body);
+// } else {
+//  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/keyword\/([^\/\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}\" class=\"keyword\">", $entry_body);
+  $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/target\?word=([^\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}\" class=\"keyword\">", $entry_body);
+//  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/([^\/\"]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}\" class=\"user\">", $entry_body);
+  $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/([^\/]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}\" class=\"user\">", $entry_body);
+//   if ($val->user->id == 'fumobot')$entry_body = preg_replace("/<a[^>]*href=\"(http:\/\/h[[:alnum:]]*\.hatena\.[^\/]+\/*)\/keyword\/([^\"]+)\"[^>]*>/u", "<a href=\"./entries.php?keyword=\${2}\" class=\"keyword\">", $entry_body);
+  $entry_body = preg_replace("/<a[^>]*href=\"(http:\/\/h[[:alnum:]]*\.hatena\.[^\/]+\/*)\/touch\/asin\/([[:alnum:]]+)\"[^>]*>/u", "<a href=\"./entries.php?keyword=asin%3A\${2}\" class=\"keyword\">", $entry_body);
+// }
+$entry_body = preg_replace("/<div class=\"*user-map\"*><a[^>]*><img[^>]*alt=\"((map):(-*[[:digit:]]{1,3}\.*[[:digit:]]*):(-*[[:digit:]]{1,3}\.*[[:digit:]]*))\"[^>]*><\/a><\/div>/u", "\${1}", $entry_body);
+
+if ($get_image != 'on'){
+  $entry_body = preg_replace("/<a[^>]*><img[^>]*class=\"*(profile-image|favicon)\"*[^>]*><\/a>/u", "", $entry_body);
+  $entry_body = preg_replace("/<div[^>]*><iframe[^>]*src=\"http:\/\/www\.youtube\.com\/embed\/([^\"]+)\"[^>]*><\/iframe><\/div>/u", "<a href=\"http://m.youtube.com/watch?v=\${1}\">YouTube(\${1})</a>", $entry_body);
+} else {
+  if ($device_who == 'ktai' || $device_who == 'android-old'){
+       $entry_body = preg_replace("/<div[^>]*><iframe[^>]*src=\"http:\/\/www\.youtube\.com\/embed\/([^\"]+)\"[^>]*><\/iframe><\/div>/u", "<a href=\"http://m.youtube.com/watch?v=\${1}\"><img src=\"http://img.youtube.com/vi/\${1}/0.jpg\" alt=\"\" /></a>", $entry_body);
+  } else {
+       $entry_body = preg_replace("/<div[^>]*>(<iframe[^>]*src=\"http:\/\/www\.youtube\.com\/embed\/([^\"]+)\"[^>]*><\/iframe>)<\/div>/u", "\${1}", $entry_body);
+  }
+}
+//はてなスター
+if ($val->favorited != "0"){
+if (isset($starisjs) && $starisjs == '1'){
+  $show_star = '';
+} else {
+       $show_star = "<span class=\"hatena-star\"><a href=\"http://s.hatena.ne.jp/mobile/entry?uri=" . rawurlencode("http://h.hatena.ne.jp/{$val->user->id}/{$val->id}") . "\">★{$val->favorited}</a></span>";
+}
+} else {
+       $show_star = "";
+       }
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+if (isset($starisjs) && $starisjs == '1'){
+  $add_star = '';
+} else {
+       $add_star = '<input type="submit" value="☆+" title="add-star" class="add-star-button" style="vertical-align: middle;"><input type="hidden" name="posting" value="favo" /><input type="hidden" name="entry" value="' . $val->id . '" /><input type="hidden" name="return" value="' . htmlspecialchars($self_anchor_possibly_with_pagenum, ENT_QUOTES);
+       if (isset($entry_processor_mode) && $entry_processor_mode != 'entry') $add_star = $add_star . '&amp;reftime=-'.$first_time . ',0'. '#'.$val->id;
+       $add_star = $add_star . '" /> ';
+}
+}      else {
+       $add_star = '';
+}
+//キーワードの前処理
+/*if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  $headend = "</form><br />";
+} else {*/
+  $headend = "<br />";
+// }
+if ($entries_mode == 'keyword_timeline'){
+  $entry_kw = '';
+} elseif (mb_ereg_match("^{$http_url_regexp}$",htmlspecialchars($val->keyword, ENT_QUOTES))){
+       $entry_kw = "URL:%KEYWORD%</span>{$headend}\n";
+//     var_dump($entry_body);
+} elseif (preg_match("/^asin:[[:alnum:]]+$/u", $val->keyword)){
+       $entry_kw = "ASIN:%KEYWORD%</span>{$headend}\n";
+} elseif (!isset($val->keyword)){
+       $entry_kw = "</span>{$headend}\n";
+/*} elseif (mb_strpos($entry_body, "{$val->keyword}=") !== FALSE) {
+       //var_dump($val["keyword"]);
+       $entry_body = str_replace("{$val->keyword}=","%KEYWORD%</span>{$headend}\n<span class=\"entry-body\">\n",$entry_body);*/
+} elseif (preg_match("/^(id:{1})(.+)/u", $val->keyword) == 0) {
+//     var_dump($entry_body);
+       $entry_kw = "%KEYWORD%</span>{$headend}\n";
+} else {
+       $entry_kw = "%KEYWORD%</span>{$headend}\n";
+}
+//var_dump($entry_body);
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+       $replying = '<a href="./entry.php?entry=' . $val->id . '&amp;user=' . $val->user->id . '&amp;keyword=' . rawurlencode($val->keyword) . '" class="replying">Re</a> ';
+} else {
+  $replying = '';
+}
+//
+// var_dump($entry_body);
+//公式モバイル版における各エントリへのリンク URL 生成
+//$refer_link = $haiku_official_url . $val->user->id . '/' . $val->id;
+$refer_link = "http://{$haiku_host}/" . $val->user->id . "/" . $val->id;
+//タイムスタンプ
+if (preg_match("/[0-2][0-9]:[0-9]{2}:[0-9]{2}/u", $val->keyword)){
+  $dating = date("Y-m-d H:i:s", $unix_time);
+} else {
+  $day = date("Ymd", $unix_time);
+  $time = date("H:i", $unix_time);
+  $year = date("Y", $unix_time);
+  $today = date("Ymd");
+  $tyear = date("Y");
+  if ($year < $tyear){
+       $dating = date("Y-m-d", $unix_time).' '.$time;
+  } elseif ($day == $today){
+       $dating = ''.$time;
+  } elseif ($day == $today-1){
+       $dating = '昨日 '.$time;
+  } elseif ($day == $today-2){
+       $dating = '一昨日 '.$time;
+  } elseif ($day <= $today-3 && $day >= $today-6){
+       $wdaynum = getdate($unix_time);
+       $wdaylabel = array('日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日');
+       $dating = $wdaylabel[$wdaynum['wday']].' '.$time;
+  } else {
+       $dating = date("Y-m-d", $unix_time).' '.$time;
+  }
+}
+$entry_body_a = explode("\n", $entry_body);
+$entry_body_b = array();
+foreach ($entry_body_a as $line){
+  if ($get_image != 'on'){
+       if (preg_match("/<a[^>]*href=\".+(youtube|ugomemo|nicovideo).+\"[^>]*><img/u", $line)){
+         $line = preg_replace("/<img[^>]*alt=\"([^>\"]*)\"[^>]*>/ui", "\${1}", $line);
+         
+       } else {
+         $line = preg_replace("/<img[^>]*src=\"([^>\"]*)\"[^>]*>/uie", "parse_url('\\1', PHP_URL_HOST) . '(' . basename('\\1') . ')';", $line);
+         
+       }
+  }
+  if (preg_match("/<a[^>]*href=\".+(youtube|ugomemo|nicovideo).+\"[^>]*><img/u", $line)){
+       $line = preg_replace("/<a[^>]*href=\"({$http_url_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/ue", "'<a href=\"\\1\">\\2{$mobile_gateway_for_images}'.rawurlencode(rawurldecode('\\3')).'\\4';", $line);
+  } elseif (preg_match("/<a[^>]*href=\"({$http_url_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/u", $line)){
+       $line = preg_replace("/<a[^>]*href=\"(http:{$http_path_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/ue", "'<a href=\"{$mobile_gateway}'.rawurlencode(rawurldecode('\\3')).'\">\\2{$mobile_gateway_for_images}'.rawurlencode(rawurldecode('\\3')).'\\4';", $line);
+  }
+//   if (!preg_match("/<a[^>]*href=\"(http:\/\/d\.hatena\.(ne\.jp|com)\/keyword\/{$http_dir_regexp})\"[^>]*>([^<]+)<\/a>/ue", $line)){
+  if (mb_check_encoding(urldecode($line), 'UTF-8')){
+       $line = preg_replace("/<a[^>]*href=\"(http:{$http_path_regexp})\"[^>]*>([^<]+)<\/a>/ue", "'<a href=\"{$mobile_gateway}'.rawurlencode(rawurldecode('\\1')).'\">'.rawurldecode('\\2').'</a>';", $line);
+  } else {
+  }
+  $line = mb_ereg_replace('\\\("|\'|\\\)', "\\1", $line);
+  $entry_body_b[] = $line;
+}
+$entry_body = implode("\n", $entry_body_b);
+
+// var_dump($entry_body);
+//map 記法の処理
+if ($get_image == 'on'){
+  $entry_body = preg_replace("/(map):(-*[[:digit:]]{1,3}\.*[[:digit:]]*):(-*[[:digit:]]{1,3}\.*[[:digit:]]*)/u", "<a href=\"http://www.google.co.jp/m/local?site=local&amp;q=\${2}%2C\${3}\" class=\"to-map\"><img src=\"http://maps.google.com/maps/api/staticmap?maptype=mobile&amp;markers=\${2}%2C\${3}&amp;sensor=false&amp;size=140x140&amp;zoom=13\" width=\"140\" height=\"140\" /></a><br />[ココ]<a href=\"http://c.hatena.ne.jp/s/nearby?lat=\${2}&amp;lon=\${3}\" class=\"to-coco\">この地点の近くのスポット</a>", $entry_body);
+} else {
+  $entry_body = preg_replace("/(map):(-*[[:digit:]]{1,3}\.*[[:digit:]]*):(-*[[:digit:]]{1,3}\.*[[:digit:]]*)/u", "<a href=\"http://www.google.co.jp/m/local?site=local&amp;q=\${2}%2C\${3}\" class=\"to-map\">\${1}:\${2}:\${3}</a><br />[ココ]<a href=\"http://c.hatena.ne.jp/s/nearby?lat=\${2}&amp;lon=\${3}\" class=\"to-coco\">この地点の近くのスポット</a>", $entry_body);
+}
+//表示
+$echo = $echo . "<div class=\"entry\"";
+if (!isset($eprocessor_sub_mode) || $eprocessor_sub_mode != 'presult'){
+  $echo = $echo . " id=\"{$val->id}\"";
+}
+$echo = $echo . ">";
+
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  if (isset($starisjs) && $starisjs == '1'){
+  } else {
+    $echo = $echo . '<form method="post" action="';
+    $echo = $echo . './post.php';
+  //   if ($device_who == 'android' && preg_match("/(1\.6)|(1\.5)/", $_SERVER['HTTP_USER_AGENT'])) $echo = $echo . $self_anchor_possibly_with_pagenum;
+  //   if (isset($entry_processor_mode) && $entry_processor_mode != 'entry') $echo = $echo . '&amp;reftime=-'.$first_time . ',0'. '#'.$val->id;
+    $echo = $echo . '" class="star-form">';
+  }
+}
+$echo = $echo . "<span class=\"entry-head\">";
+if ($get_image == 'on' || (isset($show_icon) && $show_icon == 'yes')){
+       $echo = $echo . '<img src="' . $val->user->profile_image_url . '" width="16" height="16" class="user-icon" alt="" /> ';
+}
+
+//キーワードの処理
+if (!isset($val->keyword)){
+       $entry_body = ' ' . $add_star . $show_star . $entry_body;
+}
+if ($entries_mode == 'keyword_timeline'){
+  $entry_kw = $add_star . $show_star . '</span>' . $headend . "\n";
+} else {
+// if ($get_image == 'on'){
+//   $entry_kw = str_replace("%KEYWORD%","<a href=\"./entries.php?keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"keyword\">". htmlspecialchars($val->target->title, ENT_QUOTES) . "</a> {$add_star}{$show_star}",$entry_kw);
+// } else {
+  $entry_kw = str_replace("%KEYWORD%","<a href=\"./entries.php?keyword=" . rawurlencode($val->keyword) . "\" class=\"keyword\">". htmlspecialchars($val->target->title, ENT_QUOTES) . "</a> {$add_star}{$show_star}",$entry_kw);
+// }
+
+//id キーワードの処理
+  if (preg_match('/^(id:{1}[a-zA-Z]{1}[-_a-zA-Z1234567890]{1,30}[a-zA-Z1234567890]{1})$/u',$val->keyword) >= 1){
+//   if ($get_image == 'on'){
+//     $entry_kw = "<a href=\"./entries.php?keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"keyword\">" . htmlspecialchars($val->target->word, ENT_QUOTES) . "</a> {$add_star}{$show_star}</span>{$headend}\n";
+//   } else {
+       $entry_kw = "<a href=\"./entries.php?keyword=" . rawurlencode($val->keyword) . "\" class=\"keyword\">" . htmlspecialchars($val->target->word, ENT_QUOTES) . "</a> {$add_star}{$show_star}</span>{$headend}\n";
+//   }
+  }
+}
+//Reply-to
+if ($val->in_reply_to_status_id != ''){
+//     echo "...";
+//   if ($get_image == 'on'){
+//     $reply_to = "<span class=\"reply-to reply\"><a href=\"./entry.php?entry={$val->in_reply_to_status_id}&amp;user={$val->in_reply_to_user_id}&amp;keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"hatena-id\">[← " . $val->in_reply_to_user_id . " へ</a></span>";
+//   } else {
+       $reply_to = "<span class=\"reply-to reply\"><a href=\"./entry.php?entry={$val->in_reply_to_status_id}&amp;user={$val->in_reply_to_user_id}&amp;keyword=" . rawurlencode($val->keyword) . "\" class=\"hatena-id\">[← " . $val->in_reply_to_user_id . " へ</a></span>";
+//   }
+       if (mb_substr_count($entry_body, '<br />') < 1){
+               if (preg_match('/\[画像\(.+\)\]/u', $entry_body) || preg_match('/<img[^>]+\/>/u', $entry_body)){
+                       $reply_to = $reply_to."<br />\n";
+               } else {
+                       $reply_to = $reply_to.' ';
+               }
+       } else {
+               $reply_to = $reply_to."<br />\n";
+       }
+       $entry_body = $reply_to.$entry_body;
+}
+//Reply-from
+if (isset($reply_from)){
+       unset($reply_from);
+}
+if (isset($in_reply)){
+       unset($in_reply);
+}
+if (isset($val->replies[0]->id)){
+  $in_reply = '';
+       foreach($val->replies as $replies){
+//       if ($get_image == 'on'){
+//             $in_reply = $in_reply . " <a href=\"./entry.php?entry={$replies->id}&user={$replies->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"hatena-id\">[← {$replies->user->id} から</a> ";
+//       } else {
+               $in_reply = $in_reply . " <a href=\"./entry.php?entry={$replies->id}&user={$replies->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "\" class=\"hatena-id\">[← {$replies->user->id} から</a> ";
+//       }
+       }
+       $reply_from = "<span class=\"reply-from reply\">{$in_reply}</span>";
+} else {
+  $reply_from = '';
+}
+//
+// $entry_body = preg_replace("/(<a[^>]+>)([^<]+)(<\/a>)/ue", "'\\1'.urldecode('\\2').'\\3';", $entry_body);
+// var_dump($entry_body);
+$entry_body = mb_ereg_replace('\\\("|\'|\\\)', "\\1", $entry_body);
+// var_dump($entry_body);
+// $entry_body = $entry_body . "<br />\n";
+$echo = $echo . "{$dating} ";
+$echo = $echo . $entry_kw;
+$echo = $echo . "<p class=\"entry-body\">\n";
+$echo = $echo . $entry_body;
+$echo = $echo . "</p>\n";
+$echo = $echo . "<span class=\"dating\">";
+$echo = $echo . "by <a href=\"./entries.php?user=";
+$echo = $echo . $val->user->id;
+//   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
+$echo = $echo . "\" class=\"hatena-id\" title=\"id:{$val->user->screen_name}\">";
+$echo = $echo . htmlspecialchars($val->user->name, ENT_QUOTES);
+$echo = $echo . '</a> ';
+$echo = $echo . ' ';
+if ($entry_processor_mode == 'entry'){
+  $echo = $echo . 'from ' . $val->source . ' ';
+}
+$echo = $echo . "{$replying}{$reply_from} <a href=\"{$refer_link}\" class=\"to-original-link\">&nbsp;†&nbsp;</a>";
+$echo = $echo . '</span>';
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+if (isset($starisjs) && $starisjs == '1'){
+} else {
+  $echo  = $echo . "</form>";
+}
+} 
+$echo = $echo . "</div><hr />\n";
+}
+?>
\ No newline at end of file
diff --git a/favicon.ico b/favicon.ico
new file mode 100644 (file)
index 0000000..8a9f4fe
Binary files /dev/null and b/favicon.ico differ
diff --git a/footer_include.php b/footer_include.php
new file mode 100644 (file)
index 0000000..ebbd984
--- /dev/null
@@ -0,0 +1,213 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2014 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php defined("HELLO") or exit(); ?>
+<?php
+if (isset($navi_paging)){
+if ($navi_paging === TRUE){
+$base_query = $_SERVER['QUERY_STRING'];
+$base_query = preg_replace("/&reftime=[^&]+/u", "", $base_query);
+$base_query = preg_replace("/&log=try/u", "", $base_query);
+$base_query = preg_replace("/&oauth_token=[^&]+/u", "", $base_query);
+$base_query = preg_replace("/&oauth_verifier=[^&]+/u", "", $base_query);
+  if (isset($_GET['page']) && $_GET['page'] != ''){
+         if ($_GET['page'] >= 100){
+                 $next_query = preg_replace('/page=[0123456789]{1,3}/u',"page=1",$base_query);
+                 $next_url = "http://{$_SERVER["SERVER_NAME"]}{$_SERVER['PHP_SELF']}?$next_query";
+                 $next_num = 1;
+         }     else {
+                         $next_num = $_GET['page'] + 1;
+                         $next_query = preg_replace('/page=[0123456789]{1,3}/u',"page={$next_num}",$base_query);
+                         $next_url = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"] . "?" . $next_query;
+                 }
+  }    elseif ($base_query != ""){
+                 $next_num = 2;
+                 $next_query = $base_query . "&page=" . $next_num;
+                 $next_url = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"] . "?" . $next_query;
+  }    else {
+                 $next_num = 2;
+                 $next_query = "page=" . $next_num;
+                 $next_url = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"] . "?" . $next_query;
+  }
+  if ($next_num == 1){
+         $current_page = 100;
+  } else {
+         $current_page = $next_num - 1;
+  }
+  if (isset($_GET['page']) && $_GET['page'] != ''){
+         if ($_GET['page'] <= 1){
+                 $prev_query = preg_replace('/page=[0123456789]{1,3}/u',"page=100",$base_query);
+                 $prev_url = "http://{$_SERVER["SERVER_NAME"]}{$_SERVER['PHP_SELF']}?$prev_query";
+                 $prev_num = 100;
+         } else {
+                 $prev_num = $_GET['page'] - 1;
+                 $prev_query = preg_replace('/page=[0123456789]{1,3}/u',"page={$prev_num}",$base_query);
+                 $prev_url = "http://{$_SERVER['SERVER_NAME']}" . $_SERVER["PHP_SELF"] . "?" . $prev_query;
+         }
+  } elseif ($base_query != ''){
+         $prev_num = 100;
+         $prev_query = $safequery . '&page=' . $prev_num;
+         $prev_url = "http://{$_SERVER['SERVER_NAME']}" . $_SERVER["PHP_SELF"] . "?" . $prev_query;
+  } else {
+         $prev_num = 100;
+         $prev_query = 'page=' . $prev_num;
+         $prev_url = "http://{$_SERVER['SERVER_NAME']}" . $_SERVER["PHP_SELF"] . "?" . $prev_query;
+  }
+if (mb_strlen($next_num) == 1) $next_str = ''.$next_num;
+if (mb_strlen($next_num) == 2) $next_str = ''.$next_num;
+if (mb_strlen($next_num) == 3) $next_str = $next_num;
+if (mb_strlen($prev_num) == 1) $prev_str = ''.$prev_num;
+if (mb_strlen($prev_num) == 2) $prev_str = ''.$prev_num;
+if (mb_strlen($prev_num) == 3) $prev_str = $prev_num;
+}
+}
+?>
+<?php
+if ($device_who == 'ktai'){
+  $navi_str['new'] = '最新';
+  $navi_str['public'] = '全員';
+  $navi_str['mail'] = 'メール';
+  $navi_str['prev'] = '前へ';
+  $navi_str['img']['show'] = '画像有';
+  $navi_str['img']['hide'] = '画像無';
+  $navi_str['next'] = '次へ';
+  $navi_str['keywd']['default'] = '鍵語';
+  $navi_str['keywd']['fav'] = '愛鍵';
+  $navi_str['keywd']['rel'] = '連鍵';
+  $navi_str['home'] = '受信器';
+  $navi_str['top'] = '一面';
+  $navi_str['omit'] = '&nbsp;-&nbsp;-&nbsp;-';
+} else {
+  $navi_str['new'] = '最新の句';
+  $navi_str['public'] = '皆の投稿';
+  $navi_str['mail'] = 'メール';
+  $navi_str['prev'] = '前/p'. $prev_str;
+  $navi_str['img']['show'] = '画像表示';
+  $navi_str['img']['hide'] = '画像省略';
+  $navi_str['next'] = '次/p'. $next_str;
+  $navi_str['keywd']['default'] = '鍵語一覧';
+  $navi_str['keywd']['fav'] = '愛好鍵語';
+  $navi_str['keywd']['rel'] = '関連鍵語';
+  $navi_str['home'] = 'アンテナ';
+  $navi_str['top'] = 'トビラ';
+  $navi_str['omit'] = '&nbsp;-&nbsp;-&nbsp;-&nbsp;-';
+}
+?>
+<?php
+/*if ($_GET['image'] != ''){
+       $qimagemode = '?image=' . $_GET['image'];
+} else {
+       $qimagemode = '';
+}*/
+if ((isset($entries_mode) && $entries_mode == 'default') || (isset($list_mode) && $list_mode == 'default')){
+       $first = $self_anchor.'?page=1';
+} else {
+       $first = $self_anchor.'&amp;page=1';
+}
+$to_entries = './entries.php';
+$to_index = './index.php';
+$to_keywords = './keywords.php';
+// if ($get_image == 'on'){
+//   $first = $first.'&amp;image=on';
+//   $to_entries = $to_entries.'?image=on';
+//   $to_index = $to_index.'?image=on';
+// }
+if ($navi_paging === TRUE){
+  $echo = $echo . '<ul id="page-navi">';
+  $echo = $echo . '<li>';
+  if (isset($first_time) && $first_time != '' && $current_page > 1) $prev_url = $prev_url . '&reftime=%2B' . $first_time . '%2C1';
+  $prev_url = htmlspecialchars($prev_url, ENT_QUOTES);
+  $echo = $echo . "4.<a href=\"{$prev_url}\" class=\"navigation-link\" accesskey=\"4\" rel=\"nofollow\">{$navi_str['prev']}</a> ";
+  $echo = $echo . '</li>';
+
+  $echo = $echo . '<li>';
+  $echo = $echo . "〈ここは第 " . $current_page . " 頁〉";
+  if (isset($unix_time) && $unix_time != '' & $current_page < 100) $next_url = $next_url . '&reftime=-' . $unix_time . '%2C1';
+  $echo = $echo . '</li>';
+
+  $echo = $echo . '<li>';
+  $next_url = htmlspecialchars($next_url, ENT_QUOTES);
+  $echo = $echo . "6.<a href=\"{$next_url}\" class=\"navigation-link\" accesskey=\"6\" rel=\"nofollow\">{$navi_str['next']}</a></li>";
+  $echo = $echo . "</ul>\n";
+}
+
+$echo = $echo . '<ul id="navigation-menu">';
+if ($navi_paging === TRUE){
+  $echo = $echo . "<li>";
+  $echo = $echo . "1.<a href=\"{$first}\" class=\"navigation-link\" accesskey=\"1\">{$navi_str['new']}</a> ";
+  $echo = $echo . '</li>';
+}
+
+$echo = $echo . '<li>';
+$echo = $echo . "2.<a href=\"{$to_entries}\" class=\"navigation-link\" accesskey=\"2\">{$navi_str['public']}</a> ";
+$echo = $echo . '</li>';
+
+$echo = $echo . '<li>';
+$echo = $echo . "3.<a href=\"mailto:h@hatena.ne.jp?subject=";
+if (isset($_GET['keyword'])){
+  $echo = $echo . rawurlencode(mb_convert_encoding(rawurldecode($_GET['keyword']), $charcode, 'UTF-8'));
+} elseif (isset($_GET['word'])){
+  $echo = $echo . rawurlencode(mb_convert_encoding(rawurldecode($_GET['word']), $charcode, 'UTF-8'));
+}
+if (isset($_GET['body'])) $echo = $echo . '&amp;body='.rawurlencode(mb_convert_encoding(rawurldecode($_GET['body']), $charcode, 'UTF-8'));
+$echo = $echo . "\" class=\"navigation-link\" accesskey=\"3\">{$navi_str['mail']}</a></li>";
+
+if ($navi_imaging === TRUE){
+  $echo = $echo . "<li>";
+  if ($get_image == 'on'){
+         $self_anchor_invert_imagemode = $self_anchor_possibly_with_pagenum . '&amp;image=off';
+         if (isset($first_time) && $first_time != '') $self_anchor_invert_imagemode = $self_anchor_invert_imagemode . '&amp;reftime=-' . $first_time . ',0';
+         $echo = $echo . '5.<a href="' . $self_anchor_invert_imagemode .  '" class="navigation-link" accesskey="5" rel="nofollow">'. $navi_str['img']['hide'] .'</a> ';
+  } else {
+         $self_anchor_invert_imagemode = $self_anchor_possibly_with_pagenum . '&amp;image=on';
+         if (isset($first_time) && $first_time != '') $self_anchor_invert_imagemode = $self_anchor_invert_imagemode . '&amp;reftime=-' . $first_time . ',0';
+         $echo = $echo . '5.<a href="' . $self_anchor_invert_imagemode . '" class="navigation-link" accesskey="5" rel="nofollow">'. $navi_str['img']['show'] .'</a> ';
+  }
+  $echo = $echo . '</li>';
+}
+
+$echo = $echo . '<li>';
+if (isset($entries_mode)){
+  if ($entries_mode == 'keyword_timeline'){
+// var_dump($entries_mode);
+       $echo = $echo . "7.<a href=\"./keywords.php?related=".rawurlencode($_GET['keyword']);
+//     if ($get_image == 'on') $echo = $echo . '&amp;image=on';
+       $echo = $echo . "\" class=\"navigation-link\" accesskey=\"7\">{$navi_str['keywd']['rel']}</a> ";
+  } elseif ($entries_mode == 'user_timeline'){
+       $echo = $echo . "7.<a href=\"./keywords.php?user=".$get_user;
+//     if ($get_image == 'on') $echo = $echo . '&amp;image=on';
+       $echo = $echo . "\" class=\"navigation-link\" accesskey=\"7\">{$navi_str['keywd']['fav']}</a> ";
+  } elseif ($entries_mode == 'friends_timeline'){
+       $echo = $echo . "7.<a href=\"./keywords.php?user=".$get_following;
+//     if ($get_image == 'on') $echo = $echo . '&amp;image=on';
+       $echo = $echo . "\" class=\"navigation-link\" accesskey=\"7\">{$navi_str['keywd']['fav']}</a> ";
+  } else {
+       $echo = $echo . '7.<a href="'.$to_keywords;
+//     if ($get_image == 'on') $echo = $echo . '?image=on';
+       $echo = $echo . "\" class=\"navigation-link\" accesskey=\"7\">{$navi_str['keywd']['default']}</a> ";
+  }
+} else {
+  $echo = $echo . '7.<a href="'.$to_keywords;
+//   if ($get_image == 'on') $echo = $echo . '?image=on';
+  $echo = $echo . "\" class=\"navigation-link\" accesskey=\"7\">{$navi_str['keywd']['default']}</a> ";
+}
+$echo = $echo . '</li>';
+
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  $echo = $echo . '<li>';
+       $echo = $echo . "8.<a href=\"./entries.php?following={$_SESSION['hatenaid']}";
+//     if ($get_image == 'on') $echo = $echo . '&amp;image=on';
+       $echo = $echo . "\" class=\"navigation-link\" accesskey=\"8\">{$navi_str['home']}</a> ";
+$echo = $echo . '</li>';
+}
+
+$echo = $echo . '<li>';
+$echo = $echo . '9.<a href="'.$to_index.'" class="navigation-link" accesskey="9">'. $navi_str['top'] .'</a>';
+$echo = $echo . '</li>';
+
+$echo = $echo ."</ul>\n<hr />";
+$echo = $echo . echoCommonFooter();
+$echo = $echo . $footer;
+?>
\ No newline at end of file
diff --git a/index.php b/index.php
new file mode 100644 (file)
index 0000000..8561072
--- /dev/null
+++ b/index.php
@@ -0,0 +1,157 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2014 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+require_once 'init_processor.php';
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+//session_regenerate_id(TRUE);
+if (isset($_GET['with']) || isset($_GET['log'])){
+  require 'login_processor.php';
+}
+?>
+<?php
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+$self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}";
+if ($get_image == 'on'){
+               $self_anchor_with_imagemode = $self_anchor . '?image=on';
+} else {
+               $self_anchor_with_imagemode = $self_anchor . '?image=off';
+}
+$relog_back = $self_anchor_with_imagemode . '&log=try';
+$relogin = $self_anchor_with_imagemode . '&amp;with=haiku&amp;callback='.rawurlencode(rawurldecode($relog_back));
+//echo ini_get("include_path");
+$echo = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
+       <meta http-equiv="Content-Style-Type" content="text/css" />
+       <meta http-equiv="Content-Script-Type" content="text/javascript" />
+       <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
+       <title>{$site_name} {$site_name_caption}</title>
+       <link rel="stylesheet" href="{$style_sheet}" />
+       <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
+</head>
+<body>
+EOL;
+?>
+<?php
+$echo = $echo . echoCommonHeader('#com-ftr', $self_anchor_with_imagemode) . "<hr />\n";
+$echo = $echo . '<div id="header">';
+$echo = $echo . "<h1 id=\"index-head\" class=\"head1\">{$site_name}</h1>\n";
+$echo = $echo . "<p class=\"caption\">by <abbr title=\"{$product_name_full}\">{$product_name_abbr}</abbr> Ver.{$product_version}</p>\n";
+$echo = $echo . <<<EOL
+</div>
+<div id="index-contents" class="contents">
+EOL;
+// var_dump($_SESSION);
+if (isset($_SESSION['oauth_stat'])){
+  $echo = $echo . '<div class="oauth-res">'."\n";
+  if ($_SESSION['oauth_stat'] === TRUE) {
+       $echo = $echo . "<span>アクセストークンを更新しました。</span>\n";
+  } else {
+       $echo = $echo . "<span>アクセストークンを取得できませんでした。</span>\n";
+       $echo = $echo . "<blockquote>{$_SESSION['oauth_stat']}</blockquote>";
+  }
+  $echo = $echo . '</div>'."\n";
+}
+$echo = $echo . <<<EOL
+<div class="index-content">
+<h2 id="users-index-head">ユーザーのページ</h2>
+<ul>
+EOL;
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  $echo = $echo . "<li><a href=\"./entries.php?following={$_SESSION['hatenaid']}\n";
+//   if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '&amp;image=on';
+  $echo = $echo . "\" class=\"user\">{$_SESSION['hatenaid']} のアンテナ</a></li>\n";
+  $echo = $echo . "<li><a href=\"./entries.php?user={$_SESSION['hatenaid']}";
+//   if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '&amp;image=on';
+  $echo = $echo . "\" class=\"user\">{$_SESSION['hatenaid']} のエントリー</a></li>\n";
+  $echo = $echo . "<li><a href=\"./entries.php?favours={$_SESSION['hatenaid']}";
+//   if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . "&amp;image=on";
+  $echo = $echo . "\" class=\"user\">{$_SESSION['hatenaid']} のお気に入り</a></li>\n";
+  $echo = $echo . "<li><a href=\"{$relogin}\" class=\"user\">再認証</a></li>";
+} else {
+  $echo = $echo . '<li><form method="get" action="./entries.php">';
+  $echo = $echo . '<label for="userflw">id:</label><input type="text" name="following" maxlength="32" id="userflw"/><label for="userflw">のアンテナを</label><input type="submit" value="表示" />';
+//   if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '<input type="hidden" name="image" value="on" />';
+  $echo = $echo . '</form></li>'."\n";
+  $echo = $echo . '<li><form method="get" action="./entries.php">';
+  $echo = $echo . '<label for="username">id:</label><input type="text" name="user" maxlength="32" id="username"/><label for="username">のエントリーを</label><input type="submit" value="表示" />';
+  if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '<input type="hidden" name="image" value="on" />';
+  $echo = $echo . '</form></li>'."\n";
+}
+
+// $echo = $echo . "<li><a href=\"./config.php";
+// if (isset($get_image) && $get_image == 'on') $echo = $echo . '?image=on';
+// $echo = $echo . "\" class=\"user\">YANMAH2 の設定</a></li>\n";
+$echo = $echo . "</ul>\n</div>\n";
+?>
+<?php
+$echo = $echo . <<<EOL
+<div class="index-content content">
+<h2 id="entries-index-head">みんなのページ</h2>
+<ul>
+EOL;
+$echo = $echo . '<li><a href="./entries.php';
+// if(isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '?image=on';
+$echo = $echo . '" class="entries">みんなのエントリー</a></li>';
+$echo = $echo . '<li><a href="./entries.php?album=public';
+// if(isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '&amp;image=on';
+$echo = $echo . '" class="entries">みんなのアルバム</a></li>';
+$echo = $echo . '<li><a href="./entries.php?users=public';
+// if(isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '&amp;image=on';
+$echo = $echo . '" class="entries">ユーザー一覧</a></li>';
+$echo = $echo . "</ul>\n</div>\n";
+?>
+<?php
+$echo = $echo . <<<EOL
+<div class="index-content">
+<h2 id="keywords-index-head">キーワード</h2>
+<ul>
+<li><form method="get" action="./keywords.php" accept-charset="{$meta_charset}">
+<label for="go2keyword">キーワード</label><input type="text" name="word" maxlength="170" id="go2keyword" /><label for="go2keyword">を</label>
+<input type="submit" value="検索" />
+EOL;
+// if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '<input type="hidden" name="image" value="on" />';
+$echo = $echo . '</form></li>';
+// $request_url = "{$api_base_url}keywords/hot.xml".'?without_related_keywords=1';
+// $use_cache = FALSE;
+// require_once 'keywords_processor.php';
+?>
+<?php
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+       $echo = $echo . '<li><a href="./keywords.php?user=' . $_SESSION['hatenaid'];
+       $echo = $echo . '" class="keyword">' . $_SESSION['hatenaid'] . ' のお気に入りキーワード</a></li>' . "\n";
+}
+$echo = $echo . '<li><a href="./keywords.php';
+// if(isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '?image=on';
+$echo = $echo . '" class="keyword">キーワード一覧</a></li>';
+$echo = $echo . "</ul>\n</div>\n</div>\n<hr />\n";
+?>
+<?php
+$echo = $echo . echoCommonFooter('#com-hdr');
+$echo = $echo . $footer;
+$echo = $echo . '</body></html>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+if (isset($_SESSION['oauth_stat'])) unset($_SESSION['oauth_stat']);
+?>
\ No newline at end of file
diff --git a/init_processor.php b/init_processor.php
new file mode 100644 (file)
index 0000000..ecc558f
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/ormodify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php defined("HELLO") or exit(); ?>
+<?php
+ini_set('session.gc_maxlifetime', $session_file_lifetime);
+if ($session_gc_prob[0] != 'default') ini_set('session.gc_probability', $session_gc_prob[0]);
+if ($session_gc_prob[1] != 'default') ini_set('session.gc_divisor', $session_gc_prob[1]);
+ini_set('session.use_trans_sid', 0);
+session_set_cookie_params($session_cookie_expire, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+if ($custom_session_save_path != 'default'){
+       session_save_path($custom_session_save_path);
+}
+session_start();
+//session_regenerate_id(TRUE);
+?>
+<?php
+if ($extra_include_path != "default"){
+       $default_include_path = ini_get("include_path");
+       ini_set('include_path', ".:{$extra_include_path}:{$default_include_path}");
+}
+$http_url_regexp = 's?https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:@&=+$,%#]+';
+$http_host_regexp = 's?https?:\/\/[-_.!~*\'()a-zA-Z0-9;?:@&=+$,%#]+\/*';
+$http_path_regexp = '[-_.!~*\'()a-zA-Z0-9;\/?:@&=+$,%#]*';
+$http_dir_regexp = '[-_.!~*\'()a-zA-Z0-9;\/@&=+$,%]+';
+mb_internal_encoding('UTF-8');
+mb_regex_encoding("UTF-8");
+libxml_use_internal_errors(TRUE);
+date_default_timezone_set('Asia/Tokyo');
+?>
+<?php
+//NULL バイトの入力を弾く
+checkNull($_GET);
+checkNull($_POST);
+checkNull($_COOKIE);
+?>
+<?php
+if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] != ''){
+  $device_who = whatDevice($_SERVER['HTTP_USER_AGENT']);
+} else {
+  $device_who = 'generic';
+}
+?>
+<?php
+if (isset($_GET['ce']) && preg_match("/^(UTF-8|SJIS|EUC-JP|JIS)$/i",$_GET['ce'])){
+  setcookie('charcode', $_GET['ce'], time() + $session_cookie_expire);
+  $charcode = $_GET['ce'];
+} elseif (isset($_COOKIE['charcode']) && preg_match("/^(UTF-8|SJIS|EUC-JP|JIS)$/i",$_COOKIE['charcode'])){
+  $charcode = $_COOKIE['charcode'];
+}
+switch ($charcode){
+       case 'UTF-8':
+               $meta_charset = 'utf-8';
+               break;
+       case 'SJIS';
+               $meta_charset = 'Shift_JIS';
+               break;
+       case 'EUC-JP':
+               $meta_charset = 'euc-jp';
+               break;
+       case 'JIS':
+               $meta_charset = 'iso-2022-jp';
+               break;
+       default:
+               $meta_charset = 'utf-8';
+               break;
+}
+?>
+<?php
+// if (isset($_GET['image']) && isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+//     $_SESSION['image'] = $_GET['image'];
+// }
+if (isset($_GET['image']) && preg_match("/^(on|off)$/", $_GET['image'])){
+  setcookie('y2dconfig', $_GET['image'], time()+60*60*24*365);
+}
+if (isset($_GET['image']) && $_GET['image'] == 'on'){
+  $get_image = 'on';
+} elseif (isset($_GET['image']) && $_GET['image'] == 'off'){
+  $get_image = 'off';
+} elseif (isset($_COOKIE['y2dconfig']) && $_COOKIE['y2dconfig'] == 'on'){
+  $get_image = 'on';
+} elseif (isset($_COOKIE['y2dconfig']) && $_COOKIE['y2dconfig'] == 'off'){
+  $get_image = 'off';
+} else {
+  $get_image = 'off';
+}
+
+if (isset($_COOKIE['y2config'])){
+  parse_str($_COOKIE['y2config'], $y2config);
+}
+if (isset($y2config['count']) && $y2config['count'] != '' && preg_match("/^[0123456789]{1,3}$/", $y2config['count'])){
+  $ecount = $y2config['count'];
+}
+if (isset($y2config['showicon']) && $y2config['showicon'] != '' && preg_match("/^(yes|no)$/", $y2config['showicon'])){
+  $show_icon = $y2config['showicon'];
+}
+if (isset($y2config['disbr']) && $y2config['disbr'] != '' && preg_match("/^(yes|no)$/", $y2config['disbr'])){
+  $disbr = $y2config['disbr'];
+}
+if (isset($y2config['starisjs']) && $y2config['starisjs'] != '' && preg_match("/^(0|1)$/", $y2config['starisjs'])){
+  $starisjs = $y2config['starisjs'];
+}
+if (isset($y2config['elimit']) && $y2config['elimit'] != '' && preg_match("/^[0123456789]{1,3}$/", $y2config['elimit'])){
+  $entry_limit = $y2config['elimit'];
+}
+if (isset($y2config['hdomain']) && $y2config['hdomain'] != '' && preg_match("/^(h|h1beta)(\.hatena\.ne\.jp|\.hatena\.com)$/", $y2config['hdomain'])){
+  $haiku_host = $y2config['hdomain'];
+  $haiku_official_url = preg_replace("/(http:\/\/)[^\/]+(\/.*)/u", "\${1}{$haiku_host}\${2}", $haiku_official_url);
+  $api_base_url = "http://{$haiku_host}/api/";
+}
+if (isset($y2config['iscale']) && $y2config['iscale'] != '' && preg_match("/^[[:digit:]]{1}\.{0,1}[[:digit:]]{0,1}$/", $y2config['iscale'])){
+  $iscale = $y2config['iscale'];
+} else {
+  $iscale = '1';
+}
+// var_dump($y2config);
+?>
\ No newline at end of file
diff --git a/keywords.php b/keywords.php
new file mode 100644 (file)
index 0000000..9764723
--- /dev/null
@@ -0,0 +1,157 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2014 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+require_once "init_processor.php";
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+//session_regenerate_id(TRUE);
+?>
+<?php
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+$safequery = htmlspecialchars($_SERVER["QUERY_STRING"], ENT_QUOTES);
+?>
+<?php
+//長すぎる検索ワード
+if (isset($_GET["word"])) checkWord($_GET["word"]);
+if (isset($_GET['related'])) checkWord($_GET['related']);
+//不正なはてなID
+if (isset($_GET["user"])) checkId($_GET["user"]);
+//不正な page
+if (isset($_GET['page'])) checkPagenum($_GET['page']);
+?>
+<?php
+//
+// require 'login_processor.php';
+?>
+<?php
+if (isset($_GET['word']) && $_GET['word'] != ''){
+  $get_word = $_GET['word'];
+  $get_word = mb_convert_encoding($get_word, 'UTF-8', $charcode);
+  $json_url = $api_base_url.'keywords/list.xml?word=' . rawurlencode($get_word).'&without_related_keywords=1';
+  $page_head = htmlspecialchars($get_word, ENT_QUOTES) . ' に一致するキーワード';
+  $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}".'?word=' . rawurlencode(htmlspecialchars($get_word, ENT_QUOTES));
+  $list_mode = 'search';
+} elseif (isset($_GET['user']) && $_GET['user'] != ''){
+  $get_user = $_GET['user'];
+  $json_url = $api_base_url.'statuses/keywords/' . $get_user . '.xml'.'?without_related_keywords=1';
+  $page_head = htmlspecialchars($get_user, ENT_QUOTES) . ' のお気に入りキーワード';
+  $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}".'?user=' . $get_user;
+  $list_mode = 'following';
+} elseif(isset($_GET['related']) && $_GET['related'] != ''){
+  $get_related = $_GET['related'];
+  $get_related = mb_convert_encoding($get_related, 'UTF-8', $charcode);
+  $json_url = $api_base_url.'keywords/show/'.rawurlencode($get_related).'.xml';
+  $page_head = htmlspecialchars($get_related, ENT_QUOTES).' の関連キーワード';
+  $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}".'?related='.$get_related;
+  $list_mode = 'related';
+} else {
+  $json_url = $api_base_url.'keywords/list.xml'.'?without_related_keywords=1';
+  $page_head = 'キーワード一覧';
+  $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}";
+  $list_mode = 'default';
+}
+if (isset($_GET['page']) && $_GET['page'] != ''){
+       if ($list_mode == 'default' || $list_mode == 'related'){
+               $self_anchor_possibly_with_pagenum = $self_anchor . '?page=' . $_GET['page'];
+       } else {
+               $self_anchor_possibly_with_pagenum = $self_anchor . '&amp;page=' . $_GET['page'];
+       }
+       $relog_back = $self_anchor_possibly_with_pagenum . '&log=try';
+       $relogin = $self_anchor_possibly_with_pagenum . '&amp;with=haiku&amp;callback='.rawurlencode($relog_back);
+} else {
+       $self_anchor_possibly_with_pagenum = $self_anchor;
+       if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != ''){
+         $relog_back = $self_anchor_possibly_with_pagenum . '&log=try';
+         $relogin = $self_anchor_possibly_with_pagenum . '&amp;with=haiku&amp;callback='.rawurlencode($relog_back);
+       } else {
+         $relog_back = $self_anchor_possibly_with_pagenum . '?log=try';
+         $relogin = $self_anchor_possibly_with_pagenum . '?with=haiku&amp;callback='.rawurlencode($relog_back);
+       }
+}
+if ($get_image == 'on'){
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '&image=on';
+} else {
+               $self_anchor_with_imagemode = $self_anchor_possibly_with_pagenum . '&image=off';
+}
+?>
+<?php
+$echo = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
+       <meta http-equiv="Content-Style-Type" content="text/css" />
+       <meta http-equiv="Content-Script-Type" content="text/javascript" />
+       <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
+       <title>{$page_head} - {$site_name}{$site_name_caption}</title>
+       <link rel="stylesheet" href="{$style_sheet}" />
+       <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" /></head>
+<body>
+<div id="page">
+EOL;
+?>
+<?php
+//var_dump($_GET);
+// var_dump($json_url);
+// var_dump($list_mode);
+$echo = $echo . echoCommonHeader('#navigation-menu', $self_anchor_with_imagemode) . "<hr />\n";
+$echo = $echo . "<div id=\"header\" class=\"keywords\">\n";
+$echo = $echo . "<h1 id=\"entries-head\" class=\"head1\">{$page_head}</h1>\n<hr />";
+$echo = $echo . "</div>\n";
+?>
+<?php
+$echo = $echo . '<div class="contents"><ul class="kwd-ls">';
+$echo = $echo . '<li><form method="get" action="./keywords.php" accept-charset="'.$meta_charset.'">
+';
+$echo = $echo . '<label for="go2keyword">キーワード</label><input type="text" name="word" maxlength="170" id="go2keyword" /><label for="go2keyword">を</label>
+';
+// if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '<input type="hidden" name="image" value="on" />';
+$echo = $echo . '<input type="submit" value="検索" /></form></li>';
+?>
+<?php
+if (isset($_GET["page"]) && $_GET["page"] != ''){
+       if (isset($get_word) && $get_word != ''){
+               $request_url = $json_url . "&page=" . htmlspecialchars($_GET["page"], ENT_QUOTES);
+       }       elseif (isset($get_user) && $get_user != ''){
+                 $request_url = $json_url . "&page=" . htmlspecialchars($_GET["page"], ENT_QUOTES);
+       }       elseif (isset($get_related) && $get_related != ''){
+               $request_url = $json_url . '?page='.htmlspecialchars($_GET['page'], ENT_QUOTES);
+       } else {
+                       $request_url = $json_url . '&page=' . htmlspecialchars($_GET['page'], ENT_QUOTES);
+       }
+}      else {
+       $request_url = $json_url;
+}
+// var_dump($request_url);
+require_once 'keywords_processor.php';
+$echo = $echo . "</ul><hr /></div>";
+?>
+<?php
+if ($list_mode == 'related' || $list_mode == 'following'){
+  $navi_paging = FALSE;
+} else {
+  $navi_paging = TRUE;
+}
+  $navi_imaging = FALSE;
+require 'footer_include.php';
+$echo = $echo . '</div></body></html>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+?>
\ No newline at end of file
diff --git a/keywords_processor.php b/keywords_processor.php
new file mode 100644 (file)
index 0000000..4c7d5ed
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2014 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php defined("HELLO") or exit(); ?>
+<?php
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  $json = getJson($request_url, TRUE);
+} else {
+  $json = getJson($request_url, FALSE);
+}
+if ($json['stat'] !== TRUE){
+               $echo = $echo . "<li>はてなハイク API から一覧を取得できませんでした。";
+               $echo = $echo . "<blockquote>{$json['stat']}</blockquote></li>";
+               return;
+         } else {
+//             $contents = json_decode($json['body'], TRUE);
+               $contents = simplexml_load_string($json['body']);
+         }
+// }
+// var_dump($contents);
+if (libxml_get_last_error() !== FALSE){
+       $json = strip_tags($json['body']);
+       $echo = $echo . "<li>はてなハイク API から一覧を取得できませんでした。";
+       $echo = $echo . "<blockquote><pre>{$json}</pre></blockquote></li>";
+} elseif (isset($contents['error'])){
+       $echo = $echo . "<li>はてなハイク API から一覧を取得できませんでした。";
+       $echo = $echo . "<blockquote><pre>{$contents['error']}</pre></blockquote></li>";
+} else {
+//     echo "<pre>"; var_dump($contents); echo "</pre>";
+  if (isset($list_mode) && $list_mode == 'related'){
+//     echo "...";
+       foreach ($contents->related_keywords as $val){
+         $echo = $echo . "<li><a href=\"./entries.php?keyword=";
+         $echo = $echo . rawurlencode($val);
+//       if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '&amp;image=on';
+         $echo = $echo . "\" class=\"keyword\">";
+         $echo = $echo . htmlspecialchars($val, ENT_QUOTES);
+         $echo = $echo . "</a></li>";
+       }
+  } else {
+       foreach ($contents as $val){
+         $echo = $echo . "<li><a href=\"./entries.php?keyword=";
+         $echo = $echo . rawurlencode($val->word);
+//       if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '&amp;image=on';
+         $echo = $echo . "\" class=\"keyword\">";
+         $echo = $echo . htmlspecialchars($val->title, ENT_QUOTES);
+         $echo = $echo . "</a>(" . number_format((double)$val->entry_count) . ")</li>";
+       }
+  }
+}
+?>
\ No newline at end of file
diff --git a/login.php b/login.php
new file mode 100644 (file)
index 0000000..a162677
--- /dev/null
+++ b/login.php
@@ -0,0 +1,274 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/ormodify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+require_once "init_processor.php";
+// session_regenerate_id(TRUE);
+?>
+<?php
+$page_head = 'ログイン';
+$lot_one = array("猫とラーメンのトリコ",
+"邪神の眷族",
+"鳥類の王",
+"しなもんの使用人",
+"タルト連合親善大使",
+"どうやら",
+"こくだランド環境大臣",
+"仮面貴族",
+"地獄の",
+"青い宇宙(そら)からやって来た",
+"ピンクの頬の",
+"魔界倶楽部総裁",
+"革命戦士",
+"カレーに魅入られた",
+"エアはてなスタッフの",
+"ロールちゃん広報担当",
+"牛乳パックの",
+"ステキな",
+"人工無能",
+"魔法少女",
+"美少女戦士セーラー",
+"ダンプ",
+"キューティ",
+"ねずみの世話人",
+"カラアゲ食べたい",
+"ブロック機能実装期成同盟の",
+"イーグル",
+"アンドレ・ザ・",
+"ハルク・",
+"グレート・",
+"初代",
+"二代目",
+"三代目",
+"東洋の巨人",
+"魔法女装子",
+"破壊王",
+"ドロリッチ評論家",
+"サンニコフ島元島民",
+"火星人",
+"木星人",
+"エナガファンクラブ一号",
+"日本やんまにの会の",
+"エル・",
+"ラ・",
+"スペル・",
+"キレイな",
+"落ちている手袋研究家",
+"赤い仮面の",
+"忍者");
+$lot_two = array("今日も元気に",
+"今日もハイク、明日もハイク、これじゃ毎日",
+"迷ったら",
+"ホッと一息",
+"朝から千本",
+"何かあったら",
+"宴に飽きたら",
+"一人でいるなら",
+"デスマーチでも",
+"ネタにしたけりゃ",
+"みんなも一緒に",
+"そんなこと言ったって",
+"練習が終わったら",
+"そうだ、京都へ行っても",
+"月に代わって",
+"試合に負けても",
+"スクワット三千回分",
+"やる気がなくても",
+"てなこた忘れて",
+"悲しくったってコートの中では平気なら",
+"ドッドッドリフの",
+"とりあえず",
+"孫子曰く、彼を知り、己を知らば、",
+"子、曰わく、仁を求めて仁を得たり、また",
+"やや内角を狙い、えぐりこむように",
+"正義のためなら鬼となるより",
+"夢で逢えたら",
+"何もなくても",
+"風の唸りに血が叫び力の限り",
+"ナヌ? ****に疲れた? それなら",
+"アレはナンナンジャと思ったら");
+?>
+<?php //セキュリティのための前処理。
+//不正なはてなID
+if (isset($_POST["hatenaid"]) && $_POST["hatenaid"] != '') checkId($_POST["hatenaid"]);
+?>
+<?php
+if (isset($_GET['return']) && $_GET['return'] != ''){
+       $return = $_GET['return'];
+}
+?>
+<?php
+if (isset($_GET['log']) && $_GET['log'] == 'out'){
+       $_SESSION = array();
+       setcookie(session_name(),'',time()-999, dirname($_SERVER['SCRIPT_NAME']) . '/');
+       session_destroy();
+       $page_head = 'ログアウト';
+       $page_phase = 'after';
+} else {
+  $page_phase = 'before';
+}
+?>
+<?php
+//var_dump($_POST['login']);
+require 'login_processor.php';
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+$safequery = htmlspecialchars($_SERVER["QUERY_STRING"], ENT_QUOTES);
+$self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}";
+$self_anchor_possibly_with_pagenum = $self_anchor;
+if ($get_image == 'on'){
+               $self_anchor_with_imagemode = $self_anchor . '?image=on';
+} else {
+               $self_anchor_with_imagemode = $self_anchor . '?image=off';
+}
+// var_dump($self_anchor);
+?>
+<?php
+$echo = <<<EOL
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
+       <meta http-equiv="Content-Style-Type" content="text/css" />
+       <meta http-equiv="Content-Script-Type" content="text/javascript" />
+       <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
+       <title>{$page_head} - {$site_name}{$site_name_caption}</title>
+       <link rel="stylesheet" href="{$style_sheet}" />
+       <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+       <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
+</head>
+<body>
+<div id="page">
+EOL;
+?>
+<?php
+$echo = $echo . echoCommonHeader('#com_footer', $self_anchor_with_imagemode) . "<hr />\n";
+$echo = $echo . '<div id="header" class="';
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+  $echo = $echo . 'user_timeline';
+} else {
+  $echo = $echo . 'default';
+}
+$echo = $echo . '"><h1>';
+$echo = $echo . $page_head;
+$echo = $echo . "</h1></div>\n<hr />\n";
+?>
+
+<?php
+// var_dump($acs_body);
+// var_dump($_SESSION);
+//var_dump($_SERVER['SERVER_NAME']);
+//echo dirname($_SERVER['SCRIPT_NAME']);
+//var_dump($_SESSION['password']);
+//var_dump($session_cookie_expire);
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+/*     $_SESSION['hatenaid'] = $user_info['url_name'];
+       $_SESSION['hatenaname'] = $user_info['display_name'];*/
+       $phrase_1 = 'ログインしました。あなたは';
+       $word_one = pullLot($lot_one);
+       $phrase_2 = '(';
+       $tag_1 = '<a href="./entries.php?user=';
+       $tag_2 = '" class="hatena-id">';
+       $phrase_3 = 'id:';
+       $tag_3 = '</a>';
+       $phrase_4 = ')です。';
+       $word_two = pullLot($lot_two);
+       $tag_4 = '<a href="./entries.php?word='.$product_name_abbr.'&amp;body=';
+       $tag_5 = '" class="navigation-link">';
+       $phrase_5 = 'ハイクしよう。';
+       $tag_6 = '</a>';
+       $echo = $echo . '<p>' . $phrase_1 . $word_one . htmlspecialchars($_SESSION['hatenaname'],ENT_QUOTES) . $phrase_2 . $tag_1 . $_SESSION['hatenaid'] . $tag_2 . $phrase_3 . htmlspecialchars($_SESSION['hatenaid'],ENT_QUOTES) . $tag_3 .  $phrase_4 . $word_two . $tag_4 . rawurlencode('ログインしました。私は'.$word_one.$_SESSION['hatenaname'].$phrase_2.$phrase_3.$_SESSION['hatenaid'].$phrase_4.$word_two.$phrase_5." \n{$product_name_abbr} Ver.{$product_version} at http://".$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).'/'."\n");
+       if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '&amp;image=on';
+       $echo = $echo . $tag_5 . $phrase_5 . $tag_6 . '</p>';
+       $echo = $echo . '<p>もし間違っている場合は、一旦<a href="./login.php?log=out" class="navigation-link">ログアウト</a>してください。</p>';
+} elseif (isset($_SESSION['auth']) && $_SESSION['auth'] == 'wait'){
+  $echo = $echo . "<p>ログインできませんか? <a href=\"./login.php?log=out\">もう一度試してみてください。</a></p>\n";
+  if (isset($_SESSION['reqtoken']) && $_SESSION['reqtoken'] != ''){
+       $authorize = 'http://www.hatena.ne.jp/mobile/oauth/authorize';
+       $redirect = $authorize.'?oauth_token='.rawurlencode($_SESSION['reqtoken']);
+//     $echo = $echo . "<p><a href=\"{$redirect}\">リダイレクトなんて(´・ω・`)知らんがな。</a></p>";
+  }
+}
+
+// if (isset($error) && $error != ''){
+//   $echo = $echo . $error;
+//   $echo = $echo . "<pre>";
+//   $echo = $echo . var_dump($acstoken['trace']);
+//   $echo = $echo . "</pre>";
+// }
+if (isset($_GET['log']) && $_GET['log'] == 'out'){
+       $echo = $echo . '<p>ログアウトしました。</p>';
+}
+?>
+<?php
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+       if (isset($return) && $return != ''){
+               $return = rawurlencode($return);
+       }
+// var_dump($error);
+       if (isset($error) && $error != ''){
+         $echo = $echo . $error;
+         $echo = $echo . "<pre>";
+         $echo = $echo . var_dump($acstoken['trace']);
+         $echo = $echo . "</pre>";
+       } else {
+         $login_url = "{$self_anchor}?with=haiku";
+         if (isset($return) && $return != '') $login_url = $login_url.'&return='.$return;
+         $echo = $echo . "<p>→<a href=\"{$login_url}\" class=\"navigation-link\">はてな OAuth 認証でログインする</a></p>";
+         $echo = $echo . $login_notice;
+       }
+}
+// var_dump($_SESSION['auth']);
+$echo = $echo . "<hr />\n<div>\n";
+?>
+
+<?php
+if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
+       if (isset($return) && $return != ''){
+         $echo = $echo . '<ul class="navigation-menu">';
+               if (preg_match("/.+\?.+/u", $return)){
+//                     echo $return;
+                       $echo = $echo . '<li><a href="' . $return . '&amp;log=on';
+//                     if ($_GET['image'] == 'on') echo '&amp;image=on';
+                       $echo = $echo . '" class="navigation-link">元のページ</a>に戻る</li>';
+               } else {
+                       $echo = $echo . '<li><a href="' . $return . '?log=on';
+//                     if ($_GET['image'] == 'on') echo '&amp;image=on';
+                       $echo = $echo . '" class="navigation-link">元のページ</a>に戻る</li>';
+               }
+         $echo = $echo . '</ul>';
+         $return = '';
+       }
+}
+?>
+<?php
+$navi_paging = FALSE;
+$navi_imaging = FALSE;
+require 'footer_include.php';
+$echo = $echo . '</div></body></html>';
+echo mb_convert_encoding($echo, $charcode, 'UTF-8');
+if (isset($_SESSION['oauth_stat'])){
+  unset($_SESSION['oauth_stat']);
+}
+?>
+<?php
+if ($page_phase == 'before'){
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] === FALSE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+}
+?>
\ No newline at end of file
diff --git a/login_processor.php b/login_processor.php
new file mode 100644 (file)
index 0000000..31502fe
--- /dev/null
@@ -0,0 +1,78 @@
+<?php defined("HELLO") or exit(); ?>
+<?php
+if (isset($_GET['with'])){
+  if (isset($_GET['callback'])){
+       $callback = $_GET['callback'];
+  } else {
+       $callback = 'http://'.$_SERVER["SERVER_NAME"].dirname($_SERVER['SCRIPT_NAME']).'/login.php?log=try';
+       if (isset($_GET['return'])) $callback = $callback.'&return='.rawurlencode($_GET['return']);
+  }
+  $error = '';
+  if ($_GET['with'] == 'twitter'){
+  } elseif ($_GET['with'] == 'haiku') {
+       $authorize = 'http://www.hatena.ne.jp/mobile/oauth/authorize';
+       // $myjson = 'http://n.hatena.com/applications/my.json';
+       $reqtoken = getRequest('https://www.hatena.com/oauth/initiate', $callback, 'read_public,write_public,write_private', $conkey, $conkey_sec);
+  //   var_dump($reqtoken);
+       if (isset($reqtoken['stat']) && $reqtoken['stat'] !== TRUE){
+         $error = "<p>ログインの初期処理に失敗しました。</p>\n<blockquote>{$reqtoken['error']}</blockquote>";
+         $_SESSION['oauth_stat'] = $reqtoken['stat'];
+       } else {
+         $_SESSION['reqtoken'] = $reqtoken['token'];
+         $_SESSION['req_sec'] = $reqtoken['secret'];
+         $redirect = $authorize.'?oauth_token='.rawurlencode($reqtoken['token']);
+         $_SESSION['auth'] = "wait";
+//       header('HTTP/1.1 303 See Other');
+               header('HTTP/1.1 307 Temporary Redirect');
+               header('Location: ' . $redirect);
+               exit();
+       }
+  }
+}
+if (isset($_GET['log']) && $_GET['log'] == 'try'){
+       $token = 'https://www.hatena.com/oauth/token';
+       $verifier = $_GET['oauth_verifier'];
+       $acstoken = getAccess($token, $_SESSION['reqtoken'], $_SESSION['req_sec'], $verifier, $conkey, $conkey_sec);
+       if (isset($acstoken['error'])){
+         $error = "<p>アクセストークンの取得に失敗しました。</p>\n<blockquote>{$acstoken['error']}<br />{$acstoken['body']}</blockquote>";
+         $_SESSION['auth'] = FALSE;
+         $_SESSION['oauth_stat'] = $acstoken['stat'];
+//       var_dump($acstoken);
+       } else {
+         $_SESSION['acstoken'] = $acstoken['token'];
+         $_SESSION['acs_sec'] = $acstoken['secret'];
+         parse_str($acstoken['body'], $acs_body);
+         $_SESSION['hatenaid'] = $acs_body['url_name'];
+         $_SESSION['hatenaname'] = rawurldecode($acs_body['display_name']);
+         $_SESSION['auth'] = TRUE;
+         $_SESSION['oauth_stat'] = $acstoken['stat'];
+//       var_dump($acstoken);
+//       exit();
+//       $_SESSION['reauth'] = $acstoken['stat'];
+         if (isset($_GET['image'])) $_SESSION['image'] = $_GET['image'];
+         parse_str($_SERVER['QUERY_STRING'], $parsedq);
+         foreach ($parsedq as $key => $val){
+               if ($key == 'log' && $val == 'try') unset($parsedq['log']);
+               if (preg_match('/^oauth_.+/', $key)) unset($parsedq[$key]);
+         }
+         $redirect = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER['SCRIPT_NAME'];
+         if ($parsedq != ''){
+               $redirect = $redirect.'?';
+               $num = 1;
+               foreach ($parsedq as $key => $val){
+                 if ($num == 1) {
+                       $redirect = $redirect.$key.'='.rawurlencode($val);
+                       $num = 2;
+                 } else {
+                       $redirect = $redirect.'&'.$key.'='.rawurlencode($val);
+                 }
+               }
+         }
+//       $redirect = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER['SCRIPT_NAME'];
+//       header('HTTP/1.1 303 See Other');
+               header('HTTP/1.1 307 Temporary Redirect');
+               header('Location: ' . $redirect);
+               exit();
+       }
+}
+?>
\ No newline at end of file
diff --git a/post.php b/post.php
new file mode 100644 (file)
index 0000000..d5162f1
--- /dev/null
+++ b/post.php
@@ -0,0 +1,37 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php
+define("HELLO","world");
+require_once "product_definitions.php";
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+?>
+<?php
+require_once 'init_processor.php';
+// var_dump($_SESSION);
+?>
+<?php
+$selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
+$safequery = htmlspecialchars($_SERVER["QUERY_STRING"], ENT_QUOTES);
+?>
+<?php
+if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
+// if ($_SESSION['image'] != 'on'){
+  $_SESSION = array();
+  if (isset($_COOKIE[session_name()])){
+       setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
+  }
+  session_destroy();
+// }
+}
+?>
+<?php
+//投稿処理の呼び出し。
+//var_dump($_POST);
+if (isset($_POST['posting'])){
+  require 'post_processor.php';
+}
+?>
diff --git a/post_processor.php b/post_processor.php
new file mode 100644 (file)
index 0000000..73d368d
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2012 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/ormodify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php defined("HELLO") or exit(); ?>
+<?php
+$post_return = $_POST['return'];
+$post_posting = $_POST['posting'];
+if ($post_posting == 'favo'){
+  $post_entry = $_POST['entry'];
+  $api = "{$api_base_url}favorites/create/{$post_entry}.xml?body_formats=html_touch,api";
+  unset($_POST['entry']);
+} elseif ($post_posting == 'hateb'){
+  $post_url = $_POST['url'];
+  $post_comment = $_POST['comment'];
+  $api = "http://b.hatena.ne.jp/atom/post";
+  unset($_POST['url'], $_POST['comment']);
+} else {
+  if ($_POST['status'] == ''){
+       if (isset($_POST['keyword']) && $_POST['keyword'] != ''){
+         $keyword = mb_convert_encoding($_POST['keyword'], 'UTF-8', $charcode);
+         $redirect = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).'/entries.php?keyword='.rawurlencode($keyword);
+       } else {
+                 $redirect = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).'/entries.php';
+       }
+
+       header('HTTP/1.1 303 See Other');
+//     header('HTTP/1.1 302 found');
+       header('Location: '.$redirect);
+       exit();
+  }
+  if (isset($_POST['source'])) $_SESSION['source'] = $_POST['source'];
+  if ($_POST['source'] == '') $_POST['source'] = $product_name_abbr;
+  if (isset($_POST['status'])) $_POST['status'] = mb_convert_encoding($_POST['status'], 'UTF-8', $charcode);
+  if (isset($_POST['keyword'])) $_POST['keyword'] = mb_convert_encoding($_POST['keyword'], 'UTF-8', $charcode);
+  if (!isset($_POST['keyword']) || $_POST['keyword'] == '') $_POST['keyword'] = 'id:' . $_SESSION['hatenaid'];
+       $api = "{$api_base_url}statuses/update.xml?body_formats=html_touch,api";
+}
+unset($_POST['return'], $_POST['posting']);
+$postd = $_POST;
+/*var_dump($_SESSION);
+var_dump($_POST);
+exit();*/
+if ($post_posting == 'favo' || $post_posting == 'status'){
+$_SESSION['post_to'] = 'haiku';
+  $json = postGeneric($api, $postd, $conkey, $conkey_sec, $_SESSION['acstoken'], $_SESSION['acs_sec']);
+  if ($json['stat'] === TRUE){
+       $json_body = $json['body'];
+       $contents = checkEntryData($json_body);
+       if ($contents['stat'] == FALSE){
+         $post_return = preg_replace("/^([^#]+)(#.*)/u", "\${1}", $post_return);                       
+       }
+         $_SESSION['post_result'] = TRUE;
+         if ($post_posting == 'status'){
+               $_SESSION['post_result_mes'] = '投稿しました。';
+         } elseif ($post_posting == 'favo'){
+               $_SESSION['post_result_mes'] = '.。.:*・゜゚・*☆';
+         } else {
+               $_SESSION['post_result_mes'] = '投稿しました。';
+         }
+         $_SESSION['post_body'] = $json_body;
+         
+  } else {
+         $_SESSION['post_result'] = FALSE;
+         $_SESSION['post_result_mes'] = 'なんかのエラーですすす。';
+         $_SESSION['post_error'] = $json['error'];
+         $post_return = preg_replace("/^([^#]+)(#.*)/u", "\${1}", $post_return);
+//       $_SESSION['post_session'] = $json['session'];
+  }
+} elseif ($post_posting == 'hateb'){
+  $_SESSION['post_to'] = 'hateb';
+  $post_comment = mb_convert_encoding($post_comment, 'UTF-8', $charcode);
+  $body = <<<EOL
+<entry xmlns="http://purl.org/atom/ns#">
+  <title>dummy</title>
+  <link rel="related" type="text/html" href="{$post_url}" />
+  <summary type="text/plain">{$post_comment}</summary>
+</entry>
+EOL;
+  $xml = postGeneric($api, $postd, $conkey, $conkey_sec, $_SESSION['acstoken'], $_SESSION['acs_sec'], $body);
+  if ($xml['http'] != '201'){
+       $_SESSION['post_result'] = FALSE;
+       $_SESSION['post_result_mes'] = 'なんかのエラーです。';
+       $_SESSION['post_error'] = $xml['body'];
+  } else {
+       $_SESSION['post_result'] = TRUE;
+       $_SESSION['post_result_mes'] = 'ブックマークを投稿しました。';
+       $_SESSION['post_body'] = $xml['body'];
+  }
+}
+// if ($device_who == 'android' && preg_match("/(1\.6)|(1\.5)/", $_SERVER['HTTP_USER_AGENT'])){
+//   $post_return = htmlspecialchars($post_return, ENT_QUOTES);
+//   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
+//   echo "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
+//   echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ja\" lang=\"ja\">\n";
+//   echo "<head>\n";
+//   echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
+//   echo "<meta http-equiv=\"Refresh\" content=\"1;URL={$post_return}\" />";
+//   echo "<title>Redirect for POST after...</title>";
+//   echo "</head>\n";
+//   echo "<body><p><a href=\"{$post_return}\">Redirecting...</a></p></body></html>";
+//   exit();
+// } else {
+  header('HTTP/1.1 303 See Other');
+  // header('HTTP/1.1 302 found');
+  header('Location: ' . $post_return);
+  exit();
+// }
+?>
diff --git a/product_definitions.php b/product_definitions.php
new file mode 100644 (file)
index 0000000..114aa54
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+//YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
+//(c) 2014 YANMAH2 project
+//This program is freesoftware. you can redistribute it and/ormodify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
+?>
+<?php defined("HELLO") or exit(); ?>
+<?php
+$product_name_abbr = "YANMAH2 -season 2-";
+$product_name_full = "Yet ANother Mobile Accelerated HatenaHaiku";
+$product_version = "1.9901-beta";
+$project_name = "YANMAH2 project";
+$project_url = "http://yanmah2.sourceforge.jp/";
+$user_agent = $product_name_abbr . '/' . $product_version . ' ' . $_SERVER['SERVER_NAME'];
+?>
diff --git a/style.php b/style.php
new file mode 100644 (file)
index 0000000..5823d00
--- /dev/null
+++ b/style.php
@@ -0,0 +1,294 @@
+<?php
+define("HELLO","world");
+require_once "configurable_variables.php";
+require_once "common_functions.php";
+require_once 'init_processor.php';
+?>
+<?php
+header('Content-Type: text/css; charset=utf-8');
+header('Cache-Control: private, max-age=' . 60*60*24);
+?>
+body {
+       color: black; background-color: white;
+       margin-top: 0%; margin-bottom: 0%;
+       margin-left: 1%; margin-right: 1%;
+       padding-left: 1%; padding-right: 1%;
+       border-width: 1px;
+       border-style: solid;
+       border-color: #888888;
+}
+blockquote {
+       color: inherit; background-color: #f6f6f6;
+       border-color: #999999; border-style: dotted;
+       border-width: 1px;
+}
+hr {
+       display: none;
+}
+address {
+       font-size: 75%;
+}
+#page {
+}
+#header {
+       padding: 1%;
+}
+#header.default, #header.album, #header.users, #header.about {
+       color: white; background-color: #6C8CA5;
+}
+#header.user_timeline, #header.friends_timeline, #header.entry_cat, #header.favours {
+       color: white; background-color: #D07C7A;
+}
+#header.keyword_timeline, #header.keywords, #header.keyword_users {
+       color: white; background-color: #7BA86D;
+}
+#header.coco-ready, #header.coco-result {
+  color: white; background-color: #77B4F1;
+}
+#header {
+}
+#com-hdr {
+  border-bottom-style: solid; border-bottom-width: 1px;
+  border-color: #999999;
+  color: black; background-color: white;
+  font-size: 90%; text-align: right;
+}
+#com-ftr {
+  border-top-style: solid; border-top-width: 1px;
+  border-color: #999999;
+  color: black; background-color: white;
+  font-size: 90%; text-align: right;
+}
+.header-log, .ftr-cnf {
+  margin-right: 3%;
+}
+.to-bottom, to-top {
+  margin-left: 3%;
+}
+#index-head {
+}
+.head1 {
+}
+.caption {
+  display: inline;
+  font-size: 80%;
+}
+#index-contents {
+       border: none;
+}
+.post-result, .oauth-res {
+  color: black; background-color: #d6e6ff;
+  margin: 1%; padding: 1%;
+}
+.contents {
+       border-color: #999999; border-top-style: solid;
+       border-top-width: 1px;
+}
+.index-content ul, .cnf-blk, .cnf-blk ul, .kwd-ls {
+<?php
+if ($device_who == 'ktai'){
+  echo "line-height: 1.0em;\n";
+} elseif ($device_who == 'iphone' || $device_who == 'android' || $device_who == 'android-old'){
+  echo "line-height: 1.7em;\n";
+} else {
+  echo "line-height: 1.2em;\n";
+}
+?>
+}
+.index-content {
+}
+.content {
+}
+#entries-index-head {
+       color: white; background-color: #6C8CA5;
+}
+a:link.entries {
+       color: #43647C; background-color: transparent;
+}
+a:visited.entries {
+       color: #43647C; background-color: transparent;
+}
+#users-index-head {
+       color: white; background-color: #D07C7A;
+}
+a:link.user,a:visited.user {
+       color: #833B55; background-color: transparent;
+}
+#keywords-index-head {
+       color: white; background-color: #7BA86D;
+}
+a:link.keyword {
+       color: #467237; background-color: transparent;
+}
+a:visited.keyword {
+       color: #467237; background-color: transparent;
+}
+#footer {
+       border-color: #999999; border-top-style: solid;
+       border-top-width: 1px;
+}
+
+#entries-head {
+}
+.external-link {
+}
+.generic-link {
+}
+.image-link {
+}
+
+.post-box {
+}
+#post-keyword {
+       font-size: 100%;
+       width: 99%; height: auto;
+}
+#post-text {
+       font-size: 100%;
+       width: 99%; height: 4em;
+}
+#post-haiku, #post-from {
+       vertical-align: middle;
+}
+#post-haiku {
+  margin-right: 4%;
+}
+#post-from {
+  width: 6em; margin-right: 2%;
+}
+.entry, .users-list, .geo-result, .coco-search, .hateb-form, .to-amazon, .cnf-blk {
+       border-color: #999999; border-bottom-style: solid;
+       border-bottom-width: 1px;
+       margin: 0; 
+       padding-top: 1%;padding-bottom: 1%;
+       line-height: 1.3em;
+}
+.entry img {
+  max-width: 100%; max-height: 16em;
+}
+.entry-head {
+       font-weight: bold;
+}
+.user-icon {
+  height: 2em; width: 2em;
+  vertical-align: top;
+  float: left;
+  margin-right: 1px;
+}
+.hatena-star-comment-button, .hatena-star-add-button {
+<?php
+if ($device_who == 'iphone' || $device_who == 'android' || $device_who == 'android-old'){
+echo <<<EOL
+
+  height: 1.5em;
+  margin: 0px 0.3em!important;
+
+EOL;
+} else {
+  echo "height: 1.2em;\n";
+}
+?>
+}
+.entry-body {
+<?php
+if ($device_who == 'ktai'){
+  echo "line-height: 1.1em;\n";
+} elseif ($device_who == 'iphone' || $device_who == 'android' || $device_who == 'android-old'){
+  echo "line-height: 1.3em;\n";
+} else {
+  echo "line-height: 1.3em;\n";
+}
+?>
+  margin-top: 2px; margin-bottom: 2px;
+  margin-left: 2em;
+}
+.entry-body img {
+  vertical-align: middle;
+}
+.star-form {
+       display: inline;
+}
+a:link.hatena-id {
+       color: #833B55; background-color: transparent;
+}
+a:visited.hatena-id {
+       color: #833B55; background-color: transparent;
+}
+.add-star-button {
+  color: #327896; background-color: white;
+  border-style: solid; border-color: #327896; border-width: 1px;
+}
+.hateb-form {
+  margin: 1%;
+}
+#bcomment {
+  width: 75%; height: auto;
+}
+#post-hateb {
+  color: #1742CE; background-color: white;
+  width: 10%; height: auto; font-weight: bold;
+  border-style: solid; border-color:#1742CE ; border-width: 1px;
+}
+.hatena-star a:link, .hatena-star a:visited{
+       color: #b88606; background-color: transparent;
+}
+.dating, .sname, .entry-head {
+       color: #555555; background-color: transparent;
+}
+.reply {
+       color: #555555; background-color: transparent;
+}
+a:link.replying,a:visited.replying {
+       color: #833B55; background-color: transparent;
+}
+a:link.see-more {
+       color: #833B55; background-color: transparent;
+}
+a:visited.see-more {
+       color: #833B55; background-color: transparent;
+}
+.to-original-link {
+}
+#navigation-menu, #page-navi {
+  text-align: center;
+       list-style-type: none;
+       margin-left: 0; margin-right: 0;
+       padding: 0; padding-right: 0;
+       padding-top: 0.2em; padding-bottom: 0.2em;
+       font-size: 100%;
+}
+#navigation-menu li, #page-navi li {
+<?php
+if ($device_who == 'ktai'){
+  echo "line-height: 1.0em;\n";
+} elseif ($device_who == 'iphone' || $device_who == 'android' || $device_who == 'android-old'){
+  echo "line-height: 2.0em;\n";
+} else {
+  echo "line-height: 1.5em;\n";
+}
+?>
+}
+#page-navi li{
+  display: inline;
+}
+a:link.navigation-link {
+       color: #43647C; background-color: transparent;
+}
+a:visited.navigation-link {
+       color: #43647C; background-color: transparent;
+}
+.access-key {
+       text-decoration: underline;
+}
+#about-head {
+}
+.users-list dd, .users-list dt {
+}
+.users-list dt {
+  font-weight: bold;
+}
+.users-list dd {
+}
+.credit {
+  font-size: 75%;
+}
\ No newline at end of file