OSDN Git Service

一頁に表示できる最大件数を200に拡大。ユーザーTLとキーワードTLで長い投稿を省略しないように変更。
[yanmah2/YANMAH2-season2-.git] / init_processor.php
1 <?php
2 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3 //(c) 2016 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).
5 ?>
6 <?php defined("HELLO") or exit(); ?>
7 <?php
8 ini_set('session.gc_maxlifetime', $session_file_lifetime);
9 if ($session_gc_prob[0] != 'default') ini_set('session.gc_probability', $session_gc_prob[0]);
10 if ($session_gc_prob[1] != 'default') ini_set('session.gc_divisor', $session_gc_prob[1]);
11 ini_set('session.use_trans_sid', 0);
12 session_set_cookie_params($session_cookie_expire, dirname($_SERVER['SCRIPT_NAME']) . '/', $_SERVER["SERVER_NAME"]);
13 if ($custom_session_save_path != 'default'){
14         session_save_path($custom_session_save_path);
15 }
16 session_start();
17 //session_regenerate_id(TRUE);
18 ?>
19 <?php
20 if ($extra_include_path != "default"){
21         $default_include_path = ini_get("include_path");
22         ini_set('include_path', ".:{$extra_include_path}:{$default_include_path}");
23 }
24 $http_url_regexp = 's?https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:@&=+$,%#]+';
25 $http_host_regexp = 's?https?:\/\/[-_.!~*\'()a-zA-Z0-9;?:@&=+$,%#]+\/*';
26 $http_path_regexp = '[-_.!~*\'()a-zA-Z0-9;\/?:@&=+$,%#]*';
27 $http_dir_regexp = '[-_.!~*\'()a-zA-Z0-9;\/@&=+$,%]+';
28 mb_internal_encoding('UTF-8');
29 mb_regex_encoding("UTF-8");
30 libxml_use_internal_errors(TRUE);
31 date_default_timezone_set('Asia/Tokyo');
32 ?>
33 <?php
34 //NULL バイトの入力を弾く
35 checkNull($_GET);
36 checkNull($_POST);
37 checkNull($_COOKIE);
38 ?>
39 <?php
40 if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] != ''){
41   $device_who = whatDevice($_SERVER['HTTP_USER_AGENT']);
42 } else {
43   $device_who = 'generic';
44 }
45 ?>
46 <?php
47 if (isset($_GET['ce']) && preg_match("/^(UTF-8|SJIS|EUC-JP|JIS)$/i",$_GET['ce'])){
48   setcookie('charcode', $_GET['ce'], time() + $session_cookie_expire);
49   $charcode = $_GET['ce'];
50 } elseif (isset($_COOKIE['charcode']) && preg_match("/^(UTF-8|SJIS|EUC-JP|JIS)$/i",$_COOKIE['charcode'])){
51   $charcode = $_COOKIE['charcode'];
52 }
53 switch ($charcode){
54         case 'UTF-8':
55                 $meta_charset = 'utf-8';
56                 break;
57         case 'SJIS';
58                 $meta_charset = 'Shift_JIS';
59                 break;
60         case 'EUC-JP':
61                 $meta_charset = 'euc-jp';
62                 break;
63         case 'JIS':
64                 $meta_charset = 'iso-2022-jp';
65                 break;
66         default:
67                 $meta_charset = 'utf-8';
68                 break;
69 }
70 ?>
71 <?php
72 foreach ($ng_query as $ngw){
73     if (preg_match('/'.preg_quote($ngw, '/').'/u', $_SERVER['QUERY_STRING'])){
74         header("HTTP/1.0 404 Not Found");
75         exit();
76     }
77 }
78 ?>
79 <?php
80 // if (isset($_GET['image']) && isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
81 //      $_SESSION['image'] = $_GET['image'];
82 // }
83 if (isset($_GET['image']) && preg_match("/^(on|off)$/", $_GET['image'])){
84   setcookie('y2dconfig', $_GET['image'], time()+60*60*24*365);
85 }
86 if (isset($_GET['image']) && $_GET['image'] == 'on'){
87   $get_image = 'on';
88 } elseif (isset($_GET['image']) && $_GET['image'] == 'off'){
89   $get_image = 'off';
90 } elseif (isset($_COOKIE['y2dconfig']) && $_COOKIE['y2dconfig'] == 'on'){
91   $get_image = 'on';
92 } elseif (isset($_COOKIE['y2dconfig']) && $_COOKIE['y2dconfig'] == 'off'){
93   $get_image = 'off';
94 } else {
95   $get_image = 'off';
96 }
97
98 if (isset($_COOKIE['y2config'])){
99   parse_str($_COOKIE['y2config'], $y2config);
100 }
101 if (isset($y2config['count']) && $y2config['count'] != '' && preg_match("/^[0123456789]{1,3}$/", $y2config['count'])){
102   $ecount = $y2config['count'];
103 }
104 if (isset($y2config['showicon']) && $y2config['showicon'] != '' && preg_match("/^(yes|no)$/", $y2config['showicon'])){
105   $show_icon = $y2config['showicon'];
106 }
107 if (isset($y2config['disbr']) && $y2config['disbr'] != '' && preg_match("/^(yes|no)$/", $y2config['disbr'])){
108   $disbr = $y2config['disbr'];
109 }
110 if (isset($y2config['starisjs']) && $y2config['starisjs'] != '' && preg_match("/^(0|1)$/", $y2config['starisjs'])){
111   $starisjs = $y2config['starisjs'];
112 }
113 if (isset($y2config['elimit']) && $y2config['elimit'] != '' && preg_match("/^[0123456789]{1,3}$/", $y2config['elimit'])){
114   $entry_limit = $y2config['elimit'];
115 }
116 // if (isset($y2config['hdomain']) && $y2config['hdomain'] != '' && preg_match("/^(h|h1beta)(\.hatena\.ne\.jp|\.hatena\.com)$/", $y2config['hdomain'])){
117 //   $haiku_host = $y2config['hdomain'];
118 //   $haiku_official_url = preg_replace("/(http:\/\/)[^\/]+(\/.*)/u", "\${1}{$haiku_host}\${2}", $haiku_official_url);
119 //   $api_base_url = "http://{$haiku_host}/api/";
120 // }
121 if (isset($y2config['iscale']) && $y2config['iscale'] != '' && preg_match("/^[[:digit:]]{1}\.{0,1}[[:digit:]]{0,1}$/", $y2config['iscale'])){
122   $iscale = $y2config['iscale'];
123 } else {
124   $iscale = '1';
125 }
126 // var_dump($y2config);
127 ?>