Skip to content

Instantly share code, notes, and snippets.

View nveselinov's full-sized avatar

Nasi Atanasov nveselinov

View GitHub Profile
@nveselinov
nveselinov / gist:6161459
Last active December 20, 2015 16:29
Nginx vhost with php-fpm support.
server {
listen 192.168.1.1:80;
server_name site.com;
index index.php index.html;
error_log /var/www/site.com/logs/error.log;
access_log off;
root /var/www/site.com/public;
location / {
@nveselinov
nveselinov / gist:1749595
Created February 6, 2012 04:12
PHP list directory
<?php
$dir = opendir(".");
while($entryName = readdir($dir))
{
$dirArray[] = $entryName;
}
closedir($dir);
$indexCount = count($dirArray);
echo $indexCount." Files<br />";
for($index=0; $index < $indexCount; $index++)
@nveselinov
nveselinov / gist:1749537
Created February 6, 2012 04:08
Online/Offline ip adress
<?php
$ip = "000.000.00.00";
$port = "80";
if ($check=@fsockopen($ip,$port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
fclose($check);
echo '<b style="color:green">Online</b>';
} else {
echo '<b style="color:red">Offline</b>';
}
?>
@nveselinov
nveselinov / gist:1749513
Created February 6, 2012 04:08
HTML 5 Slider Bar
<!DOCTYPE html>
<html>
<head>
<title>HTML 5 Slider Bar</title>
</head>
<body>
<input type="range" min="0" max="50" value="0" step="5" onchange="showValue(this.value)" />
<span id="range">0</span>
<script type="text/javascript">
function showValue(newValue)
@nveselinov
nveselinov / gist:1749506
Created February 6, 2012 04:07
Multilanguage site with php
<!-- Included files contain, variable with their values -->
<!-- Example url: index.php?lang=en -->
<?php
if (!isset ($_GET['lang'])) {
if(isset($_SESSION['lang'])){
$lang=$_SESSION['lang'];
}
else {
$lang='bg';
}
@nveselinov
nveselinov / gist:1749498
Created February 6, 2012 04:06
How to Refresh Current Page in CodeIgniter
redirect($this->uri->uri_string());
@nveselinov
nveselinov / gist:1749492
Created February 6, 2012 04:05
How To Check Whether Ajax Request
<?php
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
if(IS_AJAX)
{
echo 'Ajax request was here';
}
else
{
echo 'Not ajax request';