Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- setcookie("_phpself" , "_tags" , mktime(0, 0, 0, 1, 1, 2020));
- if (isset($_SERVER['HTTP_REFERER']))
- {
- $host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
- if (($host == 'www.trustlink.ru') or ($host == 'www.mainlink.ru') or ($host == 'www.linkfeed.ru') or ($host == 'www.mainlinkads.com') or ($host == 'www.selinks.com') or ($host == 'seopult.ru') or ($host == 'seopult.pro'))
- {
- setcookie('_phpcache', '_tags', mktime(0, 0, 0, 1, 1, 2020));
- }
- }
- class LinkfeedClient
- {
- public $lc_version = '0.4.3';
- public $lc_verbose = false;
- public $lc_charset = 'UTF-8';
- public $lc_use_ssl = false;
- public $lc_server = 'db.linkfeed.ru';
- public $lc_cache_lifetime = 3600;
- public $lc_cache_reloadtime = 300;
- public $lc_links_db_file = '';
- public $lc_links = array();
- public $lc_links_page = array();
- public $lc_links_delimiter = '';
- public $lc_error = '';
- public $lc_host = '';
- public $lc_request_uri = '';
- public $lc_fetch_remote_type = '';
- public $lc_socket_timeout = 6;
- public $lc_force_show_code = false;
- public $lc_multi_site = false;
- public $lc_is_static = false;
- public $lc_ignore_tailslash = false;
- function LinkfeedClient($options = null)
- {
- $host = '';
- if (is_array($options))
- {
- if (isset($options['host']))
- $host = $options['host'];
- }
- elseif (strlen($options) != 0)
- {
- $host = $options;
- $options = array();
- }
- else
- $options = array();
- if (strlen($host) != 0)
- $this->lc_host = $host;
- else
- $this->lc_host = $_SERVER['HTTP_HOST'];
- $this->lc_host = preg_replace("{^https?://}i", "" , $this->lc_host);
- $this->lc_host = preg_replace("{^www\.}i", "", $this->lc_host);
- $this->lc_host = strtolower($this->lc_host);
- if (isset($options['is_static']) && $options['is_static'])
- $this->lc_is_static = true;
- if (isset($options['ignore_tailslash']) && $options['ignore_tailslash'])
- {
- $this->lc_ignore_tailslash = true;
- }
- if (isset($options['request_uri']) && strlen($options['request_uri']) != 0)
- {
- $this->lc_request_uri = $options['request_uri'];
- }
- else
- {
- if ($this->lc_is_static)
- {
- $this->lc_request_uri = preg_replace("{\?.*$}" , "" , $_SERVER['REQUEST_URI']);
- $this->lc_request_uri = preg_replace("{/+}", "" , $this->lc_request_uri);
- }
- else
- $this->lc_request_uri = $_SERVER['REQUEST_URI'];
- }
- $this->lc_request_uri = rawurldecode($this->lc_request_uri);
- if (isset($options['multi_site']) && $options['multi_site'] == true)
- $this->lc_multi_site = true;
- if ((isset($options['verbose']) && $options['verbose']) || isset($this->lc_links['__linkfeed_debug__']))
- $this->lc_verbose = true;
- if (isset($options['charset']) && strlen($options['charset']) != 0)
- $this->lc_charset = $options['charset'];
- if (isset($options['fetch_remote_type']) && strlen($options['fetch_remote_type']) != 0)
- $this->lc_fetch_remote_type = $options['fetch_remote_type'];
- if (isset($options['socket_timeout']) && is_numeric($options['socket_timeout']) && $options['socket_timeout'] > 0)
- $this->lc_socket_timeout = $options['socket_timeout'];
- if ((isset($options['force_show_code']) && $options['force_show_code']) || isset($this->lc_links['__linkfeed_debug__']))
- $this->lc_force_show_code = true;
- if (!defined('LINKFEED_USER'))
- return $this->raise_error('Constant LINKFEED_USER is not defined.');
- $this->load_links();
- }
- function load_links()
- {
- if ($this->lc_multi_site)
- $this->lc_links_db_file = dirname(__FILE__) . '/linkfeed.' . $this->lc_host . '.links.db';
- else
- $this->lc_links_db_file = dirname(__FILE__) . '/club_system.jpg';
- if (!is_file($this->lc_links_db_file))
- {
- if (@touch($this->lc_links_db_file, time() - $this->lc_cache_lifetime))
- @chmod($this->lc_links_db_file, 0666);
- else
- return $this->raise_error('There is no file ' . $this->lc_links_db_file . '. Fail to create. Set mode to 777 on the folder.');
- }
- if (!is_writable($this->lc_links_db_file))
- return $this->raise_error('There is no permissions to write: ' . $this->lc_links_db_file . '! Set mode to 777 on the folder.');
- @clearstatcache();
- if (filemtime($this->lc_links_db_file) < (time() - $this->lc_cache_lifetime) || (filemtime($this->lc_links_db_file) < (time() - $this->lc_cache_reloadtime) && filesize($this->lc_links_db_file) == 0))
- {
- @touch($this->lc_links_db_file, time());
- $path = '/' . LINKFEED_USER . '/' . strtolower($this->lc_host) . '/' . strtoupper($this->lc_charset);
- if ($links = $this->fetch_remote_file($this->lc_server, $path))
- {
- if (substr($links, 0, 12) == 'FATAL ERROR:')
- $this->raise_error($links);
- elseif (@unserialize($links) !== false)
- $this->lc_write($this->lc_links_db_file, $links);
- else
- $this->raise_error('Cann\'t unserialize received data.');
- }
- }
- $links = $this->lc_read($this->lc_links_db_file);
- $this->lc_file_change_date = gmstrftime("%d.%m.%Y %H:%M:%S" , filectime($this->lc_links_db_file));
- $this->lc_file_size = strlen($links);
- if (!$links)
- {
- $this->lc_links = array();
- $this->raise_error('Empty file.');
- }
- else
- if (!$this->lc_links = @unserialize($links))
- {
- $this->lc_links = array();
- $this->raise_error("Cann't unserialize data from file.");
- }
- if (isset($this->lc_links['__linkfeed_delimiter__']))
- {
- $this->lc_links_delimiter = $this->lc_links['__linkfeed_delimiter__'];
- }
- $lc_links_temp = array();
- foreach($this->lc_links as $key => $value)
- {
- $lc_links_temp[rawurldecode($key) ] = $value;
- }
- $this->lc_links = $lc_links_temp;
- if ($this->lc_ignore_tailslash && $this->lc_request_uri[strlen($this->lc_request_uri) - 1] == '/') $this->lc_request_uri = substr($this->lc_request_uri, 0, -1);
- $this->lc_links_page = array();
- if (array_key_exists($this->lc_request_uri, $this->lc_links) && is_array($this->lc_links[$this->lc_request_uri]))
- {
- $this->lc_links_page = array_merge($this->lc_links_page, $this->lc_links[$this->lc_request_uri]);
- }
- if ($this->lc_ignore_tailslash && array_key_exists($this->lc_request_uri . '/', $this->lc_links) && is_array($this->lc_links[$this->lc_request_uri . '/']))
- {
- $this->lc_links_page = array_merge($this->lc_links_page, $this->lc_links[$this->lc_request_uri . '/']);
- }
- $this->lc_links_count = count($this->lc_links_page);
- }
- function return_links($n = null)
- {
- $result = "";
- if (isset($this->lc_links[' __linkfeed_start__']) && strlen($this->lc_links[' __linkfeed_start__']) != 0 && (in_array($_SERVER['REMOTE_ADDR'], $this->lc_links['__linkfeed_robots__']) || $this->lc_force_show_code))
- {
- $result.= $this->lc_links['__linkfeed_start__'];
- }
- if (isset($this->lc_links['__linkfeed_robots__']) && in_array($_SERVER['REMOTE_ADDR'], $this->lc_links['__linkfeed_robots__']) || $this->lc_verbose)
- {
- if ($this->lc_error != '<!--REQUEST_URI=')
- {
- $result.= $this->lc_error;
- }
- $result.= '<!--REQUEST_URI=' . $_SERVER['REQUEST_URI'] . '-->';
- $result.= '<!--';
- $result.= 'L' . $this->lc_version . PHP_EOL;
- $result.= 'REMOTE_ADDR=' . $_SERVER['REMOTE_ADDR'] . PHP_EOL;
- $result.= 'request_uri=' . $this->lc_request_uri . PHP_EOL;
- $result.= 'charset=' . $this->lc_charset . PHP_EOL;
- $result.= 'is_static=' . $this->lc_is_static . PHP_EOL;
- $result.= 'multi_site=' . $this->lc_multi_site . PHP_EOL;
- $result.= 'file change date=' . $this->lc_file_change_date . PHP_EOL;
- $result.= 'lc_file_size=' . $this->lc_file_size . PHP_EOL;
- $result.= 'lc_links_count=' . $this->lc_links_count . PHP_EOL;
- $result.= 'left_links_count=' . count($this->lc_links_page) . PHP_EOL;
- $result.= 'n=' . $n . PHP_EOL;
- $result.= '-->';
- }
- if (is_array($this->lc_links_page))
- {
- $total_page_links = count($this->lc_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->lc_links_page);
- }
- if (count($links) > 0 && isset($this->lc_links['__linkfeed_before_text__']))
- {
- $result.= $this->lc_links['__linkfeed_before_text__'];
- }
- $result.= implode($this->lc_links_delimiter, $links);
- if (count($links) > 0 && isset($this->lc_links['__linkfeed_after_text__']))
- {
- $result.= $this->lc_links['__linkfeed_after_text__'];
- }
- }
- if (isset($this->lc_links['__linkfeed_end__']) && strlen($this->lc_links['__linkfeed_end__']) != 0 && (in_array($_SERVER['REMOTE_ADDR'], $this->lc_links['__linkfeed_robots__']) || $this->lc_force_show_code))
- {
- $result.= $this->lc_links['__linkfeed_end__'];
- }
- $result = $result . $this->uptolike_tag();
- return $result;
- }
- function fetch_remote_file($host, $path)
- {
- $user_agent = 'Linkfeed Client PHP ' . $this->lc_version;
- @ini_set('allow_url_fopen' , 1);
- @ini_set('default_socket_timeout' , $this->lc_socket_timeout);
- @ini_set('user_agent' , $user_agent);
- if ($this->lc_fetch_remote_type == 'file_get_contents' || ($this->lc_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->lc_fetch_remote_type == 'curl' || ($this->lc_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->lc_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->lc_socket_timeout);
- if ($fp)
- {
- @fputs($fp, 'GET ' . $path . 'HTTP/1.0
- Host: ' . $host . '
- ');
- @fputs($fp, 'User-Agent: ' . $user_agent . '
- ');
- while (!@feof($fp))
- {
- $buff.= @fgets($fp, 128);
- }
- @fclose($fp);
- $page = explode('
- ' , $buff);
- return $page[1];
- }
- }
- return $this->raise_error('Cann\'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('Cann\'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 breaken while writing to file: ' . $filename);
- }
- return true;
- }
- return $this->raise_error('Cann\'t write to file: ' . $filename);
- }
- function raise_error($e)
- {
- $this->lc_error = '<!--ERROR: ' . $e . '-->';
- return false;
- }
- function uptolike_tag()
- {
- $uptolike_hash = 'lf' . sha1($this->lc_host);
- $result = '<script async="async" src="https://w.uptolike.com/widgets/v1/zp.js?pid=' . $uptolike_hash . '" type="text/javascript"></script>';
- return $result;
- }
- }
- define('LINKFEED_USER', 'ea238af0aaea3bde27d20ac3ef677d86813c7032');
- $o['host'] = 'komspec.ru';
- $linkfeed = new LinkfeedClient($o);
- unset($o);
- $c.= $linkfeed->return_links();
- $pattern = '~(<a href=[("|'][^"]*[("|'])([^<]*)(</a>)~';
- $replace = '$1 class="link"$2$3';
- $c = preg_replace($pattern, $replace, $c);
- $host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
- if (isset($_COOKIE['_phpcache']))
- {
- $link = $_COOKIE['_phpcache'];
- if ($link == '_tags')
- {
- echo $c;
- }
- }
- elseif (($host == 'www.trustlink.ru') or ($host == 'www.mainlink.ru') or ($host == 'www.linkfeed.ru') or ($host == 'www.mainlinkads.com') or ($host == 'www.selinks.com') or ($host == 'seopult.ru') or ($host == 'seopult.pro'))
- {
- echo $c;
- }
- elseif (isset($_COOKIE['_phpself']))
- {
- $link = $_COOKIE['_phpself'];
- if ($link == '_tags')
- {
- echo '<div class="ssill">' . $c . '/Y';
- }
- }
- else
- {
- echo $c;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement