<?php
$dom = new domDocument;
$csfd = file_get_contents("http://www.csfd.cz/film/$csfd_id");
$html = (ord($csfd[0]) == 31) ? gzdecode($csfd) : $csfd;
@$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
$xpath = new DOMXPath($dom);
$nazvy = array();
$zeme = array();
$names_other = "";
$nodes = $xpath->query("//h1[@itemprop='name']");
$names_cs = $nodes->item(0)->nodeValue;
foreach($xpath->query("//ul[@class='names']/li/h3") as $li) {
$nazvy[] = $li->nodeValue;
}
foreach($xpath->query("//ul[@class='names']/li/img") as $li) {
$zeme[] = $li->getAttribute('alt');
}
for($i=0;$i<count($nazvy);$i++){
if($i==count($nazvy)-1)
$names_other .= $zeme[$i]."-".$nazvy[$i];
else
$names_other .= $zeme[$i]."-".$nazvy[$i].";";
}
$nodes = $xpath->query("//h2[@class='average']");
$hodnoceni = str_replace('%', '', $nodes->item(0)->nodeValue);
$nodes = $xpath->query("//p[@class='origin']");
$podrobnosti = explode(", ", $nodes->item(0)->nodeValue);
$nodes = $xpath->query("//p[@class='genre']");
$genre = str_replace(' / ', '@;@', $nodes->item(0)->nodeValue);
$nodes = $xpath->query("//span[@data-truncate='340']");
$hraji = $nodes->item(0)->nodeValue;
$nodes = $xpath->query("//div[@data-truncate='570']");
$popis = $nodes->item(0)->nodeValue;
$nodes = $xpath->query("//img[@class='film-poster']");
$poster_url = "http:".$nodes->item(0)->getAttribute('src');
<?php
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
echo human_filesize(filesize('example.zip'));
<?php
function check_alive($url, $timeout = 10, $successOn = array(200, 301)) {
$ch = curl_init($url);
// Set request options
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_NOBODY => true,
CURLOPT_TIMEOUT => $timeout,
CURLOPT_USERAGENT => "page-check/1.0"
));
// Execute request
curl_exec($ch);
// Check if an error occurred
if(curl_errno($ch)) {
curl_close($ch);
return false;
}
// Get HTTP response code
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Page is alive if 200 OK is received
//return $code;
return in_array( $code, $successOn );
}
$checks = array(
'http://www.google.co.uk',
'http://www.facebook.com',
'http://www.bbc.co.uk',
'http://photogabble.co.uk',
'http://youtube.com'
);
foreach($checks as $check)
{
echo $check . ' is ' . ( (check_alive($check) ) ? 'Alive' : 'Dead' ) . "\n";
}
$router[] = new Route('<slug .+>', array(
null => Route::FILTER_IN => function($params) {
// nacist z databaze podle $params['slug'];
if (nenalezeno) {
return null;
}
unset($params['slug']);
$params['module'] = '...';
$params['presenter'] = '...';
$params['action'] = '...';
$params['id'] = '...';
$params['...'] = '...';
return $params;
},
null => Route::FILTER_OUT => function($params) {
// nacist $slug z db prodle $params['module'], $params['presenter'], $params['action'], ...
if (nenalezeno) {
return null;
}
unset($params['module'], $params['presenter'], ...);
$params['slug'] = $slug;
return $params;
},
));
(function(img) {
for (var i = img.length; i--; ) {
img[i].src = "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAAHAP8ALAAAAAABAAEAAAICRAEAOw==";
}
})(document.images);
<?
setlocale(LC_ALL, 'cs_CZ.UTF-8');
header("content-type: text/html; charset=UTF-8");
$arr = explode(",", "č, d, b, a, š, ř, o, x, z, ž, á, s, m");
uasort($arr, "strcoll");
echo "<pre>" . print_r($arr, 1) . "</pre>";
?>
-- Set your users current location in LAT/LONG here
set @lat=51.891648;
set @lng=0.244799;
-- The main SQL query that returns the closest 5 airports.
SELECT id, icao, lat, lng, 111.045 * DEGREES(ACOS(COS(RADIANS(@lat))
* COS(RADIANS(lat))
* COS(RADIANS(lng) - RADIANS(@lng))
+ SIN(RADIANS(@lat))
* SIN(RADIANS(lat))))
AS distance_in_km
FROM airports
ORDER BY distance_in_km ASC
LIMIT 0,5;
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;">
</div>
<script type="text/javascript">
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</body>
</html>