Browse Source

여러 내용 수정...

master
Hakase 1 year ago
parent
commit
da5d8223b2
6 changed files with 203 additions and 36 deletions
  1. 1
    1
      LICENSE
  2. 185
    6
      _function.php
  3. 5
    5
      fmaru.php
  4. 5
    17
      index.php
  5. 3
    3
      manga.php
  6. 4
    4
      mangalist.php

+ 1
- 1
LICENSE View File

@@ -1,6 +1,6 @@
1 1
 MIT License
2 2
 
3
-Copyright (c) 2016-2017 hakasenyang
3
+Copyright (c) 2016-2018 hakasenyang
4 4
 
5 5
 Permission is hereby granted, free of charge, to any person obtaining a copy
6 6
 of this software and associated documentation files (the "Software"), to deal

+ 185
- 6
_function.php View File

@@ -1,7 +1,43 @@
1 1
 <?php
2 2
     class Marumaru {
3
-        private $httph = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36';
4
-        private $fname = 'cookie.txt';
3
+        private $httph = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36';
4
+        private $fname = 'cookie_hidden.txt';
5
+
6
+        public function linkencode ($url) {
7
+            $ta = parse_url($url);
8
+            if (!empty($ta['scheme']))
9
+                $ta['scheme'] .= '://';
10
+            if (!empty($ta['pass']) and !empty($ta['user']))
11
+            {
12
+                $ta['user'] = ':';
13
+                $ta['pass'] = rawurlencode($ta['pass']).'@';
14
+            }
15
+            elseif (!empty($ta['user']))
16
+                $ta['user'] .= '@';
17
+
18
+            if (!empty($ta['port']) and !empty($ta['host']))
19
+                $ta['host'] = ''.$ta['host'].':';
20
+            elseif (!empty($ta['host']))
21
+                $ta['host'] = $ta['host'];
22
+
23
+            if (!empty($ta['path']))
24
+            {
25
+                $tu = '';
26
+                $tok = strtok($ta['path'], "\\/");
27
+                while (strlen($tok))
28
+                {
29
+                    $tu .= rawurlencode($tok).'/';
30
+                    $tok = strtok("\\/");
31
+                }
32
+                $ta['path'] = '/'.trim($tu, '/');
33
+            }
34
+            if (!empty($ta['query']))
35
+                $ta['query'] = '?'.$ta['query'];
36
+            if (!empty($ta['fragment']))
37
+                $ta['fragment'] = '#'.$ta['fragment'];
38
+
39
+            return implode('', array($ta['scheme'], $ta['user'], $ta['pass'], $ta['host'], $ta['port'], $ta['path'], $ta['query'], $ta['fragment']));
40
+        }
5 41
         public function splits($data, $first, $end, $num = 1)
6 42
         {
7 43
             $temp = @explode($first, $data);
@@ -11,11 +47,13 @@
11 47
         }
12 48
         public function WEBParsing($url, $cookie=NULL, $headershow=TRUE, $postparam=NULL, $otherheader=NULL)
13 49
         {
50
+            if (!preg_match('/^(?:https?):\/\//', $url)) return false;
14 51
             $ch = curl_init();
52
+            $url = $this->linkencode($url);
15 53
             $opts = array(CURLOPT_RETURNTRANSFER => true,
16 54
                 CURLOPT_URL => $url,
17
-                CURLOPT_TIMEOUT => 10,
18
-                CURLOPT_CONNECTTIMEOUT => 5,
55
+                CURLOPT_TIMEOUT => 60,
56
+                CURLOPT_CONNECTTIMEOUT => 10,
19 57
                 CURLOPT_SSL_VERIFYPEER => FALSE,
20 58
                 CURLOPT_HEADER => $headershow,
21 59
                 CURLOPT_USERAGENT => $this->httph
@@ -35,6 +73,144 @@
35 73
             curl_close($ch);
36 74
             return ($data) ? $data : false;
37 75
         }
76
+        /**
77
+         * sucuri - sucuri 프록시 관련 쿠키 우회
78
+         * 소스 : https://github.com/organization/cloudflare-bypass
79
+         * 소스 : http://cafe.naver.com/gogoomas/337647
80
+         * @param  string $result 쿠키 string 입력
81
+         * @return strring         쿠키 데이터 출력
82
+         * 사용하지 않음.
83
+         */
84
+        /*public function sucuri($result)
85
+        {
86
+            if(strpos($result, 'sucuri_cloudproxy_js') !== false)
87
+            {
88
+                $cp_temp1 = explode('S=\'', $result);
89
+                $cp_temp2 = explode(';', $cp_temp1[1]);
90
+                $cp_script = $cp_temp2[0];
91
+                $cp_temp1 = explode('A=\'', $result);
92
+                $cp_temp2 = explode('\';', $cp_temp1[1]);
93
+                $cp_chlist = $cp_temp2[0];
94
+                $cp_charr = array();
95
+                for($i = 0; $i < 64; $i++)
96
+                    $cp_charr[$cp_chlist[$i]] = $i;
97
+                $cp_len = strlen($cp_script);
98
+                $cp_c = 0;
99
+                $cp_u = 0;
100
+                $cp_i = 0;
101
+                $cp_l = 0;
102
+                $cp_a = NULL;
103
+                $cp_r = NULL;
104
+                for($i = 0; $i < $cp_len; $i++)
105
+                {
106
+                    $cp_c = $cp_charr[$cp_script[$i]];
107
+                    $cp_u = ($cp_u << 6) + $cp_c;
108
+                    $cp_l += 6;
109
+                    while($cp_l >= 8)
110
+                        (($cp_a = ($cp_u >> ($cp_l -= 8)) & 0xff) || ($cp_i < ($cp_len - 2))) && ($cp_r .= chr($cp_a));
111
+                }
112
+                $cp_temp1 = explode('document.cookie=', $cp_r);
113
+                $cp_temp2 = explode('=', $cp_temp1[1]);
114
+                $cp_cnam = str_replace('"', '\'', $cp_temp2[0]);
115
+                $cp_cnam_split = explode('+', $cp_cnam);
116
+                $cp_cnam_split_cnt = count($cp_cnam_split);
117
+                $cp_cnam_string = NULL;
118
+                for($i = 0 ; $i < $cp_cnam_split_cnt; $i++)
119
+                {
120
+                    $cp_cnam = trim($cp_cnam_split[$i]);
121
+                    if(strpos($cp_cnam, 'slice') !== false)
122
+                    {
123
+                        $cp_temp1 = explode('\'', $cp_cnam);
124
+                        $cp_temp2 = explode('(', $cp_cnam);
125
+                        $cp_temp3 = explode(')', $cp_temp2[1]);
126
+                        $cp_temp4 = explode(',', $cp_temp3[0]);
127
+                        $cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp4[0]), (intval(trim($cp_temp4[1])-trim($cp_temp4[0]))));
128
+                    }
129
+                    elseif(strpos($cp_cnam, 'charAt') !== false)
130
+                    {
131
+                        $cp_temp1 = explode('\'', $cp_cnam);
132
+                        $cp_temp2 = explode('(', $cp_cnam);
133
+                        $cp_temp3 = explode(')', $cp_temp2[1]);
134
+                        $cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp3[0]), 1);
135
+                    }
136
+                    elseif(strpos($cp_cnam, 'String.fromCharCode') !== false)
137
+                    {
138
+                        $cp_temp1 = explode('(', $cp_cnam);
139
+                        $cp_temp2 = explode(')', $cp_temp1[1]);
140
+                        if(strpos($cp_temp2[0], '0x') !== false)
141
+                            $cp_cnam_string .= chr(hexdec($cp_temp2[0]));
142
+                        else
143
+                            $cp_cnam_string .= chr($cp_temp2[0]);
144
+                    }
145
+                    elseif(strpos($cp_cnam, 'substr') !== false)
146
+                    {
147
+                        $cp_temp1 = explode('\'', $cp_cnam);
148
+                        $cp_temp2 = explode('(', $cp_cnam);
149
+                        $cp_temp3 = explode(')', $cp_temp2[1]);
150
+                        $cp_temp4 = explode(',', $cp_temp3[0]);
151
+                        $cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp4[0]), trim($cp_temp4[1]));
152
+                    }
153
+                    else
154
+                        $cp_cnam_string .= trim(trim($cp_cnam, '\''));
155
+                    $cp_cnam_string .= NULL;
156
+                }
157
+                //$cp_temp1 = explode('=', $cp_r);
158
+                $cp_temp1 = strpos($cp_r, '=');
159
+                $cp_temp2 = explode(';document.cookie', substr($cp_r, $cp_temp1+1)); //$cp_temp[1]
160
+                $cp_cval = str_replace('"', '\'', $cp_temp2[0]);
161
+                $cp_cval_split = explode('+', $cp_cval);
162
+                $cp_cval_split_cnt = count($cp_cval_split);
163
+                $cp_cval_string = null;
164
+                for($i = 0 ; $i < $cp_cval_split_cnt; $i++)
165
+                {
166
+                    $cp_nval = trim($cp_cval_split[$i]);
167
+                    if(strpos($cp_nval, 'slice') !== false)
168
+                    {
169
+                        $cp_temp1 = explode('\'', $cp_nval);
170
+                        $cp_temp2 = explode('(', $cp_nval);
171
+                        $cp_temp3 = explode(')', $cp_temp2[1]);
172
+                        $cp_temp4 = explode(',', $cp_temp3[0]);
173
+                        $cp_cval_string .= substr($cp_temp1[1], trim($cp_temp4[0]), (intval(trim($cp_temp4[1])-trim($cp_temp4[0]))));
174
+                    }
175
+                    elseif(strpos($cp_nval, 'charAt') !== false)
176
+                    {
177
+                        $cp_temp1 = explode("'", $cp_nval);
178
+                        $cp_temp2 = explode("(", $cp_nval);
179
+                        $cp_temp3 = explode(")", $cp_temp2[1]);
180
+                        $cp_cval_string .= substr($cp_temp1[1], trim($cp_temp3[0]), 1);
181
+                    }
182
+                    elseif(strpos($cp_nval, 'String.fromCharCode') !== false)
183
+                    {
184
+                        $cp_temp1 = explode('(', $cp_nval);
185
+                        $cp_temp2 = explode(')', $cp_temp1[1]);
186
+                        if(strpos($cp_temp2[0], '0x') !== false)
187
+                        {
188
+                            $cp_cval_string .= chr(hexdec($cp_temp2[0]));
189
+                        }
190
+                        else
191
+                        {
192
+                            $cp_cval_string .= chr($cp_temp2[0]);
193
+                        }
194
+                    }
195
+                    elseif(strpos($cp_nval, 'substr') !== false)
196
+                    {
197
+                        $cp_temp1 = explode('\'', $cp_nval);
198
+                        $cp_temp2 = explode('(', $cp_nval);
199
+                        $cp_temp3 = explode(')', $cp_temp2[1]);
200
+                        $cp_temp4 = explode(',', $cp_temp3[0]);
201
+                        $cp_cval_string .= substr($cp_temp1[1], trim($cp_temp4[0]), trim($cp_temp4[1]));
202
+                    }
203
+                    else
204
+                    {
205
+                        $cp_cval_string .= trim(trim($cp_nval, '\''));
206
+                    }
207
+                    $cp_cval_string .= NULL;
208
+                }
209
+
210
+                // String Output
211
+                return $cp_cnam_string."=".$cp_cval_string;
212
+            }
213
+        }*/
38 214
         public function FileRead($filename=NULL)
39 215
         {
40 216
             $filename = ($filename) ? $filename : $this->fname;
@@ -55,6 +231,9 @@
55 231
         }
56 232
         public function GetCookie()
57 233
         {
234
+            /*$data = $this->WEBParsing('http://wasabisyrup.com/archives/');
235
+            $cookie = $this->splits($data, '<script>', '</script>');
236
+            $cookie = $this->sucuri($cookie);*/
58 237
             $data = $this->WEBParsing('http://wasabisyrup.com/archives/455742', $cookie, true, 'pass=qndxkr',
59 238
                 array(
60 239
                     'Referer: http://wasabisyrup.com/'
@@ -88,9 +267,9 @@
88 267
                         $err='Not found comics data';
89 268
                         break;
90 269
                     default:
91
-                        $err='Unknown Error. Please send me an e-mail (contact@hakase.kr)';
270
+                        $err='Unknown Error. Please send me an e-mail (hakase@hakase.io)';
92 271
                 }
93 272
                 die(json_encode(array('error'=>$num, 'message'=>$err)));
94 273
             }
95 274
         }
96
-    }
275
+    }

