-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
83 lines (77 loc) · 2.56 KB
/
functions.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
<?php
function find($first, $latest, $text) {
@preg_match_all('/' . preg_quote($first, '/') . '(.*?)'. preg_quote($latest, '/').'/i', $text, $m);
return @$m[1];
}
function curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Content-Type: application/xml', 'Connection: Keep-Alive'));
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36');
return $html = curl_exec($ch);
curl_close($ch);
}
function percent($a, $b) {
if ( $a > 0 ) {
return round((($b * 100) / $a),2);
} else {
return 0;
}
}
function clearInteger($x) {
return (int)str_replace('.', '', $x);
}
function clearPercent($x) {
return str_replace(',', '.', $x);
}
function turkishDate($format, $datetime = 'now') {
$z = date("$format", strtotime($datetime));
$string = array(
'Monday' => 'Pazartesi',
'Tuesday' => 'Salı',
'Wednesday' => 'Çarşamba',
'Thursday' => 'Perşembe',
'Friday' => 'Cuma',
'Saturday' => 'Cumartesi',
'Sunday' => 'Pazar',
'January' => 'Ocak',
'February' => 'Şubat',
'March' => 'Mart',
'April' => 'Nisan',
'May' => 'Mayıs',
'June' => 'Haziran',
'July' => 'Temmuz',
'August' => 'Ağustos',
'September' => 'Eylül',
'October' => 'Ekim',
'November' => 'Kasım',
'December' => 'Aralık',
'Mon' => 'Pts',
'Tue' => 'Sal',
'Wed' => 'Çar',
'Thu' => 'Per',
'Fri' => 'Cum',
'Sat' => 'Cts',
'Sun' => 'Paz',
'Jan' => 'Oca',
'Feb' => 'Şub',
'Mar' => 'Mar',
'Apr' => 'Nis',
'Jun' => 'Haz',
'Jul' => 'Tem',
'Aug' => 'Ağu',
'Sep' => 'Eyl',
'Oct' => 'Eki',
'Nov' => 'Kas',
'Dec' => 'Ara',
);
foreach($string as $en => $tr){
$z = str_replace($en, $tr, $z);
}
if (strpos($z, 'Mayıs') !== false && strpos($format, 'F') === false) $z = str_replace('Mayıs', 'May', $z);
return $z;
}