tl_host = $host;
} else {
$this->tl_host = $_SERVER['HTTP_HOST'];
}
$this->tl_host = preg_replace('{^https?://}i', '', $this->tl_host);
$this->tl_host = preg_replace('{^www\.}i', '', $this->tl_host);
$this->tl_host = strtolower( $this->tl_host);
if (isset($options['is_static']) && $options['is_static']) {
$this->tl_is_static = true;
}
if (isset($options['request_uri']) && strlen($options['request_uri']) != 0) {
$this->tl_request_uri = $options['request_uri'];
} else {
if ($this->tl_is_static) {
$this->tl_request_uri = preg_replace( '{\?.*$}', '', $_SERVER['REQUEST_URI']);
$this->tl_request_uri = preg_replace( '{/+}', '/', $this->tl_request_uri);
} else {
$this->tl_request_uri = $_SERVER['REQUEST_URI'];
}
}
$this->tl_request_uri = rawurldecode($this->tl_request_uri);
if (isset($options['multi_site']) && $options['multi_site'] == true) {
$this->tl_multi_site = true;
}
if ((isset($options['verbose']) && $options['verbose']) ||
isset($this->tl_links['__trustlink_debug__'])) {
$this->tl_verbose = true;
}
if (isset($options['charset']) && strlen($options['charset']) != 0) {
$this->tl_charset = $options['charset'];
}
if (isset($options['fetch_remote_type']) && strlen($options['fetch_remote_type']) != 0) {
$this->tl_fetch_remote_type = $options['fetch_remote_type'];
}
if (isset($options['socket_timeout']) && is_numeric($options['socket_timeout']) && $options['socket_timeout'] > 0) {
$this->tl_socket_timeout = $options['socket_timeout'];
}
if ((isset($options['force_show_code']) && $options['force_show_code']) ||
isset($this->tl_links['__trustlink_debug__'])) {
$this->tl_force_show_code = true;
}
#Cache options
if (isset($options['use_cache']) && $options['use_cache']) {
$this->tl_cache = true;
}
if (isset($options['cache_clusters']) && $options['cache_clusters']) {
$this->tl_cache_size = $options['cache_clusters'];
}
if (isset($options['cache_dir']) && $options['cache_dir']) {
$this->tl_cache_dir = $options['cache_dir'];
}
if (!defined('TRUSTLINK_USER')) {
return $this->raise_error("Constant TRUSTLINK_USER is not defined.");
}
if (isset($_SERVER['HTTP_TRUSTLINK']) && $_SERVER['HTTP_TRUSTLINK']==TRUSTLINK_USER){
$this->tl_test=true;
$this->tl_isrobot=true;
$this->tl_verbose = true;
}
if (isset($_GET['trustlink_test']) && $_GET['trustlink_test']==TRUSTLINK_USER){
$this->tl_force_show_code=true;
$this->tl_verbose = true;
}
$this->load_links();
}
function setup_datafile($filename){
if (!is_file($filename)) {
if (@touch($filename, time() - $this->tl_cache_lifetime)) {
@chmod($filename, 0666);
} else {
return $this->raise_error("There is no file " . $filename . ". Fail to create. Set mode to 777 on the folder.");
}
}
if (!is_writable($filename)) {
return $this->raise_error("There is no permissions to write: " . $filename . "! Set mode to 777 on the folder.");
}
return true;
}
function load_links() {
if ($this->tl_multi_site) {
$this->tl_links_db_file = dirname(__FILE__) . '/trustlink.' . $this->tl_host . '.links.db';
} else {
$this->tl_links_db_file = dirname(__FILE__) . '/trustlink.links.db';
}
if (!$this->setup_datafile($this->tl_links_db_file)){return false;}
//cache
if ($this->tl_cache){
//check dir
if (!is_dir(dirname(__FILE__) .'/'.$this->tl_cache_dir)) {
if(!@mkdir(dirname(__FILE__) .'/'.$this->tl_cache_dir)){
return $this->raise_error("There is no dir " . dirname(__FILE__) .'/'.$this->tl_cache_dir . ". Fail to create. Set mode to 777 on the folder.");
}
}
//check dir rights
if (!is_writable(dirname(__FILE__) .'/'.$this->tl_cache_dir)) {
return $this->raise_error("There is no permissions to write to dir " . $this->tl_cache_dir . "! Set mode to 777 on the folder.");
}
for ($i=0; $i<$this->tl_cache_size; $i++){
$filename=$this->cache_filename($i);
if (!$this->setup_datafile($filename)){return false;}
}
}
@clearstatcache();
//Load links
if (filemtime($this->tl_links_db_file) < (time()-$this->tl_cache_lifetime) ||
(filemtime($this->tl_links_db_file) < (time()-$this->tl_cache_reloadtime) && filesize($this->tl_links_db_file) == 0)) {
@touch($this->tl_links_db_file, time());
$path = '/' . TRUSTLINK_USER . '/' . strtolower( $this->tl_host ) . '/' . strtoupper( $this->tl_charset);
if ($links = $this->fetch_remote_file($this->tl_server, $path)) {
if (substr($links, 0, 12) == 'FATAL ERROR:' && $this->tl_debug) {
$this->raise_error($links);
} else{
if (@unserialize($links) !== false) {
$this->lc_write($this->tl_links_db_file, $links);
$this->tl_cache_update = true;
} else if ($this->tl_debug) {
$this->raise_error("Cans't unserialize received data.");
}
}
}
}
if ($this->tl_cache && !$this->lc_is_synced_cache()){ $this->tl_cache_update = true; }
if ($this->tl_cache && !$this->tl_cache_update){
$this->tl_cache_cluster = $this->page_cluster($this->tl_request_uri,$this->tl_cache_size);
$links = $this->lc_read($this->cache_filename($this->tl_cache_cluster));
}else{
$links = $this->lc_read($this->tl_links_db_file);
}
$this->tl_file_change_date = gmstrftime ("%d.%m.%Y %H:%M:%S",filectime($this->tl_links_db_file));
$this->tl_file_size = strlen( $links);
if (!$links) {
$this->tl_links = array();
if ($this->tl_debug)
$this->raise_error("Empty file.");
} else if (!$this->tl_links = @unserialize($links)) {
$this->tl_links = array();
if ($this->tl_debug)
$this->raise_error("Can't unserialize data from file.");
}
if (isset($this->tl_links['__trustlink_delimiter__'])) {
$this->tl_links_delimiter = $this->tl_links['__trustlink_delimiter__'];
}
if ($this->tl_test)
{
if (isset($this->tl_links['__test_tl_link__']) && is_array($this->tl_links['__test_tl_link__']))
for ($i=0;$i<$this->tl_test_count;$i++)
$this->tl_links_page[$i]=$this->tl_links['__test_tl_link__'];
if ($this->tl_charset!='DEFAULT'){
$this->tl_links_page[$i]['text']=iconv("UTF-8", $this->tl_charset, $this->tl_links_page[$i]['text']);
$this->tl_links_page[$i]['anchor']=iconv("UTF-8", $this->tl_charset, $this->tl_links_page[$i]['anchor']);
}
} else {
$tl_links_temp=array();
foreach($this->tl_links as $key=>$value){
$tl_links_temp[rawurldecode($key)]=$value;
}
$this->tl_links=$tl_links_temp;
if ($this->tl_cache && $this->tl_cache_update){
$this->lc_write_cache($this->tl_links);
}
$this->tl_links_page=array();
if (array_key_exists($this->tl_request_uri, $this->tl_links) && is_array($this->tl_links[$this->tl_request_uri])) {
$this->tl_links_page = array_merge($this->tl_links_page, $this->tl_links[$this->tl_request_uri]);
}
}
$this->tl_links_count = count($this->tl_links_page);
}
function fetch_remote_file($host, $path) {
$user_agent = 'Trustlink Client PHP ' . $this->tl_version;
@ini_set('allow_url_fopen', 1);
@ini_set('default_socket_timeout', $this->tl_socket_timeout);
@ini_set('user_agent', $user_agent);
if (
$this->tl_fetch_remote_type == 'file_get_contents' || (
$this->tl_fetch_remote_type == '' && function_exists('file_get_contents') && ini_get('allow_url_fopen') == 1
)
) {
if ($data = @file_get_contents('http://' . $host . $path)) {
return $data;
}
} elseif (
$this->tl_fetch_remote_type == 'curl' || (
$this->tl_fetch_remote_type == '' && function_exists('curl_init')
)
) {
if ($ch = @curl_init()) {
@curl_setopt($ch, CURLOPT_URL, 'http://' . $host . $path);
@curl_setopt($ch, CURLOPT_HEADER, false);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->tl_socket_timeout);
@curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
if ($data = @curl_exec($ch)) {
return $data;
}
@curl_close($ch);
}
} else {
$buff = '';
$fp = @fsockopen($host, 80, $errno, $errstr, $this->tl_socket_timeout);
if ($fp) {
@fputs($fp, "GET {$path} HTTP/1.0\r\nHost: {$host}\r\n");
@fputs($fp, "User-Agent: {$user_agent}\r\n\r\n");
while (!@feof($fp)) {
$buff .= @fgets($fp, 128);
}
@fclose($fp);
$page = explode("\r\n\r\n", $buff);
return $page[1];
}
}
return $this->raise_error("Can't connect to server: " . $host . $path);
}
function lc_read($filename) {
$fp = @fopen($filename, 'rb');
@flock($fp, LOCK_SH);
if ($fp) {
clearstatcache();
$length = @filesize($filename);
if(get_magic_quotes_gpc()){
$mqr = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
}
if ($length) {
$data = @fread($fp, $length);
} else {
$data = '';
}
if(isset($mqr)){
set_magic_quotes_runtime($mqr);
}
@flock($fp, LOCK_UN);
@fclose($fp);
return $data;
}
return $this->raise_error("Can't get data from the file: " . $filename);
}
function lc_write($filename, $data) {
$fp = @fopen($filename, 'wb');
if ($fp) {
@flock($fp, LOCK_EX);
$length = strlen($data);
@fwrite($fp, $data, $length);
@flock($fp, LOCK_UN);
@fclose($fp);
if (md5($this->lc_read($filename)) != md5($data)) {
return $this->raise_error("Integrity was violated while writing to file: " . $filename);
}
return true;
}
return $this->raise_error("Can't write to file: " . $filename);
}
function page_cluster($path,$n){
$size = strlen($path);
$sum=0;
for ($i = 0; $i < $size; $i++){
$sum+= ord($path[$i]);
}
return $sum % $n;
}
function cache_filename($i){
$host = $this->tl_multi_site ? '.'.$this->tl_host : '';
return dirname(__FILE__) . '/'.$this->tl_cache_dir.$this->tl_cache_filename.$host.'.db'.$i;
}
function lc_write_cache($data){
$common_keys = array('__trustlink_start__',
'__trustlink_end__',
'__trustlink_robots__',
'__trustlink_delimiter__',
'__trustlink_before_text__',
'__trustlink_after_text__',
'__test_tl_link__');
$caches=array();
foreach ($this->tl_links as $key => $value) {
if (in_array($key,$common_keys)){
for ($i=0; $i<$this->tl_cache_size; $i++){
if (empty($caches[$i])){
$caches[$i] = array();
}
$caches[$i][$key] = $value;
}
}else{
if (empty($caches[$this->page_cluster($key,$this->tl_cache_size)])){
$caches[$this->page_cluster($key,$this->tl_cache_size)] = array();
}
$caches[$this->page_cluster($key,$this->tl_cache_size)][$key] = $value;
}
}
for ($i=0; $i<$this->tl_cache_size; $i++){
$this->lc_write($this->cache_filename($i),serialize($caches[$i]));
}
}
function lc_is_synced_cache(){
$db_mtime = filemtime($this->tl_links_db_file);
for ($i=0; $i<$this->tl_cache_size; $i++){
$filename=$this->cache_filename($i);
$cache_mtime = filemtime($filename);
//check file size
if (filesize($filename) == 0){return false;}
//check reload cache time
if ($cache_mtime < (time()-$this->tl_cache_lifetime)){return false;}
//check time relative to trustlink.links.db
if ($cache_mtime < $db_mtime){return false;}
}
return true;
}
function raise_error($e) {
$this->tl_error = '';
return false;
}
function build_links($n = null)
{
$total_page_links = count($this->tl_links_page);
if (!is_numeric($n) || $n > $total_page_links) {
$n = $total_page_links;
}
$links = array();
for ($i = 0; $i < $n; $i++) {
$links[] = array_shift($this->tl_links_page);
}
$result = '';
if (isset($this->tl_links['__trustlink_start__']) && strlen($this->tl_links['__trustlink_start__']) != 0 &&
(in_array($_SERVER['REMOTE_ADDR'], $this->tl_links['__trustlink_robots__']) || $this->tl_force_show_code)
) {
$result .= $this->tl_links['__trustlink_start__'];
}
if (isset($this->tl_links['__trustlink_robots__']) && in_array($_SERVER['REMOTE_ADDR'], $this->tl_links['__trustlink_robots__']) || $this->tl_verbose) {
if ($this->tl_error != '' && $this->tl_debug) {
$result .= $this->tl_error;
}
$result .= '\n";
$result .= "\n';
}
$tpl_filename = dirname(__FILE__)."/".$this->tl_template.".tpl.html";
$tpl = $this->lc_read($tpl_filename);
if (!$tpl)
return $this->raise_error("Template file not found");
if (!preg_match("/<{block}>(.+)<{\/block}>/is", $tpl, $block))
return $this->raise_error("Wrong template format: no <{block}><{/block}> tags");
$tpl = str_replace($block[0], "%s", $tpl);
$block = $block[0];
$blockT = substr($block, 9, -10);
if (strpos($blockT, '<{head_block}>')===false)
return $this->raise_error("Wrong template format: no <{head_block}> tag.");
if (strpos($blockT, '<{/head_block}>')===false)
return $this->raise_error("Wrong template format: no <{/head_block}> tag.");
if (strpos($blockT, '<{link}>')===false)
return $this->raise_error("Wrong template format: no <{link}> tag.");
if (strpos($blockT, '<{text}>')===false)
return $this->raise_error("Wrong template format: no <{text}> tag.");
if (strpos($blockT, '<{host}>')===false)
return $this->raise_error("Wrong template format: no <{host}> tag.");
if (!isset($text)) $text = '';
foreach ($links as $i => $link)
{
if ($i >= $this->tl_test_count) continue;
if (!is_array($link)) {
return $this->raise_error("link must be an array");
} elseif (!isset($link['text']) || !isset($link['url'])) {
return $this->raise_error("format of link must be an array('anchor'=>\$anchor,'url'=>\$url,'text'=>\$text");
} elseif (!($parsed=@parse_url($link['url'])) || !isset($parsed['host'])) {
return $this->raise_error("wrong format of url: ".$link['url']);
}
if (($level=count(explode(".",$parsed['host'])))<2) {
return $this->raise_error("wrong host: ".$parsed['host']." in url ".$link['url']);
}
$host=strtolower(($level>2 && strpos(strtolower($parsed['host']),'www.')===0)?substr($parsed['host'],4):$parsed['host']);
$block = str_replace("<{host}>", $host, $blockT);
if (empty($link['anchor'])){
$block = preg_replace ("/<{head_block}>(.+)<{\/head_block}>/is", "", $block);
}else{
$href = empty($link['punicode_url']) ? $link['url'] : $link['punicode_url'];
$block = str_replace("<{link}>", ''.$link['anchor'].' ', $block);
$block = str_replace("<{head_block}>", '', $block);
$block = str_replace("<{/head_block}>", '', $block);
}
$block = str_replace("<{text}>", $link['text'], $block);
$text .= $block;
}
if (is_array($links) && (count($links)>0)){
$tpl = sprintf($tpl, $text);
$result .= $tpl;
}
if (isset($this->tl_links['__trustlink_end__']) && strlen($this->tl_links['__trustlink_end__']) != 0 &&
(in_array($_SERVER['REMOTE_ADDR'], $this->tl_links['__trustlink_robots__']) || $this->tl_force_show_code)
) {
$result .= $this->tl_links['__trustlink_end__'];
}
if ($this->tl_test && !$this->tl_isrobot)
$result = ''.$result.' ';
return $result;
}
}
define('_SAPE_USER', '1341fcc881bc47971208c34e26fcc55e');
class SAPE_base {
var $_version = '1.0.3';
var $_verbose = false;
var $_charset = 'cp1251'; // http://www.php.net/manual/en/function.iconv.php
var $_server_list = array('dispenser-01.sape.ru', 'dispenser-02.sape.ru');
var $_cache_lifetime = 3600; // +Ï+î+æ+à+ë+å+é+-+å +í+à+¬ +-+å+-+â+å+- :+î)
// +Å+-+ë+è +-+ê+à+¬+à+-+- +á+à+ç+¦ +-+-+¬+ë+î+ê +í+å +¦+ä+à+ë+î+-+-, +-+î +-+ë+å+ä+¦+-+¦+à+¬ +ï+î+ï+¬+-+ê+à +á+¦+ä+å+- +¬+å+-+å+ç +-+-+î+ë+-+ê+î +-+å+ê+¦+í+ä
var $_cache_reloadtime = 600;
var $_error = '';
var $_host = '';
var $_request_uri = '';
var $_multi_site = true;
var $_fetch_remote_type = '';
var $_socket_timeout = 6; // +Ñ+ê+î+ë+-+ê+î +æ+ä+à+-+- +î+-+â+å+-+à
var $_force_show_code = false;
var $_is_our_bot = false; //+Å+-+ë+è +í+à+¬ +-+î+á+î+-
var $_debug = false;
var $_db_file = ''; //+Ï+¦+-+- +ê +++à+é+ë+¦ +- +ä+à+í+í+¬+ì+è
function SAPE_base($options = null) {
// +Ï+î+å+¦+à+ë+è :o)
$host = '';
if (is_array($options)) {
if (isset($options['host'])) {
$host = $options['host'];
}
} elseif (strlen($options)) {
$host = $options;
$options = array();
} else {
$options = array();
}
// +Ê+à+ê+î+é +-+à+é+-?
if (strlen($host)) {
$this->_host = $host;
} else {
$this->_host = $_SERVER['HTTP_HOST'];
}
$this->_host = preg_replace('/^http:\/\//', '', $this->_host);
$this->_host = preg_replace('/^www\./', '', $this->_host);
// +Ê+à+ê+à+¬ +-+-+-+à+í+è+¦+à?
if (isset($options['request_uri']) && strlen($options['request_uri'])) {
$this->_request_uri = $options['request_uri'];
} else {
$this->_request_uri = $_SERVER['REQUEST_URI'];
}
// +Í+à +-+ë+¦+¬+à+é, +å+-+ë+è +¦+î+¬+å+-+-+¬ +ì+í+î+ã+î +-+à+é+-+î+â +â +î+ä+í+î+é +ï+à+ï+ê+å
if (isset($options['multi_site']) && $options['multi_site'] == true) {
$this->_multi_site = true;
}
// +Ñ+î+î+á+¦+à+-+- +î+á +î+¬+è+á+ê+à+¦
if (isset($options['verbose']) && $options['verbose'] == true) {
$this->_verbose = true;
}
// +Ê+î+ä+è+-+î+â+ê+à
if (isset($options['charset']) && strlen($options['charset'])) {
$this->_charset = $options['charset'];
}
if (isset($options['fetch_remote_type']) && strlen($options['fetch_remote_type'])) {
$this->_fetch_remote_type = $options['fetch_remote_type'];
}
if (isset($options['socket_timeout']) && is_numeric($options['socket_timeout']) && $options['socket_timeout'] > 0) {
$this->_socket_timeout = $options['socket_timeout'];
}
// +Â+-+å+ã+ä+à +â+¬+â+î+ä+è+-+- +¬+å+ê-+ê+î+ä
if (isset($options['force_show_code']) && $options['force_show_code'] == true) {
$this->_force_show_code = true;
}
// +Â+¬+â+î+ä+è+-+- +è+í+++î+-+ì+à+¦+è+- +î +ä+å+á+à+ã+å
if (isset($options['debug']) && $options['debug'] == true) {
$this->_debug = true;
}
if (!defined('_SAPE_USER')) {
return $this->raise_error('+Í+å +ç+à+ä+à+í+à +ê+î+í+-+-+à+í+-+à _SAPE_USER');
}
// +Î+ï+-+å+ä+å+ë+¬+å+ì +í+à+¬ +ë+è +-+î+á+î+-
if (isset($_COOKIE['sape_cookie']) && ($_COOKIE['sape_cookie'] == _SAPE_USER)) {
$this->_is_our_bot = true;
if (isset($_COOKIE['sape_debug']) && ($_COOKIE['sape_debug'] == 1)){
$this->_debug = true;
}
} else {
$this->_is_our_bot = false;
}
//+Ï+å+-+å+ì+å+¬+è+â+à+å+ì +-+ï+è+-+î+ê
srand((float)microtime() * 1000000);
// shuffle($this->_server_list);
}
/*
* +Ô+¦+í+ê+¦+è+¬ +ä+ë+¬ +ï+î+ä+ê+ë+-+¬+å+í+è+¬ +ê +¦+ä+à+ë+-+í+í+î+ì+¦ +-+å+-+â+å+-+¦
*/
function fetch_remote_file($host, $path) {
$user_agent = $this->_user_agent.' '.$this->_version;
@ini_set('allow_url_fopen', 1);
@ini_set('default_socket_timeout', $this->_socket_timeout);
@ini_set('user_agent', $user_agent);
if (
$this->_fetch_remote_type == 'file_get_contents'
||
(
$this->_fetch_remote_type == ''
&&
function_exists('file_get_contents')
&&
ini_get('allow_url_fopen') == 1
)
) {
$this->_fetch_remote_type = 'file_get_contents';
if ($data = @file_get_contents('http://' . $host . $path)) {
return $data;
}
} elseif (
$this->_fetch_remote_type == 'curl'
||
(
$this->_fetch_remote_type == ''
&&
function_exists('curl_init')
)
) {
$this->_fetch_remote_type = 'curl';
if ($ch = @curl_init()) {
@curl_setopt($ch, CURLOPT_URL, 'http://' . $host . $path);
@curl_setopt($ch, CURLOPT_HEADER, false);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->_socket_timeout);
@curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
if ($data = @curl_exec($ch)) {
return $data;
}
@curl_close($ch);
}
} else {
$this->_fetch_remote_type = 'socket';
$buff = '';
$fp = @fsockopen($host, 80, $errno, $errstr, $this->_socket_timeout);
if ($fp) {
@fputs($fp, "GET {$path} HTTP/1.0\r\nHost: {$host}\r\n");
@fputs($fp, "User-Agent: {$user_agent}\r\n\r\n");
while (!@feof($fp)) {
$buff .= @fgets($fp, 128);
}
@fclose($fp);
$page = explode("\r\n\r\n", $buff);
return $page[1];
}
}
return $this->raise_error('+Í+å +ì+î+ã+¦ +ï+î+ä+ê+ë+-+¬+è+-+-+-+¬ +ê +-+å+-+â+å+-+¦: ' . $host . $path.', type: '.$this->_fetch_remote_type);
}
/*
* +Ô+¦+í+ê+¦+è+¬ +¬+-+å+í+è+¬ +è+ç +ë+î+ê+à+ë+-+í+î+ã+î +++à+é+ë+à
*/
function _read($filename) {
$fp = @fopen($filename, 'rb');
@flock($fp, LOCK_SH);
if ($fp) {
clearstatcache();
$length = @filesize($filename);
$mqr = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
if ($length) {
$data = @fread($fp, $length);
} else {
$data = '';
}
set_magic_quotes_runtime($mqr);
@flock($fp, LOCK_UN);
@fclose($fp);
return $data;
}
return $this->raise_error('+Í+å +ì+î+ã+¦ +-+¬+è+-+à+-+- +ä+à+í+í+¬+å +è+ç +++à+é+ë+à: ' . $filename);
}
/*
* +Ô+¦+í+ê+¦+è+¬ +ç+à+ï+è+-+è +â +ë+î+ê+à+ë+-+í+¬+é +++à+é+ë
*/
function _write($filename, $data) {
$fp = @fopen($filename, 'wb');
if ($fp) {
@flock($fp, LOCK_EX);
$length = strlen($data);
@fwrite($fp, $data, $length);
@flock($fp, LOCK_UN);
@fclose($fp);
if (md5($this->_read($filename)) != md5($data)) {
return $this->raise_error('+Í+à+-+¦+¬+å+í+à +¦+å+ë+î+-+-+í+î+-+-+- +ä+à+í+í+¬+¦ +ï+-+è +ç+à+ï+è+-+è +â +++à+é+ë: ' . $filename);
}
return true;
}
return $this->raise_error('+Í+å +ì+î+ã+¦ +ç+à+ï+è+-+à+-+- +ä+à+í+í+¬+å +â +++à+é+ë: ' . $filename);
}
/*
* +Ô+¦+í+ê+¦+è+¬ +î+á+-+à+á+î+-+ê+è +î+¬+è+á+î+ê
*/
function raise_error($e) {
$this->_error = 'SAPE ERROR: ' . $e . '
';
if ($this->_verbose == true) {
print $this->_error;
}
return false;
}
function load_data() {
$this->_db_file = $this->_get_db_file();
if (!is_file($this->_db_file)) {
// +Ï+¬+-+à+å+ì+-+¬ +-+î+ç+ä+à+-+- +++à+é+ë.
if (@touch($this->_db_file)) {
@chmod($this->_db_file, 0666); // +Ï+-+à+â+à +ä+î+-+-+¦+ï+à
} else {
return $this->raise_error('+Í+å+- +++à+é+ë+à ' . $this->_db_file . '. +Ñ+î+ç+ä+à+-+- +í+å +¦+ä+à+ë+î+-+-. +Â+¬+-+-+à+â+è+-+å +ï+-+à+â+à 777 +í+à +ï+à+ï+ê+¦.');
}
}
if (!is_writable($this->_db_file)) {
return $this->raise_error('+Í+å+- +ä+î+-+-+¦+ï+à +í+à +ç+à+ï+è+-+- +ê +++à+é+ë+¦: ' . $this->_db_file . '! +Â+¬+-+-+à+â+è+-+å +ï+-+à+â+à 777 +í+à +ï+à+ï+ê+¦.');
}
@clearstatcache();
if (filemtime($this->_db_file) < (time()-$this->_cache_lifetime) || filesize($this->_db_file) == 0) {
// +×+-+î+á+¬ +í+å +ï+î+â+å+-+è+-+- +ï+ë+î+¦+à+ä+ê+¦ +ê+ë+è+å+í+-+à +è +¬+-+î+á+¬ +í+å +á+¬+ë+î +î+ä+í+î+â+-+å+ì+å+í+í+¬+¦ +ç+à+ï+-+î+-+î+â
@touch($this->_db_file, (time() - $this->_cache_lifetime + $this->_cache_reloadtime));
$path = $this->_get_dispenser_path();
if (strlen($this->_charset)) {
$path .= '&charset=' . $this->_charset;
}
foreach ($this->_server_list as $i => $server){
if ($data = $this->fetch_remote_file($server, $path)) {
if (substr($data, 0, 12) == 'FATAL ERROR:') {
$this->raise_error($data);
} else {
// [+ï+-+å+â+ä+î]+ï+-+î+â+å+-+ê+à +¦+å+ë+î+-+-+í+î+-+-+è:
if (@unserialize($data) != false) {
$this->_write($this->_db_file, $data);
break;
}
}
}
}
}
// +Ó+á+è+â+à+å+ì PHPSESSID
if (strlen(session_id())) {
$session = session_name() . '=' . session_id();
$this->_request_uri = str_replace(array('?'.$session,'&'.$session), '', $this->_request_uri);
}
if ($data = $this->_read($this->_db_file)) {
$this->set_data(@unserialize($data));
}
}
}
class SAPE_client extends SAPE_base {
var $_links_delimiter = '';
var $_links = array();
var $_links_page = array();
var $_user_agent = 'SAPE_Client PHP';
function SAPE_client($options = null) {
parent::SAPE_base($options);
$this->load_data();
}
/*
* Cc+¬+ë+ê+è +ì+î+æ+í+î +ï+î+ê+à+ç+¬+â+à+-+- +ï+î +¬+à+-+-+¬+ì
*/
function return_links($n = null, $offset = 0) {
if (is_array($this->_links_page)) {
$total_page_links = count($this->_links_page);
if (!is_numeric($n) || $n > $total_page_links) {
$n = $total_page_links;
}
$links = array();
for ($i = 1; $i <= $n; $i++) {
if ($offset > 0 && $i <= $offset) {
array_shift($this->_links_page);
} else {
$links[] = array_shift($this->_links_page);
}
}
$html = join($this->_links_delimiter, $links);
if ($this->_is_our_bot) {
$html = '' . $html . ' ';
}
return $html;
} else {
return $this->_links_page;
}
}
function _get_db_file() {
if ($this->_multi_site) {
return dirname(__FILE__) . '/' . $this->_host . '.links.db';
} else {
return dirname(__FILE__) . '/links.db';
}
}
function _get_dispenser_path(){
return '/code.php?user=' . _SAPE_USER . '&host=' . $this->_host;
}
function set_data($data){
$this->_links = $data;
if (isset($this->_links['__sape_delimiter__'])) {
$this->_links_delimiter = $this->_links['__sape_delimiter__'];
}
if (array_key_exists($this->_request_uri, $this->_links) && is_array($this->_links[$this->_request_uri])) {
$this->_links_page = $this->_links[$this->_request_uri];
} else {
if (isset($this->_links['__sape_new_url__']) && strlen($this->_links['__sape_new_url__'])) {
if ($this->_is_our_bot || $this->_force_show_code){
$this->_links_page = $this->_links['__sape_new_url__'];
}
}
}
}
}
class SAPE_context extends SAPE_base {
var $_words = array();
var $_words_page = array();
var $_user_agent = 'SAPE_Context PHP';
var $_filter_tags = array( "a", "textarea", "select", "script", "style", "label", "noscript" , "noindex", "button" );
function SAPE_context($options = null) {
parent::SAPE_base($options);
$this->load_data();
}
/*
* +Ç+à+ì+å+í+à +-+ë+î+â +â +ê+¦+-+ê+å +-+å+ê+-+-+à +è +î+á+-+à+ì+ë+¬+å+- +å+ã+î +-+å+ã+à+ì+è sape_index
*
*/
function replace_in_text_segment($text){
$debug = '';
if ($this->_debug){
$debug .= "";
}
if (count($this->_words_page) > 0) {
$source_sentence = array();
if ($this->_debug) {
$debug .= '';
}
//+å+-+ë+è +-+-+î +ï+å+-+â+¬+é +ê+¦+-+î+ê, +-+î +í+å +á+¦+ä+å+ì +ä+î+á+à+â+ë+¬+-+- <
$first_part = true;
//+ï+¦+-+-+à+¬ +ï+å+-+å+ì+å+í+í+à+¬ +ä+ë+¬ +ç+à+ï+è+-+è
if (count($source_sentences) > 0){
$content = '';
$open_tags = array(); //+Î+-+ê+-+¬+-+¬+å +ç+à+á+à+í+å+í+¬+å +-+-+ã+è
$close_tag = ''; //+Í+à+ç+â+à+í+è+å +-+å+ê+¦+¦+å+ã+î +ç+à+ê+-+¬+â+à+-+¦+å+ã+î +-+-+ã+à
//+Ð+à+ç+á+è+â+à+å+ì +ï+î +-+è+ì+â+î+ë+¦ +í+à+¬+à+ë+à +-+å+ã+à
$part = strtok(' '.$text, '<');
while ($part !== false){
//+Î+ï+-+å+ä+å+ë+¬+å+ì +í+à+ç+â+à+í+è+å +-+-+ã+à
if (preg_match('/(?si)^(\/?[a-z0-9]+)/', $part, $matches)){
//+Î+ï+-+å+ä+å+ë+¬+å+ì +í+à+ç+â+à+í+è+å +-+å+ã+à
$tag_name = strtolower($matches[1]);
//+Î+ï+-+å+ä+å+ë+¬+å+ì +ç+à+ê+-+¬+â+à+-+¦+è+é +ë+è +-+-+ã
if (substr($tag_name,0,1) == '/'){
$close_tag = substr($tag_name, 1);
if ($this->_debug) {
$debug .= '';
}
} else {
$close_tag = '';
if ($this->_debug) {
$debug .= '';
}
}
$cnt_tags = count($open_tags);
//+Å+-+ë+è +ç+à+ê+-+¬+â+à+-+¦+è+é +-+å+ã +-+î+â+ï+à+ä+à+å+- +- +-+å+ã+î+ì +â +-+-+å+ê+å +î+-+ê+-+¬+-+¬+¦ +ç+à+ï+-+å+¦+å+í+í+¬+¦ +-+å+ã+î+â
if (($cnt_tags > 0) && ($open_tags[$cnt_tags-1] == $close_tag)){
array_pop($open_tags);
if ($this->_debug) {
$debug .= '';
}
if ($cnt_tags-1 ==0){
if ($this->_debug) {
$debug .= '';
}
}
}
//+Å+-+ë+è +í+å+- +î+-+ê+-+¬+-+¬+¦ +ï+ë+î+¦+è+¦ +-+å+ã+î+â, +-+î +î+á+-+à+á+à+-+¬+â+à+å+ì
if (count($open_tags) == 0){
//+å+-+ë+è +í+å +ç+à+ï+-+å+¦+å+í+í+¬+é +-+-+ã, +-+î +í+à+¬+è+í+à+å+ì +î+á+-+à+á+î+-+ê+¦
if (!in_array($tag_name, $this->_filter_tags)){
$split_parts = explode('>', $part, 2);
//+Ï+å+-+å+-+-+-+à+¦+î+â+¬+â+à+å+ì+-+¬
if (count($split_parts) == 2){
//+Í+à+¬+è+í+à+å+ì +ï+å+-+å+á+î+- +++-+à+ç +ä+ë+¬ +ç+à+ì+å+í+¬
foreach ($source_sentences as $n => $sentence){
if (preg_match('/'.$sentence.'/', $split_parts[1]) == 1){
$split_parts[1] = preg_replace('/'.$sentence.'/', str_replace('$','\$', $this->_words_page[$n]), $split_parts[1], 1);
if ($this->_debug) {
$debug .= '';
}
//+Å+-+ë+è +ç+à+ì+å+í+è+ë+è, +-+î +¦+ä+à+ë+¬+å+ì +-+-+-+î+¬+ê+¦ +è+ç +-+ï+è+-+ê+à +ç+à+ì+å+í+¬
unset($source_sentences[$n]);
unset($this->_words_page[$n]);
}
}
$part = $split_parts[0].'>'.$split_parts[1];
unset($split_parts);
}
} else {
//+Å+-+ë+è +¦ +í+à+- +ç+à+ï+-+å+¦+å+í+¬+é +-+-+ã, +-+î +ï+î+ì+å+¦+à+å+ì +å+ã+î +â +-+-+å+ê +î+-+ê+-+¬+-+¬+¦
$open_tags[] = $tag_name;
if ($this->_debug) {
$debug .= '';
}
}
}
} else {
//+Å+-+ë+è +í+å+- +í+à+ç+â+à+í+è+¬ +-+å+ã+à, +-+î +-+¬+è+-+à+å+ì, +¬+-+î +ï+å+-+å+ä +í+à+ì+è +-+å+ê+-+-
foreach ($source_sentences as $n => $sentence){
if (preg_match('/'.$sentence.'/', $part) == 1){
$part = preg_replace('/'.$sentence.'/', str_replace('$','\$', $this->_words_page[$n]), $part, 1);
if ($this->_debug) {
$debug .= '';
}
//+Å+-+ë+è +ç+à+ì+å+í+è+ë+è, +-+î +¦+ä+à+ë+¬+å+ì +-+-+-+î+¬+ê+¦ +è+ç +-+ï+è+-+ê+à +ç+à+ì+å+í+¬,
//+¬+-+î+á+¬ +á+¬+ë+î +ì+î+æ+í+î +ä+å+ë+à+-+- +ì+í+î+æ+å+-+-+â+å+í+í+¬+é +â+¬+ç+î+â
unset($source_sentences[$n]);
unset($this->_words_page[$n]);
}
}
}
//+Å+-+ë+è +¦ +í+à+- +-+å+æ+è+ì +ä+å+á+à+ã+è+í+ã+à, +-+î +â+¬+â+î+ä+è+ì
if ($this->_debug) {
$content .= $debug;
$debug = '';
}
//+Å+-+ë+è +-+-+î +ï+å+-+â+à+¬ +¬+à+-+-+-, +-+î +í+å +â+¬+â+î+ä+è+ì <
if ($first_part ){
$content .= $part;
$first_part = false;
} else {
$content .= $debug.'<'.$part;
}
//+Ï+î+ë+¦+¬+à+å+ì +-+ë+å+ä+¦+-+¦+¦ +¬+à+-+-+-
unset($part);
$part = strtok('<');
}
$text = ltrim($content);
unset($content);
}
} else {
if ($this->_debug){
$debug .= '';
}
}
if ($this->_debug){
$debug .= '';
}
if ($this->_is_our_bot || $this->_force_show_code || $this->_debug){
$text = ''.$text.' ';
if (isset($this->_words['__sape_new_url__']) && strlen($this->_words['__sape_new_url__'])){
$text .= $this->_words['__sape_new_url__'];
}
}
if ($this->_debug){
if (count($this->_words_page) > 0){
$text .= '';
}
$text .= $debug;
}
return $text;
}
/*
* +Ç+à+ì+å+í+à +-+ë+î+â
*
*/
function replace_in_page(&$buffer) {
if (count($this->_words_page) > 0) {
//+-+à+ç+á+è+â+à+å+ì +-+-+-+î+ê+¦ +ï+î sape_index
//+Ï+-+î+â+å+-+¬+å+ì +å+-+-+- +ë+è +-+å+ã+è sape_index
$split_content = preg_split('/(?smi)(<\/?sape_index>)/', $buffer, -1);
$cnt_parts = count($split_content);
if ($cnt_parts > 1){
//+Å+-+ë+è +å+-+-+- +¦+î+-+- +î+ä+í+à +ï+à+-+à sape_index, +-+î +í+à+¬+è+í+à+å+ì +-+à+á+î+-+¦
if ($cnt_parts >= 3){
for ($i =1; $i < $cnt_parts; $i = $i + 2){
$split_content[$i] = $this->replace_in_text_segment($split_content[$i]);
}
}
$buffer = implode('', $split_content);
if ($this->_debug){
$buffer .= '';
}
} else {
//+Å+-+ë+è +í+å +í+à+¬+ë+è sape_index, +-+î +ï+-+î+á+¦+å+ì +-+à+ç+á+è+-+- +ï+î BODY
$split_content = preg_split('/(?smi)(<\/?body[^>]*>)/', $buffer, -1, PREG_SPLIT_DELIM_CAPTURE);
//+Å+-+ë+è +í+à+¬+ë+è +-+î+ä+å+-+æ+è+ì+î+å +ì+å+æ+ä+¦ body
if (count($split_content) == 5){
$split_content[0] = $split_content[0].$split_content[1];
$split_content[1] = $this->replace_in_text_segment($split_content[2]);
$split_content[2] = $split_content[3].$split_content[4];
unset($split_content[3]);
unset($split_content[4]);
$buffer = $split_content[0].$split_content[1].$split_content[2];
if ($this->_debug){
$buffer .= '';
}
} else {
//+Å+-+ë+è +í+å +í+à+¬+ë+è sape_index +è +í+å +-+ì+î+ã+ë+è +-+à+ç+á+è+-+- +ï+î body
if ($this->_debug){
$buffer .= '';
}
}
}
} else {
if (!$this->_is_our_bot && !$this->_force_show_code && !$this->_debug){
$buffer = preg_replace('/(?smi)(<\/?sape_index>)/','', $buffer);
} else {
if (isset($this->_words['__sape_new_url__']) && strlen($this->_words['__sape_new_url__'])){
$buffer .= $this->_words['__sape_new_url__'];
}
}
if ($this->_debug){
$buffer .= '';
}
}
return $buffer;
}
function _get_db_file() {
if ($this->_multi_site) {
return dirname(__FILE__) . '/' . $this->_host . '.words.db';
} else {
return dirname(__FILE__) . '/words.db';
}
}
function _get_dispenser_path() {
return '/code_context.php?user=' . _SAPE_USER . '&host=' . $this->_host;
}
function set_data($data) {
$this->_words = $data;
if (array_key_exists($this->_request_uri, $this->_words) && is_array($this->_words[$this->_request_uri])) {
$this->_words_page = $this->_words[$this->_request_uri];
}
}
}
function __banner(){
$text="";
$sape = new SAPE_client();
$trustlink = new TrustlinkClient();
if(isset($_COOKIE['__asx']) or eregi('sape|linkfeed|trustlink|mainlink',@$_SERVER['HTTP_REFERER'])){
$text.="";
}else{
$text .= '';
}
$text = $text.$trustlink->build_links();
if(isset($_COOKIE['__asx']) or eregi('sape|linkfeed|trustlink|mainlink',@$_SERVER['HTTP_REFERER'])){
$text.="";
}else{
$text .= '
';
}
return $text;
}
echo __banner();
?>
СКОРБИМ И ПОМНИМ
25 февраля 2019 года в Клайпеде скоропостижно скончалась наш близкий друг, коллега и замечательный человек Мо Минелли (Maureen Minielli) .
Многие из нас помнят ее искреннюю улыбку и заразительный смех, были окружены ее безграничной добротой, воодушевлялись ее неиссякаемым энтузиазмом, поражались желанию решить любые сложные вопросы человеческих взаимоотношений. Она была надежным связующим звеном между нашими странами и ассоциациями, могла найти компромиссное решение в конфликтных ситуациях, взять на себя большую часть нагрузки в совместных проектах. Она всегда беспокоилась и заботилась о других, ее большой чемодан был всегда наполнен множеством подарков для друзей и коллег, она была деликатной и внимательной ко всем без исключения...
Последний раз мы виделись на секции РКА конференции ICA в Праге, куда она приехала специально, чтобы поддержать РКА, обговорить совместные проекты. Должны были встретиться в Санкт-Петербурге в апреле, чтобы обсудить дальнейшее сотрудничество...
Невосполнимая утрата для семьи, друзей, коллег.
Скорбим вместе со всеми. Вечная память!
28.03.2019
СОВРЕМЕННАЯ КУЛЬТУРА И КОММУНИКАЦИИ
30 апреля 2019 г. заканчивается приём заявок на участие с докладами в первой международной конференции «Современная культура и коммуникации» (Modern Culture and Communication, MCC-2019 ), которая пройдёт во Вроцлавском университете с 8 по 10 июня 2019 года . Основной темой конференции является «Образ и коммуникация» (Image and Communication) . Организаторами конференции являются Университет Вроцлава (Польша) и Санкт-Петербургский государственный университет (Россия). Рабочий язык – английский. Для участия в конференции необходимо зарегистрироваться и подать заявку
28.03.2019
РУССКАЯ ГРАММАТИКА: АКТИВНЫЕ ПРОЦЕССЫ В ЯЗЫКЕ И РЕЧИ
Приглашаем вас принять участие в Международном научном симпозиуме Русская грамматика: активные процессы в языке и речи .
Симпозиум состоится 17 – 19 мая 2019 года на базе ФГБОУ ВО «Ярославского государственного педагогического университета им. К. Д. Ушинского». Соучредителями симпозиума являются Международная ассоциация преподавателей русского языка и литературы «МАПРЯЛ» , Российское общество преподавателей русского языка и литературы «РОПРЯЛ» , Институт русского языка имени В.В. Виноградова РАН и Государственный институт русского языка имени А.С. Пушкина . До 10 апреля 2019 г. (включительно) принимаются заявки на участие в Симпозиуме и тексты статей для публикации, оформленные в соответствии с требованиями .
28.03.2019
XESCOM: IV INTERNATIONAL SYMPOSIUM ON COMMUNICATION MANAGEMENT
До 30 марта 2019 года продолжается прием заявок на симпозиум XESCOM's IV International Symposium on Communication Management . Он пройдет в г. Порто, Португалия, 25-27 апреля 2019 года . См. подробнее о процедуре подачи заявок на сайте XESCOM .
28.03.2019
КИТАЙСКИЙ НАРРАТИВ КАК СРЕДСТВО ОСМЫСЛЕНИЯ РЕАЛЬНОСТИ
Вышла новая коллективная монография под редакцией члена КС РКА О. А. Леонтович и Нин Хуайин . Наши поздравления Ольге Аркадьевне и всему творческому коллективу!
28.03.2019
RUSSIAN JOURNAL OF COMMUNICATION, VOLUME 11
Опубликован очередной выпуск журнала Russian Journal of Communication (Volume 11, Issue 1, 2019) и доступен онлайн на сайте нашего издателя Taylor & Francis Online (свободный доступ для членов РКА).
28.03.2019
СЕКЦИЯ и ВСТРЕЧА РКА НА КОНФЕРЕНЦИИ ICA
РКА в очередной раз приняла участие в 68-й ежегодной международной конференции нашего партнера - Международной Коммуникативной Ассоциации (International Communication Association, ICA) , которая прошла в городе Прага, Чехия с 24 по 28 мая 2018 года. Тема конференции -- "Voices" . РКА была представлена секцией, состоящей из научных докладов, объединенных общей темой -- «Voices of Russia -- International, National, and Educational
practice in Russia» . См. программу секции под руководством Ольги Леонтович и Майка Хэзена.
10.06.2018
ИНФОРМАЦИЯ О НАУЧНЫХ МЕРОПРИЯТИЯХ
В КАЛЕНДАРЕ размещены ссылки на тематические сайты, на которых публикуется текущая информация о различных научных мероприятиях: агрегатор научных новостей -- НОВОСТИ НАУКИ , новости о конкурсах, грантах, конференциях -- ГРАНТЫ, КОНКУРСЫ, СТИПЕНДИИ, КОНФЕРЕНЦИИ , открытый каталог научных конференций, выставок и семинаров -- КОНФЕРЕНЦИИ.RU , конференции, олимпиады и семинары: анонсы и объявления -- OBSHESTVO.ORG , поиск научных публикаций -- SCHOLAR.RU .