View file publs_v1_0/inc/func.php

File size: 2.34Kb
<?php

function trans2 ($str) {
	$str = strtr(
		$str, array(
			'а' => 'a',	 'б' => 'b',	'в' => 'v',	 'г' => 'g',	'д' => 'd',	'е' => 'e',
			'ё' => 'yo', 'ж' => 'zh',	'з' => 'z',	 'и' => 'i',	'й' => 'j',	'к' => 'k',
			'л' => 'l',	 'м' => 'm',	'н' => 'n',	 'о' => 'o',	'п' => 'p',	'р' => 'r',
			'с' => 's',	 'т' => 't',	'у' => 'u',	 'ф' => 'f',	'х' => 'h',	'ц' => 'c',
			'ч' => 'ch', 'ш' => 'w',	'щ' => 'sh', 'ъ' => 'q',	'ы' => 'y',	'э' => 'x',
			'ю' => 'yu', 'я' => 'ya',
			'А' => 'A',	 'Б' => 'B',	'В' => 'V',	 'Г' => 'G',	'Д' => 'D',	'Е' => 'E',
			'Ё' => 'YO', 'Ж' => 'ZH',	'З' => 'Z',	 'И' => 'I',	'Й' => 'J',	'К' => 'K',
			'Л' => 'L',	 'М' => 'M',	'Н' => 'N',	 'О' => 'O',	'П' => 'P',	'Р' => 'R',
			'С' => 'S',	 'Т' => 'T',	'У' => 'U',	 'Ф' => 'F',	'Х' => 'H',	'Ц' => 'C',
			'Ч' => 'CH', 'Ш' => 'W',	'Щ' => 'SH', 'Ъ' => 'Q',	'Ы' => 'Y',	'Э' => 'X',
			'Ю' => 'YU', 'Я' => 'YU',	
			' ' => '_',	 '#' => ''
		)
	);
	return $str;
}

function name_stat_upl ($array) {
	foreach ($array as $val) {
		if (!empty($val) && $val !== "") {
			$name = trim($val);
		}
	}
	return $name;
}

#	
function count_komm	($id) {
	$count = DB::run() -> querySingle("select COUNT(*) from `pub_file` where `fid` = '".$id."';");
	return intval($count);
}

#	формат файла
function format ($name) {
	$f1 = strrpos($name, ".");
	$f2 = substr($name, $f1 + 1, 999);
	$fname = strtolower($f2);
	return $fname;
}

#	Вырезание bb-кодов
function notags ($text = '') {
	$text = strtr($text, array('[green]' => '', '[/green]' => '', '[red]' => '', '[/red]' => '', '[blue]' => '', 
	'[/blue]' => '', '[b]' => '', '[/b]' => '', '[i]' => '', '[/i]' => '', '[u]' => '', '[/u]' => '', '[s]' => '', 
	'[/s]' => '', '[code]' => '', '[/code]' => ''));
    return $text;
}

#	Меняем в тексте Латинкие символы на Кирилические
function trt ($str) {
	$reetranslit = array(
	"A" => "А", "a" => "а", 
	"B" => "В", 
	"E" => "Е", "e" => "е", 
	"K" => "К", "k" => "к", 
	"M" => "М", "m" => "м", 
	"H" => "Н", 
	"O" => "О", "o" => "о", 
	"P" => "Р", "p" => "р", 
	"C" => "С", "c"  => "с", 
	"X" => "Х", "x" => "х",
	"Y" => "У", "y" => "у",
	"T" => "Т",
	"&quot;" => '"'
	);
	return strtr($str, $reetranslit);
}
?>