+ 5
- 5
fmaru.php View File

@@ -4,15 +4,15 @@
4 4
     <meta charset="utf-8">
5 5
     <meta name="viewport" content="width=500, user-scalable=no">
6 6
     <title>fmaru php porting by hakase</title>
7
-    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css">
7
+    <!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css"> -->
8
+    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css">
8 9
     <!--<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
9 10
     rel="stylesheet">-->
10
-    <link href="style.css"
11
-    rel="stylesheet">
11
+    <link href="style.css" rel="stylesheet">
12 12
 </head>
13 13
 <body style="margin:0px">
14 14
     <div id="contents"></div>
15
-    <script src="config.js?2017010701"></script>
16
-    <script src="app.js?2017010701"></script>
15
+    <script src="config.js?2018021101"></script>
16
+    <script src="app.js?2018021101"></script>
17 17
 </body>
18 18
 </html>

+ 5
- 17
index.php View File

@@ -8,16 +8,6 @@
8 8
     if(isset($imgurl))
9 9
     {
10 10
         $a = parse_url($imgurl);
11
-        // Insecure checkup causes RFI
12
-        switch($a['scheme'])
13
-        {
14
-            case 'http':
15
-            case 'https':
16
-                break;
17
-            default:
18
-                exit;
19
-        }
20
-
21 11
         switch($a['host'])
22 12
         {
23 13
             case 'www.yuncomics.com':
@@ -40,7 +30,6 @@
40 30
                 exit();
41 31
             }
42 32
         }
