Skip to content

Instantly share code, notes, and snippets.

View georgebent's full-sized avatar

Yuriy Kr georgebent

View GitHub Profile
@georgebent
georgebent / getIp.php
Last active March 3, 2018 08:38
PHP examples
function getIp()
{
//check ip from share internet
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
}
//to check ip is pass from proxy
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
@georgebent
georgebent / changeFileNames.php
Last active June 17, 2023 15:16
PHP examples
<?php
$i = 1;
$path = 'files/'; // path to files
$separator = '-logo-'; // separator to divide the string and take the first part
$errors = [];
foreach (glob($path . '*.*') as $name) {
$filename = basename($name);
$arrayOfString = explode($separator, $filename);
@georgebent
georgebent / appache_settings.txt
Last active March 6, 2018 07:39
Apache 2 Server Settings
<VirtualHost localhost:80>
ServerName test.dev
ServerAlias www.test.dev
DocumentRoot /home/yura/projects/test.dev
<directory /home/yura/projects/test.dev>
AllowOverride All
Require all granted
</directory>
ErrorLog /home/yura/projects/test.dev/logs/error.log
LogLevel warn