First commit

마루마루 관련 파일입니다.
This commit is contained in:
hakasenyang
2016-11-02 08:51:06 +09:00
committed by GitHub
parent d75ab3c422
commit f222156c55
13 changed files with 71131 additions and 0 deletions
Binary file not shown.
Binary file not shown.
+241
View File
@@ -0,0 +1,241 @@
<?php
class Marumaru {
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';
private $fname = 'cookie.txt';
public function splits($data, $first, $end, $num = 1)
{
$temp = @explode($first, $data);
$temp = @explode($end, $temp[$num]);
$temp = $temp[0];
return $temp;
}
public function WEBParsing($url, $cookie=NULL, $headershow=TRUE, $postparam=NULL, $otherheader=NULL)
{
$uri = parse_url($url);
$paramType = strtoupper($paramType);
if (!$uri['port']) $uri['port'] = 80;
if (!$uri['path']) $uri['path'] = "/";
$ch = curl_init();
$opts = array(CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_TIMEOUT => 10,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HEADER => $headershow,
CURLOPT_USERAGENT => $this->httph
);
curl_setopt_array($ch, $opts);
if ($otherheader) curl_setopt($ch, CURLOPT_HTTPHEADER, $otherheader);
if ($cookie) curl_setopt($ch, CURLOPT_COOKIE, $cookie);
if ($postparam)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postparam);
}
$data = curl_exec($ch);
curl_close($ch);
if ($curl_errno > 0)
$this->ErrorEcho(14, 'Connect Error!!!');
return ($data) ? $data : false;
}
/**
* sucuri - sucuri 프록시 관련 쿠키 우회
* 소스 : https://github.com/organization/cloudflare-bypass
* 소스 : http://cafe.naver.com/gogoomas/337647
* @param string $result 쿠키 string 입력
* @return strring 쿠키 데이터 출력
*/
public function sucuri($result)
{
if(strpos($result, 'sucuri_cloudproxy_js') !== false)
{
$cp_temp1 = explode('S=\'', $result);
$cp_temp2 = explode(';', $cp_temp1[1]);
$cp_script = $cp_temp2[0];
$cp_temp1 = explode('A=\'', $result);
$cp_temp2 = explode('\';', $cp_temp1[1]);
$cp_chlist = $cp_temp2[0];
$cp_charr = array();
for($i = 0; $i < 64; $i++)
$cp_charr[$cp_chlist[$i]] = $i;
$cp_len = strlen($cp_script);
$cp_c = 0;
$cp_u = 0;
$cp_i = 0;
$cp_l = 0;
$cp_a = NULL;
$cp_r = NULL;
for($i = 0; $i < $cp_len; $i++)
{
$cp_c = $cp_charr[$cp_script[$i]];
$cp_u = ($cp_u << 6) + $cp_c;
$cp_l += 6;
while($cp_l >= 8)
(($cp_a = ($cp_u >> ($cp_l -= 8)) & 0xff) || ($cp_i < ($cp_len - 2))) && ($cp_r .= chr($cp_a));
}
$cp_temp1 = explode('document.cookie=', $cp_r);
$cp_temp2 = explode('=', $cp_temp1[1]);
$cp_cnam = str_replace('"', '\'', $cp_temp2[0]);
$cp_cnam_split = explode('+', $cp_cnam);
$cp_cnam_split_cnt = count($cp_cnam_split);
$cp_cnam_string = NULL;
for($i = 0 ; $i < $cp_cnam_split_cnt; $i++)
{
$cp_cnam = trim($cp_cnam_split[$i]);
if(strpos($cp_cnam, 'slice') !== false)
{
$cp_temp1 = explode('\'', $cp_cnam);
$cp_temp2 = explode('(', $cp_cnam);
$cp_temp3 = explode(')', $cp_temp2[1]);
$cp_temp4 = explode(',', $cp_temp3[0]);
$cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp4[0]), (intval(trim($cp_temp4[1])-trim($cp_temp4[0]))));
}
elseif(strpos($cp_cnam, 'charAt') !== false)
{
$cp_temp1 = explode('\'', $cp_cnam);
$cp_temp2 = explode('(', $cp_cnam);
$cp_temp3 = explode(')', $cp_temp2[1]);
$cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp3[0]), 1);
}
elseif(strpos($cp_cnam, 'String.fromCharCode') !== false)
{
$cp_temp1 = explode('(', $cp_cnam);
$cp_temp2 = explode(')', $cp_temp1[1]);
if(strpos($cp_temp2[0], '0x') !== false)
$cp_cnam_string .= chr(hexdec($cp_temp2[0]));
else
$cp_cnam_string .= chr($cp_temp2[0]);
}
elseif(strpos($cp_cnam, 'substr') !== false)
{
$cp_temp1 = explode('\'', $cp_cnam);
$cp_temp2 = explode('(', $cp_cnam);
$cp_temp3 = explode(')', $cp_temp2[1]);
$cp_temp4 = explode(',', $cp_temp3[0]);
$cp_cnam_string .= substr($cp_temp1[1], trim($cp_temp4[0]), trim($cp_temp4[1]));
}
else
$cp_cnam_string .= trim(trim($cp_cnam, '\''));
$cp_cnam_string .= NULL;
}
//$cp_temp1 = explode('=', $cp_r);
$cp_temp1 = strpos($cp_r, '=');
$cp_temp2 = explode(';document.cookie', substr($cp_r, $cp_temp1+1)); //$cp_temp[1]
$cp_cval = str_replace('"', '\'', $cp_temp2[0]);
$cp_cval_split = explode('+', $cp_cval);
$cp_cval_split_cnt = count($cp_cval_split);
$cp_cval_string = null;
for($i = 0 ; $i < $cp_cval_split_cnt; $i++)
{
$cp_nval = trim($cp_cval_split[$i]);
if(strpos($cp_nval, 'slice') !== false)
{
$cp_temp1 = explode('\'', $cp_nval);
$cp_temp2 = explode('(', $cp_nval);
$cp_temp3 = explode(')', $cp_temp2[1]);
$cp_temp4 = explode(',', $cp_temp3[0]);
$cp_cval_string .= substr($cp_temp1[1], trim($cp_temp4[0]), (intval(trim($cp_temp4[1])-trim($cp_temp4[0]))));
}
elseif(strpos($cp_nval, 'charAt') !== false)
{
$cp_temp1 = explode("'", $cp_nval);
$cp_temp2 = explode("(", $cp_nval);
$cp_temp3 = explode(")", $cp_temp2[1]);
$cp_cval_string .= substr($cp_temp1[1], trim($cp_temp3[0]), 1);
}
elseif(strpos($cp_nval, 'String.fromCharCode') !== false)
{
$cp_temp1 = explode('(', $cp_nval);
$cp_temp2 = explode(')', $cp_temp1[1]);
if(strpos($cp_temp2[0], '0x') !== false)
{
$cp_cval_string .= chr(hexdec($cp_temp2[0]));
}
else
{
$cp_cval_string .= chr($cp_temp2[0]);
}
}
elseif(strpos($cp_nval, 'substr') !== false)
{
$cp_temp1 = explode('\'', $cp_nval);
$cp_temp2 = explode('(', $cp_nval);
$cp_temp3 = explode(')', $cp_temp2[1]);
$cp_temp4 = explode(',', $cp_temp3[0]);
$cp_cval_string .= substr($cp_temp1[1], trim($cp_temp4[0]), trim($cp_temp4[1]));
}
else
{
$cp_cval_string .= trim(trim($cp_nval, '\''));
}
$cp_cval_string .= NULL;
}
// String Output
return $cp_cnam_string."=".$cp_cval_string;
}
}
public function FileRead($filename=NULL)
{
$filename = ($filename) ? $filename : $this->fname;
if(!is_file($filename)) return false;
if(!filesize($filename)) return false;
$fp = fopen($filename, 'r');
$data = fread($fp, filesize($filename));
fclose($fp);
return $data;
}
public function FileWrite($str,$filename=NULL,$time=(60*30))
{
$filename = ($filename) ? $filename : $this->fname;
$fp = fopen($filename, 'w');
// 30분
fwrite($fp, time()+$time.PHP_EOL.$str);
fclose($fp);
}
public function GetCookie()
{
$data = $this->WEBParsing('http://www.yuncomics.com/archives/');
$cookie = $this->splits($data, '<script>', '</script>');
$cookie = $this->sucuri($cookie);
$data = $this->WEBParsing('http://www.yuncomics.com/wp-login.php?action=postpass', $cookie, true, 'post_password=qndxkr&Submit=Submit',
array(
'Referer: http://www.yuncomics.com/'
)
);
$cookie2 = $this->splits($data, 'Set-Cookie: wp-postpass_', ';');
$cookie2 = ';wp-postpass_'.$cookie2.';wordpress_test_cookie=WP+Cookie+check;_mcnc=1;';
$cookie .= $cookie2;
if(!$cookie) return false; else return $cookie;
}
public function ErrorEcho($num,$err=NULL)
{
if($err)
die(json_encode(array('error'=>$num, 'message'=>$err)));
else
{
switch($num)
{
case 0:
$err='Connect Error (yuncomics 403 or other error)';
break;
case 1:
$err='Cookie Send Error (Not applied sucuri cookie data)';
break;
case 2:
$err='Cookie Get Error';
break;
case 3:
$err='Password Error (Protected archive) - Retry 10 minutes after view or retry about 3 times';
break;
case 4:
$err='Not found comics data';
break;
default:
$err='Unknown Error. Please send me an e-mail (contact@hakase.kr)';
}
die(json_encode(array('error'=>$num, 'message'=>$err)));
}
}
}
+70590
View File
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
config = {
apiUrl: ""
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

+18
View File
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=500, user-scalable=no">
<title>fmaru php porting by hakase</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
<!--<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">-->
<link href="style.css"
rel="stylesheet">
</head>
<body style="margin:0px">
<div id="contents"></div>
<script src="config.js"></script>
<script src="app.js"></script>
</body>
</html>
+80
View File
@@ -0,0 +1,80 @@
<?php
include_once '_function.php';
$marumaru = new Marumaru();
$num = $_GET['num'];
if(!is_numeric($num) || strpos($num, '.'))
{
?>
<!doctype html><html><head><title>Yuncomics(marumaru.in) Image URL Parser</title><meta charset="UTF-8">
<style>body img { width: auto; height: auto; max-width: 100%;
}</style>
<link rel="shortcut icon" href="favicon.ico">
</head><body>
<p><strong>Yuncomics(marumaru.in) <u>Image URL</u> Parser</strong><br>Using: /api/{yuncomics number}/{1 or 0(null)}<br>
Use only application/web/other developers.</p>
<p><strong>Example</strong><br>
no json - <a href="/api/553645" target="_blank">/api/553645 (Gochuumon wa Usagi desuka?)</a><br>
json - <a href="/api/553645/1" target="_blank">/api/553645/1 (Gochuumon wa Usagi desuka?)</a></p>
<p><strong>JSON Type</strong><br>
Title : Manga Subject<br>
URL : Image URL<br>
Explorer : Another same cartoon episode (same episode will be ignored) - ID => Name (if not data, replaced with a null value)<br>
PrevNext : Next Episode / Prev Episode - ID => Name (if not data, replaced with a null value)<br>
- Prev : ID => Name (or NULL)<br>
- Next : ID => Name (or NULL)</p>
<p><strong>String Type</strong><br>
First Line : Manga Subject<br>
Other Line : Image URL</p>
<p><strong>Error Message View</strong><br>
Number 0 : Connect Error (yuncomics 403 or other error)<br>
Number 1 : Cookie Send Error (Not applied sucuri cookie data)<br>
Number 2 : Cookie Get Error<br>
Number 3 : Password Error (Protected archive) - Retry 10 minutes after view or retry about 3 times)<br>
Number 4 : Not found comics data<br>
Other error : read the message</p>
<p>Output only JSON (Example) {"Error":1,"Message":"Error Message)"}<br>
Only Error / Message Method use</p>
<p>Domain : <strong>marumaru.hakase.kr</strong></p>
<p><strong><i><u>No Open Source. - I just not want.<br>오픈 소스 계획 없음. - 그냥 하기 싫어.</u></i></strong></p>
<p>Developed by Hakase (contact@hakase.kr)<br>
사용은 자유고 제한 없음. 애초에 제한 있으면 API 인증키를 넣겠지만 귀찮아서 안 넣음.
</p>
</body>
</html>
<?php
exit;
}
cookieget:
$dd = $marumaru->FileRead();
if(!$dd || explode(PHP_EOL, $dd)[0] < time())
{
$cookie = $marumaru->GetCookie();
if(!$cookie) $marumaru->ErrorEcho(2);
$marumaru->FileWrite($cookie);
}
else
$cookie = explode(PHP_EOL, $dd)[1];
startdata:
$caches++;
$data = $marumaru->WEBParsing('http://www.yuncomics.com/archives/'.$num, $cookie);
/*if(stripos($data, 'HTTP/1.1 301 Moved Permanently') !== false)
{
$num = explode('/', $marumaru->splits($data, 'Location: ', PHP_EOL))[4];
$data = $marumaru->WEBParsing('http://www.yuncomics.com/archives/'.$num, $cookie.$cookie2);
}*/
if(stripos($data, 'HTTP/1.1 404 Not Found') !== false || stripos($data, 'HTTP/1.1 301 Moved Permanently') !== false) $marumaru->ErrorEcho(4);
if(stripos($data, 'HTTP/1.1 200 OK') === false) $marumaru->ErrorEcho(0);
if(stripos($data, 'This content is password protected.') !== false)
if($caches > 5) $marumaru->ErrorEcho(3);
else goto startdata;
if(stripos($data, 'You are being redirected...') !== false)
if($caches > 2) $marumaru->ErrorEcho(1);
else goto cookieget;
$jsonon = ($_GET['json'] == 1) ? true : false;
$aaa = explode('data-src="', $data);
for($i=1;$i<count($aaa);$i++)
echo '<img src="'.trim(explode('"', $aaa[$i])[0]).'"><br>';
+21
View File
@@ -0,0 +1,21 @@
<?php
include '_function.php';
$url = $_GET['url'];
$marumaru = new Marumaru();
$a = parse_url($url);
switch($a['host'])
{
case 'www.yuncomics.com':
case 'blog.yuncomics.com':
case 'marumaru.in':
break;
default:
exit;
}
header('Cache-Control: max-age=86400, public');
header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 86400));
header('Content-Type: image/jpeg');
echo $marumaru->WEBParsing($url, NULL, NULL);
?>
+120
View File
@@ -0,0 +1,120 @@
<?php
include_once '_function.php';
$marumaru = new Marumaru();
$num = $_GET['num'];
if(!is_numeric($num) || strpos($num, '.'))
{
?>
<!doctype html><html><head><title>Yuncomics(marumaru.in) Image URL Parser API</title><meta charset="UTF-8">
<style>body img { width: auto; height: auto; max-width: 100%;
}</style>
<link rel="shortcut icon" href="favicon.ico">
</head><body>
<h1>Yuncomics(marumaru.in) <u>Image URL</u> Parser API</h1>
<p>Using: /api/{yuncomics number}/{1 or 0(null)}<br>
Use only application/web/other developers.</p>
<h2>Example</h2>
<p>no json - <a href="/api/553645" target="_blank">/api/553645 (Gochuumon wa Usagi desuka?)</a><br>
json - <a href="/api/553645/1" target="_blank">/api/553645/1 (Gochuumon wa Usagi desuka?)</a><br>
<a href="https://github.com/fmaru/fmaru" rel="noreferrer" target="_blank">fmaru</a> php porting by hakase - <a href="/fmaru" target="_blank">/fmaru</a><br>
image direct view - <a href="/img/553645" target="_blank">/img/553645 (Gochuumon wa Usagi desuka?)</a></p>
<h2>JSON Type</h2>
<p>title : Manga Subject<br>
url : Image URL<br>
explorer : Another same cartoon episode (same episode will be ignored) - id => name (if not data, show null value)<br>
prevnext : Next Episode / Prev Episode (if not data, show null value)<br>
- prev : id => name (or NULL)<br>
- next : id => name (or NULL)</p>
<h2>String Type</h2>
<p>First Line : Manga Subject<br>
Other Line : Image URL</p>
<h2>Error Message</h2>
<p>Number 0 : Connect Error (yuncomics 403 or other error)<br>
Number 1 : Cookie Send Error (Not applied sucuri cookie data)<br>
Number 2 : Cookie Get Error<br>
Number 3 : Password Error (Protected archive) - Retry 10 minutes after view or retry about 3 times)<br>
Number 4 : Not found comics data<br>
Other error : read the message</p>
<p>Output only JSON (Example) {"error":1,"message":"Error Message)"}<br>
Only error / message method use</p>
<h2>Etc...</h2>
<p><strong><i><u>No Open Source. - I just not want.<br>오픈 소스 계획 없음. - 그냥 하기 싫어.</u></i></strong></p>
<p>Developed by <a href="https://keybase.io/hakasekr" rel="noreferrer" target="_blank">Hakase</a> (contact@hakase.kr)<br>
사용은 자유고 제한 없음. 애초에 제한 있으면 API 인증키를 넣겠지만 귀찮아서 안 넣음.
</p>
</body>
</html>
<?php
exit;
}
cookieget:
$dd = $marumaru->FileRead();
if(!$dd || explode(PHP_EOL, $dd)[0] < time())
{
$cookie = $marumaru->GetCookie();
if(!$cookie) $marumaru->ErrorEcho(2);
$marumaru->FileWrite($cookie);
}
else
$cookie = explode(PHP_EOL, $dd)[1];
startdata:
$caches++;
$data = $marumaru->WEBParsing('http://www.yuncomics.com/archives/'.$num, $cookie);
/*if(stripos($data, 'HTTP/1.1 301 Moved Permanently') !== false)
{
$num = explode('/', $marumaru->splits($data, 'Location: ', PHP_EOL))[4];
$data = $marumaru->WEBParsing('http://www.yuncomics.com/archives/'.$num, $cookie.$cookie2);
}*/
if(stripos($data, 'HTTP/1.1 404 Not Found') !== false || stripos($data, 'HTTP/1.1 301 Moved Permanently') !== false) $marumaru->ErrorEcho(4);
if(stripos($data, 'HTTP/1.1 200 OK') === false) $marumaru->ErrorEcho(0);
if(stripos($data, 'This content is password protected.') !== false)
if($caches > 5) $marumaru->ErrorEcho(3);
else goto startdata;
if(stripos($data, 'You are being redirected...') !== false)
if($caches > 2) $marumaru->ErrorEcho(1);
else goto cookieget;
$jsonon = ($_GET['json'] == 1) ? true : false;
$aaa = explode('data-src="', $data);
$title = $marumaru->splits($aaa[0], '<title>', '</title>');
$title = trim(explode(' | ', $title)[0]);
$data2 = explode('<option value="', str_replace(' selected>', '>', $data));
for($i=1;$i<count($data2);$i++)
{
if($num == trim(explode('">', $data2[$i])[0]))
{
if($i != count($data2) - 1)
{
$nextid = trim(explode('">', $data2[$i+1])[0]);
$nextname = trim(explode('</option>', explode('">', $data2[$i+1])[1])[0]);
}
if($i != 1)
{
$previd = trim(explode('">', $data2[$i-1])[0]);
$prevname = trim(explode('</option>', explode('">', $data2[$i-1])[1])[0]);
}
continue;
}
$aac[] = [trim(explode('">', $data2[$i])[0]) => trim(explode('</option>', explode('">', $data2[$i])[1])[0])];
}
if($previd || $nextid)
{
if($previd) $aad[] = ['prev'=>[$previd=>$prevname]]; else $aad[] = ['prev'=>null];
if($nextid) $aad[] = ['next'=>[$nextid=>$nextname]]; else $aad[] = ['next'=>null];
}
for($i=1;$i<count($aaa);$i++)
$aab[] = trim(explode('"', $aaa[$i])[0]);
if($jsonon)
{
$aaaa = array('title'=>$title, 'url'=>$aab, 'explorer'=>$aac, 'prevnext'=>$aad);
echo json_encode($aaaa);
}
else
echo $title.PHP_EOL.implode(PHP_EOL, $aab);
exit;
+15
View File
@@ -0,0 +1,15 @@
<?php
include_once '_function.php';
$marumaru = new Marumaru();
$data = $marumaru->WEBParsing('http://marumaru.in/'.$_GET['href']);
$data = str_replace('class="con_link" ', 'target="_blank" ', $data);
$thumb = $marumaru->splits($data, '<meta property="og:image" content="', '"');
$a = explode('<a target="_blank" href="', $data);
for($i=1;$i<count($a);$i++)
{
$href = explode('/', explode('"', $a[$i])[0])[4];
$title = str_replace('&nbsp;', ' ', strip_tags('<a target="_blank" href="'.explode('</a>', $a[$i])[0]));
if(!$title) continue;
$episodes[] = ['href'=>$href, 'title'=>$title];
}
echo json_encode(array('cover'=>$thumb, 'episodes'=>$episodes));
+20
View File
@@ -0,0 +1,20 @@
<?php
include_once '_function.php';
$marumaru = new Marumaru();
$file = $marumaru->FileRead('mangalist.txt');
if(!$file || explode(PHP_EOL, $file)[0] < time())
{
$data = $marumaru->WEBParsing('http://marumaru.in/c/1');
$a = explode('" href="/b/manga/', $data);
$b = explode('<div width="200"><', $data);
for($i=1;$i<count($a);$i++)
{
$name = strip_tags('<'.explode('</div>', $b[$i])[0]);
$id = explode('"', $a[$i])[0];
$c[] = ['href'=>'/b/manga/'.$id, 'title'=>$name, 'id'=>$id];
}
$marumaru->FileWrite(json_encode(array('list'=>$c)), 'mangalist.txt');
$file = $marumaru->FileRead('mangalist.txt');
}
echo explode(PHP_EOL, $file)[1];
exit;
+23
View File
@@ -0,0 +1,23 @@
/* fallback */
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'), url(/Material_Icons.woff2) format('woff2'), url(/Material_Icons.woff) format('woff');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}