Completed
Branch master (75744f)
by Mert S.
03:49 queued 01:34
created

rss.php (3 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
	include ("functions.php");
4
	date_default_timezone_set("Europe/Istanbul");
5
	
6
	$site = "http://m.koeri.boun.edu.tr/dbs/deprem-listesi-touch.asp";
7
	$content = file_get_contents($site);
8
	$local = find("&ecenter=", "&mag", $content);
9
	$date = find("&tarih=", "&", $content);
10
	$time = find("&saat=", "&", $content);
11
	$mag = find("&mag=", "&", $content);
12
	$lat = find("&lat=", "&", $content);
13
	$lon = find("&lon=", "&", $content);
14
	
15
	header("Content-Type: application/xml; UTF-8");
16
	
17
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\"
18
	xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
19
	xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"
20
	xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
21
	xmlns:atom=\"http://www.w3.org/2005/Atom\"
22
	xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"
23
	xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"
24
	xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"
25
	>
26
			<channel>
27
				<title>Deprem Bilgi Sistemi</title>
28
				<atom:link href=\"http://deprem.mertskaplan.com/rss\" rel=\"self\" type=\"application/rss+xml\" />
29
				<link>http://deprem.mertskaplan.com</link>
30
				<description>Haberciler ve geliştiriciler için son depremlerin bilgilerini veren özelleştirilebilir RSS yayını.</description>
31
				<lastBuildDate>". date("D, d M Y H:i:s") ." +0200</lastBuildDate>
32
				<language>tr-TR</language>
33
				<webMaster>[email protected] (Mert Salih Kaplan)</webMaster>
34
				<sy:updatePeriod>hourly</sy:updatePeriod>
35
				<sy:updateFrequency>1</sy:updateFrequency>
36
				<generator>http://deprem.mertskaplan.com/</generator>
37
				<image>
38
					<title>Deprem Bilgi Sistemi</title>
39
					<url>http://deprem.mertskaplan.com/img/logo.png</url>
40
					<link>http://deprem.mertskaplan.com</link>
41
					<width>140</width>
42
					<height>140</height>
43
					<description>Haberciler ve geliştiriciler için son depremlerin bilgilerini veren özelleştirilebilir RSS yayını.</description>
44
				</image>			
45
	";
46
47
	$days = array("Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi","Pazar");
48
	$months = array("Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık");
49
	
50
	$month = $months[date('m') - 1];
51
	$day = $days[date('N') - 1];
52
	
53
	if	(isset($_GET["mag"]))	{$magOp = str_replace(',', '.', $_GET["mag"]);}
54
	else						{$magOp = 0;}
55
56
	for ($x=0; $x <= 140; $x = $x+2) {
57
		
58
		$magDot = str_replace(',', '.', $mag[$x]); 
59
			
60
		if		(isset($_GET["local"]) && $_GET["local"] == 1) {			
61
			if	(
62
					strstr($local[$x],"AKDENIZ") ||
63
					strstr($local[$x],"AKDENİZ") ||
64
					strstr($local[$x],"KARADENIZ") ||
65
					strstr($local[$x],"EGE DENIZI") ||
66
					strstr($local[$x],"DOGU AKDENIZ") ||
67
					strstr($local[$x],"ACIKLARI") ||
68
					strstr($local[$x],"YUNANISTAN") ||
69
					strstr($local[$x],"GURCISTAN") ||
70
					strstr($local[$x],"GIRIT ADASI (AKDENIZ)") ||
71
					strstr($local[$x],"KIBRIS") ||
72
					strstr($local[$x],"CYPRUS") ||
73
					strstr($local[$x],"GREECE") ||
74
					strstr($local[$x],"BULGARISTAN") ||
75
					strstr($local[$x],"IRAN") ||
76
					strstr($local[$x],"AEGEAN SEA")
77
				 )
78
				 {$localFilter = 1;}
79
			else {$localFilter = 0;}
80
		}
81
		else	{$localFilter = 0;}
82
83
		if	($magDot >= $magOp && $localFilter == 0) {
84
			$editDate = str_replace("/","-",$date[$x]);
85
			$dateFormat = date("D, d M Y", strtotime($editDate));
86
			setlocale(LC_TIME, 'tr_TR');
87
			$datePrint = date("%e %B %Y, %A", strtotime($editDate));
88
			
89
			if		($_GET["map"] == "g") {
90
				$link = "https://www.google.com/maps/@$lat[$x],$lon[$x],12z";
91
			}
92
			elseif	($_GET["map"] == "y") {
93
				$link = "https://harita.yandex.com.tr/?text=$lat[$x]%2C$lon[$x]";
94
			}
95
			elseif	($_GET["map"] == "o") {
96
				$link = "http://www.openstreetmap.org/#map=12/$lat[$x]/$lon[$x]";
97
			}
98
			elseif	($_GET["map"] == "b") {
99
				$link = "http://www.bing.com/maps/?cp=$lat[$x]~$lon[$x]&amp;lvl=14&amp;sty=h";
100
			}
101
			elseif	($_GET["map"] == "w") {
102
				$link = "http://wikimapia.org/#lang=tr&amp;lat=$lat[$x]&amp;lon=$lon[$x]&amp;z=12";
103
			}
104
			elseif	($_GET["map"] == "h") {
105
				$link = "https://www.here.com/?map=$lat[$x],$lon[$x],12";
106
			}
107
			elseif	($_GET["map"] == "z") {
108
				$link = "https://www.waze.com/livemap/?zoom=12&lat=$lat[$x]&lon=$lon[$x]";
109
			}
110
			else	{
111
				$link = "http://www.openstreetmap.org/#map=12/$lat[$x]/$lon[$x]";
112
			}
113
			
114
			if ($_GET["flash"] == 1 && $mag[$x] >= 5)	{$flash = "⚡ ";}
115
			else {$flash = "";}
116
			
117
			if (strpos($local[$x], "*")) {
118
				$localeSTR = strstr($local[$x], '*', true);
119
			}
120
			elseif (strpos($local[$x], "[")) {
121
				$localeSTR = strstr($local[$x], '[', true);
122
			}
123
			else {
124
				$localeSTR = $local[$x];
125
			}
126
			
127
			$localeRp = str_replace("-",", ",str_replace(")","",str_replace("-(",", ",str_replace(" (",", ",str_replace("- (",", ",$localeSTR)))));
128
			$localeEx = explode(", ", $localeRp);
129
			
130
			$fileop = file("local.txt", FILE_IGNORE_NEW_LINES);
131
			$fileInconsistent = file("inconsistent.txt", FILE_IGNORE_NEW_LINES);
132
			$fileopUp = array_map('strtoupperEN', $fileop);
133
			$hour = substr($time[$x], 0, 5);
134
135
			$localeTR1[$x] = editLocal($localeEx[0], $fileop, $fileopUp);
136
			$localeTR2[$x] = editLocal($localeEx[1], $fileop, $fileopUp);
137
			$localeTR3[$x] = editLocal($localeEx[2], $fileop, $fileopUp);
138
		
139 View Code Duplication
			if ($localeTR1[$x] == null) {
0 ignored issues
show
It seems like you are loosely comparing $localeTR1[$x] of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
140
				$localeTR1[$x] = ucwords(strtolower($localeEx[0]));
141
				
142
				if (!in_array($localeEx[0],$fileInconsistent) && !empty($localeEx[1])) {
143
					$open = fopen("inconsistent.txt","a");
144
					$write = "$localeEx[0]\n";
145
					fwrite($open, $write);
146
					fclose($open);
147
				}
148
			}
149
			
150 View Code Duplication
			if ($localeTR2[$x] == null) {
0 ignored issues
show
It seems like you are loosely comparing $localeTR2[$x] of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
151
				$localeTR2[$x] = ucwords(strtolower($localeEx[1]));
152
				
153
				if (!in_array($localeEx[1],$fileInconsistent) && !empty($localeEx[2])) {
154
					$open = fopen("inconsistent.txt","a");
155
					$write = "$localeEx[1]\n";
156
					fwrite($open, $write);
157
					fclose($open);
158
				}
159
			}
160
			
161 View Code Duplication
			if ($localeTR3[$x] == null) {
0 ignored issues
show
It seems like you are loosely comparing $localeTR3[$x] of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
162
				$localeTR3[$x] = ucwords(strtolower($localeEx[2]));
163
				
164
				if (!in_array($localeEx[0],$fileInconsistent) && !empty($localeEx[3])) {
165
					$open = fopen("inconsistent.txt","a");
166
					$write = "$localeEx[2]\n";
167
					fwrite($open, $write);
168
					fclose($open);
169
				}
170
			}
171
	
172
			if (isset($localeEx[0])) {
173
				if ($_GET["hashtag"] == 1) {
174
					$hashtag1 = hashtag($localeTR1[$x]);
175
				}
176
			}
177
178
			if (isset($localeEx[1])) {
179
				$separator1 = ", ";
180
				if ($_GET["hashtag"] == 1) {
181
					$hashtag2 = hashtag($localeTR2[$x]);
182
				}
183
			}
184
			else {$separator1 = ""; $hashtag2 = "";}
185
			
186
			if (isset($localeEx[2])) {
187
				$separator2 = ", ";
188
				if ($_GET["hashtag"] == 1) {
189
					$hashtag3 = hashtag($localeTR3[$x]);
190
				}
191
			}
192
			else {$separator2 = ""; $hashtag3 = "";}
193
			
194
			echo "
195
					<item>
196
						<title>$mag[$x] - $hashtag1$localeTR1[$x]$separator1$hashtag2$localeTR2[$x]$separator2$hashtag3$localeTR3[$x]</title>
197
						<link>$link</link>
198
						<guid>$link</guid>
199
						<pubDate>$dateFormat $time[$x] +0200</pubDate>
200
			";
201
				if ($_GET["twitter"] == 1) {
202
					echo "
203
						<description><![CDATA[<div><img width=\"640\" height=\"320\" src=\"http://deprem.mertskaplan.com/img.php?url=https%3A%2F%2Fmaps.googleapis.com%2Fmaps%2Fapi%2Fstaticmap%3Fcenter%3D$lat[$x]%2C$lon[$x]%26zoom%3D8%26size%3D640x320%26format%3Djpg%26maptype%3Droadmap%26markers%3Dcolor%3Ared%7C$lat[$x]%2C$lon[$x]%26markers%3Dsize%3Amid%7Ccolor%3Ablue%7C$localeTR2[$x]%2C$localeTR3[$x]%26markers%3Dsize%3Amid%7Ccolor%3Ablue%7C$localeTR3[$x]%26key%3DAIzaSyDVBikwIvQQTFzyjdEWGT-zKu-smi6I1oc\" alt=\"Deprem Bilgi Sistemi\" /></div>$flash$hour sularında merkez üssü $hashtag1$localeTR1[$x]$separator1$hashtag2$localeTR2[$x]$separator2$hashtag3$localeTR3[$x] olan $mag[$x] büyüklüğünde deprem meydana geldi.]]></description>
204
					";
205
				}
206
				else {
207
					echo "
208
						<description><![CDATA[<div><img width=\"640\" height=\"320\" src=\"http://deprem.mertskaplan.com/img.php?url=https%3A%2F%2Fmaps.googleapis.com%2Fmaps%2Fapi%2Fstaticmap%3Fcenter%3D$lat[$x]%2C$lon[$x]%26zoom%3D8%26size%3D640x320%26format%3Djpg%26maptype%3Droadmap%26markers%3Dcolor%3Ared%7C$lat[$x]%2C$lon[$x]%26markers%3Dsize%3Amid%7Ccolor%3Ablue%7C$localeTR2[$x]%2C$localeTR3[$x]%26markers%3Dsize%3Amid%7Ccolor%3Ablue%7C$localeTR3[$x]%26key%3DAIzaSyDVBikwIvQQTFzyjdEWGT-zKu-smi6I1oc\" alt=\"Deprem Bilgi Sistemi\" /></div>$flash". date('j ') . $month . date(' Y ') . $day ." günü $time[$x] sularında merkez üssü $hashtag1$localeTR1[$x]$separator1$hashtag2$localeTR2[$x]$separator2$hashtag3$localeTR3[$x] olan $mag[$x] büyüklüğünde deprem meydana geldi.]]></description>
209
					";
210
				}
211
			echo "
212
						<source url=\"http://www.koeri.boun.edu.tr/scripts/sondepremler.asp\">BOĞAZİÇİ ÜNİVERSİTESİ KANDİLLİ RASATHANESİ VE DEPREM ARAŞTIRMA ENSTİTÜSÜ (KRDAE) BÖLGESEL DEPREM-TSUNAMİ İZLEME VE DEĞERLENDİRME MERKEZİ (BDTİM)</source>
213
					</item>
214
			";
215
		}
216
	}
217
	
218
	echo "
219
			</channel>
220
		</rss>
221
	";