2 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3 //(c) 2014 YANMAH2 project
4 //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).
7 define("HELLO","world");
8 require_once "product_definitions.php";
9 require_once "configurable_variables.php";
10 require_once "common_functions.php";
13 require_once "init_processor.php";
14 // session_regenerate_id(TRUE);
19 <?php //セキュリティのための前処理。
21 if (isset($_POST["hatenaid"]) && $_POST["hatenaid"] != '') checkId($_POST["hatenaid"]);
24 if (isset($_GET['return']) && $_GET['return'] != ''){
25 $return = $_GET['return'];
29 if (isset($_GET['log']) && $_GET['log'] == 'out'){
31 setcookie(session_name(),'',time()-999, dirname($_SERVER['SCRIPT_NAME']) . '/');
34 $page_phase = 'after';
36 $page_phase = 'before';
40 //var_dump($_POST['login']);
41 require 'login_processor.php';
42 $selfcall = htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES);
43 $safequery = htmlspecialchars($_SERVER["QUERY_STRING"], ENT_QUOTES);
44 $self_anchor = "http://{$_SERVER["SERVER_NAME"]}{$selfcall}";
45 $self_anchor_possibly_with_pagenum = $self_anchor;
46 if ($get_image == 'on'){
47 $self_anchor_with_imagemode = $self_anchor . '?image=on';
49 $self_anchor_with_imagemode = $self_anchor . '?image=off';
51 // var_dump($self_anchor);
55 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
56 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
57 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
59 <meta http-equiv="Content-Type" content="text/html; charset={$meta_charset}" />
60 <meta http-equiv="Content-Style-Type" content="text/css" />
61 <meta http-equiv="Content-Script-Type" content="text/javascript" />
62 <meta name="viewport" content="initial-scale={$iscale}, minimum-scale=0.1" />
63 <title>{$page_head} - {$site_name}{$site_name_caption}</title>
64 <link rel="stylesheet" href="{$style_sheet}" />
65 <link rel="icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
66 <link rel="shortcut icon" href="./favicon.ico" type="image/vnd.microsoft.icon" />
67 <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
74 $echo = $echo . echoCommonHeader('#com_footer', $self_anchor_with_imagemode) . "<hr />\n";
75 $echo = $echo . '<div id="header" class="';
76 if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
77 $echo = $echo . 'user_timeline';
79 $echo = $echo . 'default';
81 $echo = $echo . '"><h1>';
82 $echo = $echo . $page_head;
83 $echo = $echo . "</h1></div>\n<hr />\n";
87 // var_dump($acs_body);
88 // var_dump($_SESSION);
89 //var_dump($_SERVER['SERVER_NAME']);
90 //echo dirname($_SERVER['SCRIPT_NAME']);
91 //var_dump($_SESSION['password']);
92 //var_dump($session_cookie_expire);
93 if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
94 /* $_SESSION['hatenaid'] = $user_info['url_name'];
95 $_SESSION['hatenaname'] = $user_info['display_name'];*/
96 $phrase_1 = 'ログインしました。あなたは';
97 $word_one = pullLot($lot_one);
99 $tag_1 = '<a href="./entries.php?user=';
100 $tag_2 = '" class="hatena-id">';
104 $word_two = pullLot($lot_two);
105 $tag_4 = '<a href="./entries.php?word='.rawurlencode($product_name_abbr).'&body=';
106 $tag_5 = '" class="navigation-link">';
107 $phrase_5 = 'ハイクしよう。';
109 $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");
110 if (isset($_GET['image']) && $_GET['image'] == 'on') $echo = $echo . '&image=on';
111 $echo = $echo . $tag_5 . $phrase_5 . $tag_6 . '</p>';
112 $echo = $echo . '<p>もし間違っている場合は、一旦<a href="./login.php?log=out" class="navigation-link">ログアウト</a>してください。</p>';
113 } elseif (isset($_SESSION['auth']) && $_SESSION['auth'] == 'wait'){
114 $echo = $echo . "<p>ログインできませんか? <a href=\"./login.php?log=out\">もう一度試してみてください。</a></p>\n";
115 // var_dump($_SESSION);
116 if (isset($_SESSION['reqtoken']) && $_SESSION['reqtoken'] != ''){
117 $authorize = 'https://www.hatena.ne.jp/mobile/oauth/authorize';
118 $redirect = $authorize.'?oauth_token='.rawurlencode($_SESSION['reqtoken']);
119 // $echo = $echo . "<p><a href=\"{$redirect}\">リダイレクトなんて(´・ω・`)知らんがな。</a></p>";
123 if (isset($_GET['log']) && $_GET['log'] == 'out'){
124 $echo = $echo . '<p>ログアウトしました。</p>';
128 if (!isset($_SESSION['auth']) || $_SESSION['auth'] != TRUE){
129 if (isset($return) && $return != ''){
130 $return = rawurlencode($return);
133 if (isset($error) && $error != ''){
134 $echo = $echo . $error;
135 $echo = $echo . "<pre>";
136 $echo = $echo . var_dump($acstoken['trace']);
137 $echo = $echo . "</pre>";
139 $login_url = "{$self_anchor}?with=haiku";
140 if (isset($return) && $return != '') $login_url = $login_url.'&return='.$return;
141 $echo = $echo . "<p>→<a href=\"{$login_url}\" class=\"navigation-link\">はてな OAuth 認証でログインする</a></p>";
142 $echo = $echo . $login_notice;
145 // var_dump($_SESSION['auth']);
146 $echo = $echo . "<hr />\n<div>\n";
150 if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
151 if (isset($return) && $return != ''){
152 $echo = $echo . '<ul class="navigation-menu">';
153 if (preg_match("/.+\?.+/u", $return)){
155 $echo = $echo . '<li><a href="' . $return . '&log=on';
156 $echo = $echo . '" class="navigation-link">元のページ</a>に戻る</li>';
158 $echo = $echo . '<li><a href="' . $return . '?log=on';
159 $echo = $echo . '" class="navigation-link">元のページ</a>に戻る</li>';
161 $echo = $echo . '</ul>';
167 $navi_paging = FALSE;
168 $navi_imaging = FALSE;
169 require 'footer_include.php';
170 $echo = $echo . '</div></body></html>';
171 echo mb_convert_encoding($echo, $charcode, 'UTF-8');
172 if (isset($_SESSION['oauth_stat'])){
173 unset($_SESSION['oauth_stat']);
177 if ($page_phase == 'before'){
178 if (!isset($_SESSION['auth']) || $_SESSION['auth'] === FALSE){
180 if (isset($_COOKIE[session_name()])){
181 setcookie(session_name(), '', time() - 42000, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);