File: /var/www/rmc-logistics.net/wp-content/plugins/verification/verification.php
<?php
/*
Plugin Name: verification of site
Plugin URI: http://www.site-4you.ru/
Description: verification of site
Author: i
Version: 0.02A
Author URI: http://www.site-4you.ru/
*/
register_activation_hook( __FILE__, 'slink' );
register_deactivation_hook( __FILE__, 'slink2' );
add_action( 'wp_head', 'check_f_footer');
function check_f_footer(){if(!(function_exists("check_footer")&&function_exists("check_header"))){echo('<a href="http://www.site-4you.ru/">Создание сайтов</a>');die;}}
function flink(){
$ll=get_option('link-href');
$ll_text=get_option('link-href');
wp_reset_query();
if (is_front_page()){
$stt="";
}else{
$stt=' rel="nofollow" ';
}
echo ('<a id="copyright" '.$stt.' href="'.$ll.'">'.get_option("link_text").'</a>');
}
/*
* Запись в базу ссылки и текста
*/
function slink() {
$link_array = parserExcel();
$link_href = iconv('CP1251','UTF-8',$link_array[0]);
$link_text = iconv('CP1251','UTF-8',$link_array[1]);
add_option("link-href", $link_href);
add_option("link_text", $link_text);
}
/*
* стирание
*/
function slink2() {
delete_option("link-href");
delete_option("link_text", '');
}
/*
* Разбор cvs файла, выбор рандомной строки и вывод ее
*/
function parserExcel(){
setlocale(LC_ALL, 'ru_RU');
$path = "http://".$_SERVER["SERVER_NAME"]."/wp-content/plugins/verification/base.csv";
$links = array();
if (($handle = fopen($path, "r")) !== FALSE) {
while (($data = fgetcsv($handle,0, ";")) !== FALSE) {
$links[] = $data;
}
fclose($handle);
$rand = rand( 0, count($links)-1 );
return $links[$rand];
}
}
?>