if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
function mb_ucfirst($string) {
$string = mb_ereg_replace("^[\ ]+","", $string);
$string = mb_strtoupper(mb_substr($string, 0, 1, "UTF-8"), "UTF-8").mb_substr($string, 1, mb_strlen($string), "UTF-8" );
return $string;
}
}
$text=mb_ucfirst($text);
Обновлено: https://krylov.org.ua/php-strtolower-krome-pervoj-bukvy-slovo-s-bolshoj/
Нужно было, когда серверное время не правильное, и поменять его нет доступа..
В примере для парсинга используется библиотека simple_html_dom, парсится сайт http://24timezones.com/
Пример для московского времени:
require $_SERVER['DOCUMENT_ROOT'].'/lib/simple_html_dom.php';
$data_msk=file_get_html('http://24timezones.com/ru_vremia/moscow_mestnoe_vremia.php');
if ($data_msk!='') {
$time_msk_b=$data_msk->find('#currentTime',0);
$time_msk=$time_msk_b->plaintext;
if ($time_msk!='') {
$time_msk=substr($time_msk,0,strpos($time_msk,','));
$arr_msk_time=explode(':',$time_msk);
}
$data_msk->clear();
}
unset($data_msk);
echo $arr_msk_time[0].":".$arr_msk_time[1];
Время для разных городов, парсится сайт http://www.timeanddate.com/worldclock/
$data_all=file_get_html('http://www.timeanddate.com/worldclock/');
if ($data_all!='') {
//Kyiv
$time_kyiv_b=$data_all->find('#p76',0);
$time_kyiv=$time_kyiv_b->plaintext;
if ($time_kyiv!='') {
$time_kyiv=substr($time_kyiv,strrpos($time_kyiv,' '),strlen($time_kyiv));
$arr_kyiv_time=explode(':',$time_kyiv);
}
//Moscow
$time_msk_b=$data_all->find('#p95',0);
$time_msk=$time_msk_b->plaintext;
if ($time_msk!='') {
$time_msk=substr($time_msk,strrpos($time_msk,' '),strlen($time_msk));
$arr_msk_time=explode(':',$time_msk);
}
//Brussels
$time_brus_b=$data_all->find('#p27',0);
$time_brus=$time_brus_b->plaintext;
if ($time_brus!='') {
$time_brus=substr($time_brus,strrpos($time_brus,' '),strlen($time_brus));
$arr_brus_time=explode(':',$time_brus);
}
$data_all->clear();
}
unset($data_all);
После установки php5 из портов в /usr/local/etc/apache22/httpd.conf
должны присутствовать строки:
LoadModule php5_module libexec/apache22/libphp5.so
<IfModule mod_php5.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
В примере пароль для соединения с tor через telnet: 11111111.
1. Указать пароль для tor:
C:\Documents and Settings\Администратор>d:
D:\>"D:\путь\Tor Browser\App\tor.exe" --hash-password 11111111
Nov 04 12:57:59.609 [notice] Tor v0.2.2.39 (git-bec76476efb71549). This is experimental software. Do
not rely on it for strong anonymity. (Running on Windows Server 2003 Service Pack 2 [server])
16:7993DDC95824CA9560D54E1087F0CB04114C422F80127C7C03B6B1D117
2. Привести секцию [Tor] в vidalia.conf примерно к такому виду:
[Tor]
UseRandomPassword=false
ControlPassword=11111111
ControlPort=9051
TorExecutable=.\\tor.exe
Torrc=..\\Data\\Tor\\torrc
DataDirectory=..\\Data\\Tor
3. Настройки Tor (Настройки -> Дополнительное -> Редактировать текущий torrc):
HashedControlPassword 16:1192ACE7BD1DE44D607510D709DB2B1AED97C89D54FCFE28B27DBD567A
4. Настройка privoxy:
Orptions -> Edit Main configuration -> Примерно 1280 строка — добавляются строки:
forward-socks4a / 127.0.0.1:9050 .
forward-socks4 / 127.0.0.1:9050 .
forward-socks5 / 127.0.0.1:9050 .
5. Функция PHP:
function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code=''){
$fp=fsockopen($tor_ip, $control_port, $errno, $errstr, 30);
if (!$fp) return false;
fputs($fp, "AUTHENTICATE $auth_code\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code != '250') return false;
fputs($fp, "signal NEWNYM\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code != '250') return false;
fclose($fp);
return true;
}
6. Вызов:
tor_new_identity('127.0.0.1','9051','11111111');
Пример работы в скрипте:
function CreateContext() {
GetNewIdentity();
$curent_proxy='127.0.0.1:8118';
$opts=array('http'=>array('method'=>"GET",'header'=>"Accept-language: en\r\n"."Cookie: yandex_gid=213\r\n",'user_agent'=>'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28','proxy'=>$curent_proxy,'request_fulluri'=>true));
$context=stream_context_create($opts);
return $context;
}
function GetNewIdentity() {
if (tor_new_identity('127.0.0.1','9051','11111111')) {
sleep(2);
}
else {
GetNewIdentity();
}
}
$data=file_get_html('http://site.ru/',false,CreateContext());