Приятные мелочи на php

Пишу эту заметку для себя, вдруг мне пригодиться, в моем компьютере потеряется, а тут на блоге останется навсегда — да и Вам может пригодиться ;-).
Две маленькие функции на php:
- Определение Тематического Индекса Цитирования
- Многоязычный переводчик
Определение ТИЦ
Берет значения тИЦ напрямую из Яндекс.Каталога, очень быстрая скорость работы. Писал не Я, писал .
<?php
function yandex_tic($url){
$file=file_get_contents("http://search.yaca.yandex.ru/yca/cy/ch/$url/");
if(preg_match("!—\s+([0-9]{0,8})<\/b>!is",$file,$ok)){
// сайт не в каталоге.
$str=$ok[1];
}
else if(preg_match("!<td class=\"current\" valign=\"middle\">(.*?)</td>\n</tr>!si", $file, $ok)){
if(preg_match("!<td align=\"right\">(.*?)</td>\n</tr>!si", $ok[0], $str)){
// сайт в каталоге.
$str=$str[1];
} else {
$str=0;
}
}
else {
$str=0;
}
return trim($str);
}
// Пример:
// echo yandex_tic("zhilinsky.ru")
?>
Многоязычный переводчик
Работает через .
Работает быстро. Писал Я, на коленке, поэтому криво, если будут замечания — пишите! Я исправлюсь ;-)
<?php
function translate($text,$lg) {
$lg = urlencode($lg);
$text = urlencode($text);
$link = file_get_contents("http://google.com/translate_t?langpair=$lg&text=$text");
preg_match('/<div id=result_box dir=\"ltr\">(.*?)<\/div>/', $link, $out);
return $out[1];
}
// Пример:
// echo translate("hello")
// Пример c другим языком(С Английского на Немецкий):
// echo translate("hello", "en|de")
?>

You…are…my…hero!!! I cant believe something like this exists on the internet! Its so true, so honest, and more than that you dont sound like an idiot! Finally, someone who knows how to talk about a subject without sounding like a kid who didnt get that bike he wanted for Christmas.
ПриÑтные мелочи на php | Чернев.ру Very nice post. I just stumbled upon your blog and wished to say that I’ve really enjoyed browsing your blog posts. After all I will be subscribing to your feed and I hope you write again very soon!
Of course, what a splendid site and informative posts, I surely will bookmark your site.Best Regards!
Simply wanna remark on few general things, The website style and design is perfect, the subject material is real great : D.
ПриÑтные мелочи на php | Чернев.ру Pretty nice post. I just stumbled upon your blog and wished to say that I have truly enjoyed surfing around your blog posts. After all I will be subscribing to your feed and I hope you write again very soon!
ПриÑтные мелочи на php | Чернев.ру Pretty nice post. I just stumbled upon your blog and wished to say that I’ve truly enjoyed browsing your blog posts. In any case I’ll be subscribing to your rss feed and I hope you write again soon!
I loved as much as you will receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get got an edginess over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly very often inside case you shield this increase.
I dugg some of you post as I cerebrated they were extremely helpful handy
Nice post at ПриÑтные мелочи на php | Чернев.ру. I was checking continuously this blog and I’m impressed! Very useful info particularly the last part :) I care for such information much. I was seeking this particular info for a very long time. Thank you and good luck.
ПриÑтные мелочи на php | Чернев.ру Pretty nice post. I just stumbled upon your blog and wished to say that I’ve truly enjoyed surfing around your blog posts. After all I will be subscribing to your rss feed and I hope you write again very soon!