-
Notifications
You must be signed in to change notification settings - Fork 0
/
read.php
110 lines (91 loc) · 4.26 KB
/
read.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
//基本ライブラリの読み込み
require_once('components/xss.php');
require_once('components/components.php');
require_once('components/cookie.php');
if(isset($_REQUEST['url'])){
$url = $_REQUEST['url'];
//画像ファイル化によって対応を分ける
if(is_image_url($url)){
$root_url = $_REQUEST['root_url'];
header('Content-Type: image/webp');
$imagefile_path = save_with_webp($url, $root_url);
readfile($imagefile_path);
unlink($imagefile_path);
}
else{
if(isScrapable($url)){
if(isDomainUrlonList($url)){
if (isset($_REQUEST['extra'])){
$url = $url . $_REQUEST['titles'];
}
$content_raw_array = Readability_Raw_Extra($url);
$title = $content_raw_array[0];
$content_raw = $content_raw_array[1];
//HTMLのリンクを変換
$content_url_prefix = Add_Prefix_2_Link($content_raw, "http://localhost/sakusaku-net/read.php?url=");
if($_COOKIE['SAKUSAKUimgshow'] == true){
//画像のリンクを変換
$content_final = Add_Prefix_2_Img_Src($content_url_prefix, "http://localhost/sakusaku-net/read.php?root_url={$url}&url=");
}
else{
$content_final = replace_img_tags($content_url_prefix, "<p style=\"text-align: center;margin: 20px;\">画像は表示されません</p>");
}
}
else{
//Rawの本文を取得
$content_raw_array = Readability_Raw($url);
$title = $content_raw_array[0];
$content_raw = $content_raw_array[1];
//HTMLのリンクを変換
$content_url_prefix = Add_Prefix_2_Link($content_raw, "http://localhost/sakusaku-net/read.php?url=");
if($_COOKIE['SAKUSAKUimgshow'] == true){
//画像のリンクを変換
$content_final = Add_Prefix_2_Img_Src($content_url_prefix, "http://localhost/sakusaku-net/read.php?root_url={$url}&url=");
}
else{
$content_final = replace_img_tags($content_url_prefix, "<p style=\"text-align: center;margin: 20px;\">画像は表示されません</p>");
}
}
}
else{
$title = "Robots.txtによってブロックされました";
$content_url_prefix = "お客様がリクエストされたウェブサイトは、Robots.txtによってスクレイピングが禁止されているため、表示できません。元のページを表示する、をクリックしてウェブサイトを表示してください。";
$url = "read.php";
}
}
}
else{
header("HTTP/1.1 404 Not Found");
$title = "URLを指定してください";
$content_url_prefix = "URLが指定されていません。URLを指定して再度試してください。";
$url = "read.php";
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style/global.css">
<link rel="stylesheet" href="style/reader.css">
<title><?php echo $title ?></title>
</head>
<body>
<header>
<h1><a href="./"></p><span style="color: red;">サクサク</span><span class="logo_title_net">ねっと</span></a></h1>
<form action="read.php" method="get" class="search_container">
<input type="text" class="search_box_input" placeholder="URL..." name="url">
</form>
<a href="<?php echo $url?>">元ページを表示</a>
</header>
<hr>
<div class="article_body"><h1><?php echo $title ?></h1><?php echo $content_final ?></div>
<footer>
<hr>
<p>記事内容・写真の著作権は<a href="<?php echo $url?>">元サイト</a>様の作成者の方に帰属いたします。記事の著作権者はこのサービス(さくさくねっと)の作成者(Komugikotan)ではありません。</p>
<p>©Komugikotan 2023</p>
</footer>
</body>
</html>