43
-
44 33
         header('Cache-Control: max-age=86400, public');
45 34
         header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 86400));
46 35
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s',time() + 86400 ) . ' GMT' );
@@ -80,11 +69,11 @@ Number 2 : Cookie Get Error<br>
80 69
 Number 3 : Password Error (Protected archive) - Retry 10 minutes after view or retry about 3 times)<br>
81 70
 Number 4 : Not found comics data<br>
82 71
 Other error : read the message</p>
83
-<p>Output only JSON (Example) {"error":1,"message":"Error Message)"}<br>
72
+<p>Output only JSON (Example) {"error":1,"message":"Error Message"}<br>
84 73
 Only error / message method use</p>
85 74
 <h2>Etc...</h2>
86 75
 <p><strong><i><u><a href="https://github.com/hakasenyang/marumaru-php-parser" target="_blank">Open Source</a></u></i></strong></p>
87
-<p>Developed by <a href="https://keybase.io/hakasekr" rel="noreferrer" target="_blank">Hakase</a> (contact@hakase.kr)<br>
76
+<p>Developed by <a href="https://keybase.io/hakasekr" rel="noreferrer" target="_blank">Hakase</a> (hakase@hakase.io)<br>
88 77
 사용은 자유고 제한 없음. 애초에 제한 있으면 API 인증키를 넣겠지만 귀찮아서 안 넣음.
