2 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3 //(c) 2014 YANMAH2 project
4 //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).
6 <?php defined("HELLO") or exit(); ?>
8 $post_return = $_POST['return'];
9 $post_posting = $_POST['posting'];
10 if ($post_posting == 'favo'){
11 $post_entry = $_POST['entry'];
12 $api = "{$api_base_url}favorites/create/{$post_entry}.xml?body_formats=html_touch,api";
13 unset($_POST['entry']);
14 // } elseif ($post_posting == 'hateb'){
15 // $post_url = $_POST['url'];
16 // $post_comment = $_POST['comment'];
17 // $api = "http://b.hatena.ne.jp/atom/post";
18 // unset($_POST['url'], $_POST['comment']);
20 if ($_POST['status'] == ''){
21 if (isset($_POST['keyword']) && $_POST['keyword'] != ''){
22 $keyword = mb_convert_encoding($_POST['keyword'], 'UTF-8', $charcode);
23 $redirect = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).'/entries.php?keyword='.rawurlencode($keyword);
25 $redirect = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).'/entries.php';
28 header('HTTP/1.1 303 See Other');
29 // header('HTTP/1.1 302 found');
30 header('Location: '.$redirect);
33 if (isset($_POST['source'])) $_SESSION['source'] = $_POST['source'];
34 if ($_POST['source'] == '') $_POST['source'] = $product_name_abbr;
35 if (isset($_POST['status'])) $_POST['status'] = mb_convert_encoding($_POST['status'], 'UTF-8', $charcode);
36 if (isset($_POST['keyword'])) $_POST['keyword'] = mb_convert_encoding($_POST['keyword'], 'UTF-8', $charcode);
37 if (!isset($_POST['keyword']) || $_POST['keyword'] == '') $_POST['keyword'] = 'id:' . $_SESSION['hatenaid'];
38 $api = "{$api_base_url}statuses/update.xml?body_formats=html_touch,api";
40 unset($_POST['return'], $_POST['posting']);
42 /*var_dump($_SESSION);
45 if ($post_posting == 'favo' || $post_posting == 'status'){
46 $_SESSION['post_to'] = 'haiku';
47 $json = postGeneric($api, $postd, $conkey, $conkey_sec, $_SESSION['acstoken'], $_SESSION['acs_sec']);
48 if ($json['stat'] === TRUE){
49 $json_body = $json['body'];
50 $contents = checkEntryData($json_body);
51 if ($contents['stat'] == FALSE){
52 $post_return = preg_replace("/^([^#]+)(#.*)/u", "\${1}", $post_return);
54 $_SESSION['post_result'] = TRUE;
55 if ($post_posting == 'status'){
56 $_SESSION['post_result_mes'] = '投稿しました。';
57 } elseif ($post_posting == 'favo'){
58 $_SESSION['post_result_mes'] = '.。.:*・゜゚・*☆';
60 $_SESSION['post_result_mes'] = '投稿しました。';
62 $_SESSION['post_body'] = $json_body;
65 $_SESSION['post_result'] = FALSE;
66 $_SESSION['post_result_mes'] = 'なんかのエラーですすす。';
67 $_SESSION['post_error'] = $json['error'];
68 $post_return = preg_replace("/^([^#]+)(#.*)/u", "\${1}", $post_return);
69 // $_SESSION['post_session'] = $json['session'];
71 }/* elseif ($post_posting == 'hateb'){
72 $_SESSION['post_to'] = 'hateb';
73 $post_comment = mb_convert_encoding($post_comment, 'UTF-8', $charcode);
75 <entry xmlns="http://purl.org/atom/ns#">
77 <link rel="related" type="text/html" href="{$post_url}" />
78 <summary type="text/plain">{$post_comment}</summary>
81 $xml = postGeneric($api, $postd, $conkey, $conkey_sec, $_SESSION['acstoken'], $_SESSION['acs_sec'], $body);
82 if ($xml['http'] != '201'){
83 $_SESSION['post_result'] = FALSE;
84 $_SESSION['post_result_mes'] = 'なんかのエラーです。';
85 $_SESSION['post_error'] = $xml['body'];
87 $_SESSION['post_result'] = TRUE;
88 $_SESSION['post_result_mes'] = 'ブックマークを投稿しました。';
89 $_SESSION['post_body'] = $xml['body'];
92 // if ($device_who == 'android' && preg_match("/(1\.6)|(1\.5)/", $_SERVER['HTTP_USER_AGENT'])){
93 // $post_return = htmlspecialchars($post_return, ENT_QUOTES);
94 // echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
95 // echo "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
96 // echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ja\" lang=\"ja\">\n";
98 // echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
99 // echo "<meta http-equiv=\"Refresh\" content=\"1;URL={$post_return}\" />";
100 // echo "<title>Redirect for POST after...</title>";
102 // echo "<body><p><a href=\"{$post_return}\">Redirecting...</a></p></body></html>";
105 header('HTTP/1.1 303 See Other');
106 // header('HTTP/1.1 302 found');
107 header('Location: ' . $post_return);