89 78
 </p>
90 79
 </body>
@@ -145,13 +134,12 @@ startdata:
145 134
     if ($image)
146 135
     {
147 136
         $jsonon = ($_GET['json'] == 1) ? true : false;
148
-
149
-        for($i=1;$i<count($aaa);$i++)
137
+        for($i=1,$cnt=(count($aaa));$i<$cnt;$i++)
150 138
             echo '<img src="?imgurl='.urlencode(trim(explode('"', $aaa[$i])[0])).'"><br>';
151 139
     }
152 140
     else
153 141
     {
154
-        for($i=1;$i<count($data2);$i++)
142
+        for($i=1,$cnt=count($data2);$i<$cnt;$i++)
155 143
         {
156 144
             if($num == trim(explode('" >', $data2[$i])[0]))
157 145
             {
@@ -180,7 +168,7 @@ startdata:
180 168
             else
181 169
                 $aad[] = ['next'=>null];
182 170
         }
183
-        for($i=2;$i<count($aaa)-1;$i++)
171
+        for($i=1,$cnt=(count($aaa));$i<$cnt;$i++)
184 172
             $aab[] = trim(explode('"', $aaa[$i])[0]);
185 173
 
186 174
         if($jsonon)

+ 3
- 3
manga.php View File

@@ -1,16 +1,16 @@
1 1
 <?php
2 2
     include_once '_function.php';
3 3
     $marumaru = new Marumaru();
4
-    $data = $marumaru->WEBParsing('http://marumaru.in/'.$_GET['href']);
4
+    $data = $marumaru->WEBParsing('https://marumaru.in/'.$_GET['href']);
5 5
     $data = str_replace('class="con_link" ', 'target="_blank" ', $data);
6 6
     $data = preg_replace('/(<[^>]+) style=".*?"/i', '$1', $data);
7 7
     $thumb = $marumaru->splits($data, '<meta property="og:image" content="', '"');
8 8
     $a = explode('<a target="_blank" href="', $data);
9
-    for($i=1;$i<count($a);$i++)
9
+    for($i=1,$cnt=count($a);$i<$cnt;$i++)
10 10
     {
11 11
         $href = explode('/', explode('"', $a[$i])[0])[4];
12 12
         $title = str_replace('&nbsp;', ' ', strip_tags('<a target="_blank" href="'.explode('</a>', $a[$i])[0]));
13 13
         if(!$title) continue;
14 14
         $episodes[] = ['href'=>$href, 'title'=>$title];
15 15
     }
16
-    echo json_encode(array('cover'=>$thumb, 'episodes'=>$episodes));
16
+    echo json_encode(array('cover'=>$thumb, 'episodes'=>$episodes));

+ 4
- 4
mangalist.php View File

@@ -4,19 +4,19 @@
4 4
     $file = $marumaru->FileRead('mangalist.txt');
5 5
     if(!isset($file) || @explode(PHP_EOL, $file)[0] < time())
6 6
     {
7
-        $data = $marumaru->WEBParsing('http://marumaru.in/c/1');
7
+        $data = $marumaru->WEBParsing('https://marumaru.in/c/53');
8 8
         $a = explode('" href="/b/manga/', $data);
9 9
         $b = explode('<div width="200"><', $data);
10
-        for($i=1;$i<count($a);$i++)
10
+        for($i=1,$cnt=count($a);$i<$cnt;$i++)
11 11
         {
12 12
             $name = strip_tags('<'.explode('</div>', $b[$i])[0]);
13 13
             $id = explode('"', $a[$i])[0];
14 14
             $c[] = ['href'=>'/b/manga/'.$id, 'title'=>$name, 'id'=>$id];
15 15
         }
16 16
         $file = json_encode(array('list'=>$c));
17
-        $marumaru->FileWrite($file, 'mangalist.txt');
17
+        $marumaru->FileWrite($file, 'mangalist.txt', (60*30));
18 18
         echo $file;
19 19
         exit;
20 20
     }
21 21
     echo explode(PHP_EOL, $file)[1];
22
-    exit;
22
+    exit;

Loading…
Cancel
Save