add files
This commit is contained in:
3
vendor/akdelf/akdmin/lib/acess.php
vendored
Normal file
3
vendor/akdelf/akdmin/lib/acess.php
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$group['region'] = 'rnews';
|
||||
?>
|
||||
2374
vendor/akdelf/akdmin/lib/akdmin.php
vendored
Normal file
2374
vendor/akdelf/akdmin/lib/akdmin.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1910
vendor/akdelf/akdmin/lib/akdmin_10_07_14.php
vendored
Normal file
1910
vendor/akdelf/akdmin/lib/akdmin_10_07_14.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2114
vendor/akdelf/akdmin/lib/akdmin_12.php
vendored
Normal file
2114
vendor/akdelf/akdmin/lib/akdmin_12.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2144
vendor/akdelf/akdmin/lib/akdmin_19_02_18.php
vendored
Normal file
2144
vendor/akdelf/akdmin/lib/akdmin_19_02_18.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
106
vendor/akdelf/akdmin/lib/akdmin_2.php
vendored
Normal file
106
vendor/akdelf/akdmin/lib/akdmin_2.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
require('fAKdb.php');
|
||||
|
||||
class AKdmin {
|
||||
|
||||
private $main = array(); # главные настройки
|
||||
private $order = null; # текущие параметры сортировки
|
||||
private $limit = 15; # текущее кол-во элементов в таблице
|
||||
private $select = array(); #список полей которые участвуют в запросе
|
||||
|
||||
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#фильтр xss уязвимостей
|
||||
function xss($value) {
|
||||
$value = htmlentities($value, ENT_QUOTES, 'UTF-8');
|
||||
$value = htmlspecialchars($value);
|
||||
$value = strip_tags($value);
|
||||
$value = stripslashes ($value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
#входящие параметры
|
||||
function gets() {
|
||||
|
||||
$map = $this->gparam('ad', ''); # текущая схема
|
||||
if ($map == '')
|
||||
$this->erexit();
|
||||
else
|
||||
$this->map = $map;
|
||||
|
||||
$this->limit = $this->gparam('l', 15, 'int'); # кол-во записей на старнице
|
||||
$this->order = $this->gparam('ord', ''); # текущая сортировка
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
# обработка входящего параметра
|
||||
function gparam($name, $default = null, $type = 'str') {
|
||||
|
||||
if (isset($_GET[$name])) {
|
||||
$value = $_GET[$name];
|
||||
if ($type == 'str')
|
||||
return $this->xss($value);
|
||||
elseif($type == 'int')
|
||||
return (int)$value;
|
||||
}
|
||||
else
|
||||
return $default;
|
||||
}
|
||||
|
||||
# загружаем модель
|
||||
function load($map) {
|
||||
|
||||
$f_xml = site_fold_ad.'xml/'. $map.'.xml';
|
||||
|
||||
if (!file_exists($f_xml)){
|
||||
echo('not found shema');
|
||||
exit;
|
||||
}
|
||||
|
||||
return simplexml_load_file($f_xml);
|
||||
|
||||
}
|
||||
|
||||
|
||||
# иницилиазция главных настроек схемы
|
||||
function mainitems() {
|
||||
|
||||
foreach ($xml->xpath('/items/main') as $key => $mainitem) {
|
||||
$this->main[$key];
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
# получаем все записи текущей таблицы
|
||||
function list() {
|
||||
|
||||
$maintable = Table($this->main('table')); # формируем запрос к таблице
|
||||
$maintable->order($this->order); # текущая сортировка
|
||||
$maintable->limit($this->limit); # количество записей
|
||||
|
||||
|
||||
}
|
||||
|
||||
#выход с критической ошибкой
|
||||
function erexit($errstr){
|
||||
echo $errstr;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
2014
vendor/akdelf/akdmin/lib/akdmin_5_02_15.php
vendored
Normal file
2014
vendor/akdelf/akdmin/lib/akdmin_5_02_15.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1984
vendor/akdelf/akdmin/lib/akdmin_5_14.php
vendored
Normal file
1984
vendor/akdelf/akdmin/lib/akdmin_5_14.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2143
vendor/akdelf/akdmin/lib/akdmin_an.php
vendored
Normal file
2143
vendor/akdelf/akdmin/lib/akdmin_an.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2001
vendor/akdelf/akdmin/lib/akdmin_old.php
vendored
Normal file
2001
vendor/akdelf/akdmin/lib/akdmin_old.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
47
vendor/akdelf/akdmin/lib/auth.lib.php
vendored
Normal file
47
vendor/akdelf/akdmin/lib/auth.lib.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<? class auth
|
||||
{
|
||||
|
||||
var $suser = 'Auth_User';
|
||||
var $spw = 'Auth_PSWRD';
|
||||
|
||||
|
||||
function action()
|
||||
{
|
||||
if(!$this->check()) $this->authorized();
|
||||
|
||||
}
|
||||
|
||||
//вызываем автороизацию
|
||||
function authorized()
|
||||
{
|
||||
header('WWW-Authenticate: Basic realm="Argumenti: authorized"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
header('status: 401 Unauthorized');
|
||||
echo 'нет доступа';
|
||||
exit();
|
||||
/*http://loginassword@www.domain.ru/page.php*/
|
||||
}
|
||||
|
||||
//проверяем данные
|
||||
function check()
|
||||
{
|
||||
|
||||
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']))
|
||||
return False;
|
||||
|
||||
return True;
|
||||
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$_SESSION['Auth_User'] = $_SERVER['PHP_AUTH_USER'];
|
||||
$_SESSION['Auth_PSWRD'] = $_SESSION['Auth_PSWRD'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
64
vendor/akdelf/akdmin/lib/create.php
vendored
Normal file
64
vendor/akdelf/akdmin/lib/create.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
if (!isset($argv[1]))
|
||||
exit;
|
||||
|
||||
$table = $argv[1];
|
||||
|
||||
|
||||
require_once ('../config/ini.php');
|
||||
|
||||
|
||||
$result = mysql_query('SHOW COLUMNS FROM '.$table);
|
||||
|
||||
if (mysql_num_rows($result) == 0) exit;
|
||||
|
||||
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
$xml .= " <item>\n";
|
||||
$xml .= " <column>".$row['Field']."</column>\n
|
||||
<title>".$row['Field']."</title>\n";
|
||||
if ($row['Extra'] == 'auto_increment')
|
||||
$xml .= " <type>increment</type>\n";
|
||||
elseif ($row['Type'] == 'tinyint(1)')
|
||||
$xml .= " <type>checkbox</type>\n";
|
||||
elseif ($row['Type'] == 'varchar(4)')
|
||||
$xml .= " <type>file</type>\n";
|
||||
elseif ($row['Type'] == 'text')
|
||||
$xml .= " <type>textareatiny</type>\n";
|
||||
elseif ($row['Type'] == 'datetime')
|
||||
$xml .= " <type>datetime</type>\n";
|
||||
else
|
||||
$xml .= " <type>text</type>\n";
|
||||
|
||||
$xml .= " <view>\n";
|
||||
$xml .= " <table>True</table>\n";
|
||||
if ($row['Extra'] == 'auto_increment'){
|
||||
$xml .= " <form>False</form>\n";
|
||||
$increment = $row['Field'];
|
||||
}
|
||||
else
|
||||
$xml .= " <form>True</form>\n";
|
||||
|
||||
$xml .= " </view>\n";
|
||||
$xml .= " </item>\n";
|
||||
}
|
||||
|
||||
|
||||
$xml = '<?xml version="1.0" encoding="UTF8"?>'."\n".
|
||||
'<items>
|
||||
<main>
|
||||
<table>'.$table.'</table>
|
||||
<order>'.$increment.'</order>
|
||||
<order_type>DESC</order_type>
|
||||
<increment>'.$increment.'</increment>
|
||||
<title>'.$table.'</title>
|
||||
</main>'."\n".$xml.'</items>';
|
||||
|
||||
$xfile = site_fold_ad.'xml/'.$table.'.xml';
|
||||
echo $xfile;
|
||||
$file = fopen($xfile,'w');
|
||||
fwrite($file, $xml);
|
||||
fclose($file);
|
||||
|
||||
77
vendor/akdelf/akdmin/lib/day_and_week.php
vendored
Normal file
77
vendor/akdelf/akdmin/lib/day_and_week.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?
|
||||
|
||||
function monthName($nmonth)
|
||||
{
|
||||
$mese[1]="января";
|
||||
$mese[2]="февраля";
|
||||
$mese[3]="марта";
|
||||
$mese[4]="апреля";
|
||||
$mese[5]="мая";
|
||||
$mese[6]="июня";
|
||||
$mese[7]="июля";
|
||||
$mese[8]="августа";
|
||||
$mese[9]="сентября";
|
||||
$mese[10]="октября";
|
||||
$mese[11]="ноября";
|
||||
$mese[12]="декабря";
|
||||
|
||||
$mes1 = (int)$nmonth;
|
||||
if ($mes1 != 0)
|
||||
return $mese[$mes1];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function AddNull($num)
|
||||
{
|
||||
if ((int)$num < 10)
|
||||
return '0'.$num;
|
||||
else
|
||||
return $num;
|
||||
}
|
||||
|
||||
function weekName($nweek)
|
||||
{
|
||||
|
||||
$giorno[0]="Воскресенье";
|
||||
$giorno[1]="Понедельник";
|
||||
$giorno[2]="Вторник";
|
||||
$giorno[3]="Среда";
|
||||
$giorno[4]="Четверг";
|
||||
$giorno[5]="Пятница";
|
||||
$giorno[6]="Суббота";
|
||||
|
||||
return $giorno[$nweek];
|
||||
}
|
||||
|
||||
function DateNotNull($dd)
|
||||
{
|
||||
$d1 = (int)$dd;
|
||||
return (string)$d1;
|
||||
|
||||
}
|
||||
|
||||
//преобразование даты в формат RFC 822
|
||||
function DateToRFC822($date)
|
||||
{
|
||||
$datatime = explode(" ",$date); //Вместо date() результат из базы
|
||||
$dater = explode("-",$datatime[0]);
|
||||
$timer = explode(":",$datatime[1]);
|
||||
|
||||
return date('r', mktime($timer[0], $timer[1], $timer[2], $dater[1], $dater[2], $dater[0]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
function DateToStr($date)
|
||||
{
|
||||
|
||||
$begin_date = explode('-',$date);
|
||||
return DateNotNull($begin_date[2]).' '.monthName(DateNotNull($begin_date[1])).' '. $begin_date[0];
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
36
vendor/akdelf/akdmin/lib/deletefile.php
vendored
Normal file
36
vendor/akdelf/akdmin/lib/deletefile.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<? header("Content-Type: text/html;charset=windows-1251");
|
||||
session_start();
|
||||
|
||||
//0 - файла нет
|
||||
//1 - файл удален
|
||||
//2 - невозможно удалить файл
|
||||
|
||||
if (isset($_GET['file']))
|
||||
$file = $_SERVER['DOCUMENT_ROOT'].'/'.strip_tags($_GET['file']);
|
||||
if (isset($_GET['id']))
|
||||
$id = $_GET['id'];
|
||||
|
||||
if (isset($_GET['column']))
|
||||
$column = $_GET['column'];
|
||||
|
||||
if(file_exists($file)) {
|
||||
if (unlink($file)){
|
||||
$message = 'файл удален!';
|
||||
$status = 1;
|
||||
}
|
||||
else
|
||||
$status = 2;
|
||||
}
|
||||
else{
|
||||
$message = 'файл не существует!';
|
||||
$status = 0;
|
||||
}
|
||||
|
||||
|
||||
if ($status == 2){
|
||||
echo('<INPUT TYPE = "button" VALUE = "Удалить файл" onClick = "'."sendRequest('".site_ad."/deletefile?file=".$file."&id=".$id."', 'fl".$id."', getRequest);".'" /> <i>файл не удален!</i>');
|
||||
}
|
||||
else
|
||||
echo '<i>'.$message.'</i><INPUT NAME = "DFile_'.$column.'" TYPE = "hidden" VALUE = "'.$status.'">'
|
||||
|
||||
?>
|
||||
71
vendor/akdelf/akdmin/lib/file.php
vendored
Normal file
71
vendor/akdelf/akdmin/lib/file.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
//сохранить файл
|
||||
function save($filename, $content, $mode = null)
|
||||
{
|
||||
|
||||
$dir = dirname($filename);
|
||||
|
||||
if (!is_dir($dir))
|
||||
mkdir($dir, 0777, True);
|
||||
|
||||
|
||||
$file = fopen($filename,'w');
|
||||
if ($file) {
|
||||
|
||||
flock($file, LOCK_EX);
|
||||
if (fwrite($file, $content))
|
||||
$result = True;
|
||||
else
|
||||
$result = False;
|
||||
flock($file, LOCK_UN);
|
||||
fclose($file);
|
||||
if ($mode) // права доступа
|
||||
chmod($filename, '0'.$mode);
|
||||
}
|
||||
else
|
||||
$result = False;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//рубим директорию вместе с файлом
|
||||
function full_del_dir ($directory)
|
||||
{
|
||||
|
||||
if (!is_dir($directory)) exit;
|
||||
|
||||
$dir = opendir($directory);
|
||||
while(($file = readdir($dir))){
|
||||
if ( is_file ($directory."/".$file))
|
||||
{
|
||||
unlink ($directory."/".$file);
|
||||
}
|
||||
else if ( is_dir ($directory."/".$file) &&
|
||||
($file != ".") && ($file != ".."))
|
||||
{
|
||||
full_del_dir ($directory."/".$file);
|
||||
}
|
||||
}
|
||||
closedir ($dir);
|
||||
rmdir ($directory);
|
||||
}
|
||||
|
||||
|
||||
function crdir($dir)
|
||||
{
|
||||
//создаем каталог
|
||||
if (!is_dir($dir)){
|
||||
if (!mkdir($dir, 0775, True)) {
|
||||
echo('Невозможно создать каталог'.$dir.'!');
|
||||
return False;
|
||||
}
|
||||
else
|
||||
return True;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
?>
|
||||
831
vendor/akdelf/akdmin/lib/filter.php
vendored
Normal file
831
vendor/akdelf/akdmin/lib/filter.php
vendored
Normal file
@@ -0,0 +1,831 @@
|
||||
<?php
|
||||
|
||||
|
||||
require_once ('utf8_ents.php');
|
||||
|
||||
|
||||
function filter($text)
|
||||
{
|
||||
$result = new filter($text);
|
||||
return $result;
|
||||
}
|
||||
|
||||
class filter
|
||||
{
|
||||
|
||||
const TAGBEGIN = "\x01"; // признак начала тега
|
||||
const TAGEND = "\x02"; // признак конца тега
|
||||
|
||||
const NOBRSPACE = "\x03";
|
||||
const NOBRHYPHEN = "\x04";
|
||||
const THINSP = "\x05";
|
||||
const DASH = "\x06";
|
||||
const NUMDASH = "\x07";
|
||||
|
||||
const PUNCT = '\.|,|\!|\?|…|;|\:'; // знаки пунктуации
|
||||
const SPACE = '\ |\s'; //все пустые символы
|
||||
|
||||
const TEXTSPACE = ' | |\t';
|
||||
|
||||
const PARAGRAF = "\n[\r]?";
|
||||
|
||||
const TAGALL = '</?[a-z]+[^>]*?>'; //цепочка всевозможных тегов
|
||||
|
||||
|
||||
|
||||
//экранирование тегов
|
||||
var $refs = array();
|
||||
var $refscntr = 0;
|
||||
|
||||
var $tags = '';
|
||||
var $text = '';
|
||||
|
||||
|
||||
function __construct($text = '')
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
|
||||
function source($text)
|
||||
{
|
||||
$this->text = trim($text);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
function __toString()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
|
||||
//преобразовываем теги
|
||||
private function putTag($x)
|
||||
{
|
||||
$this->refs[] = $x[0];
|
||||
return filter::TAGBEGIN.($this->refscntr++).filter::TAGEND;
|
||||
}
|
||||
|
||||
//возвращаем теги на место
|
||||
private function getTag($x)
|
||||
{
|
||||
return $this->refs[$x[1]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//преобразовываем теги
|
||||
private function putTag1($x)
|
||||
{
|
||||
$this->refs[] = $x[0];
|
||||
return filter::TAGBEGIN;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private function retag($replace)
|
||||
{
|
||||
|
||||
if ($replace) //вырезаем теги
|
||||
$this->text = preg_replace_callback('/<(?:[^\'"\>]+|".*?"|\'.*?\')+>/s', array($this, 'putTag'), $this->text);
|
||||
else {
|
||||
$revers = '/'.filter::TAGBEGIN.'(\d+)'.filter::TAGEND.'/';
|
||||
|
||||
while(preg_match($revers, $this->text)) {
|
||||
$this->text = preg_replace_callback($revers, array($this, 'getTag'), $this->text);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
function html()
|
||||
{
|
||||
//вырезаем все теги
|
||||
$this->retag(True);
|
||||
|
||||
|
||||
//замена на кавычки-елочки
|
||||
$this->quotes();
|
||||
|
||||
//возвращаем
|
||||
$this->retag(False);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//получаем короткий текст с учетом абзацев, в случае неудачи возвращаем null
|
||||
function short($len)
|
||||
{
|
||||
|
||||
if ($len >= mb_strlen($this->text))
|
||||
return null;
|
||||
|
||||
|
||||
//$this->entity('text'); //преобразовываем сущности
|
||||
|
||||
$nn = 0; //текущий сивол кода
|
||||
$currlen = 0; //текущий символ текста
|
||||
$op_tag = False;
|
||||
|
||||
$nn = 0;
|
||||
while ($currlen < $len) { //находим символ для обреза
|
||||
$s = mb_substr($this->text, $nn , 1);
|
||||
$nn ++; //текущий символ
|
||||
if ($s=='<') {//открытый тег
|
||||
if($op_tag) //это был не тег
|
||||
$currlen = $nn;
|
||||
$op_tag = True;
|
||||
}
|
||||
else if ($s == '>') //закрытие тега {
|
||||
$op_tag = False;
|
||||
else {
|
||||
if (!$op_tag)
|
||||
$currlen ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tags = array('</p>', '<br />', '<br>', '</pre>'); //теги окончания абзаца
|
||||
|
||||
$currend = null;
|
||||
|
||||
$van_str = mb_substr($this->text, 0, $nn); // начало текста
|
||||
$obrezok = mb_substr($this->text, $nn); //вторая часть
|
||||
$len_obrezok = mb_strlen($obrezok); //кол-во символов после последнего символа
|
||||
$currend = $len_obrezok;
|
||||
|
||||
foreach ($tags as $tag) { //ищем признак окончания абзаца
|
||||
$tag_pos = strpos($obrezok, $tag);
|
||||
if ($tag_pos > 0 and $currend > $tag_pos) { //выбираем самый близкий закрывающий тег
|
||||
$currend = $tag_pos; //позиция тега
|
||||
$taglen = mb_strlen($tag); //размер тега
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($currend < $len_obrezok) {
|
||||
$endpos = $currend + $taglen; //узнаем последний символ с закрывающим тегом
|
||||
if ($endpos == $len_obrezok)
|
||||
return null;
|
||||
return $van_str.mb_substr($obrezok, 0, $endpos); //получаем обрезанный текст
|
||||
}
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//корректный перевод строки
|
||||
private function correct_return()
|
||||
{
|
||||
|
||||
if (strtoupper(substr(PHP_OS,0,3)) === 'WIN')
|
||||
$this->correct_return = "\r\n"; // перевод строки для Windows-систем
|
||||
else
|
||||
$this->correct_return = "\n"; // перевод строки для UNIX-систем
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function text($entity = 'text')
|
||||
{
|
||||
|
||||
$this->entity('cp1251');
|
||||
$this->html2text();
|
||||
$this->space_text(); # убиваем лишние пробелы
|
||||
$this->special(); # спецзнаки
|
||||
//$this->text_edit();
|
||||
|
||||
if ($entity = 'text')
|
||||
return $this;
|
||||
else if ($entity = 'xml')
|
||||
$this->entity('xml');
|
||||
else if ($entity = 'html')
|
||||
$this->entity('html');
|
||||
|
||||
$this->html2text();
|
||||
$this->space_text(); # убиваем лишние пробелы
|
||||
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function xml()
|
||||
{
|
||||
|
||||
$this->strip_bak_tag(); # лишние и вредоносные теги
|
||||
$this->clean();//убиваем стайлы
|
||||
$this->space(); # убиваем лишние пробелы
|
||||
$this->space_text();
|
||||
$this->special(); # спецзнаки
|
||||
$this->html_edit();
|
||||
$this->entity('cp1251');
|
||||
//$this->text_edit();
|
||||
$this->xmltags(); # оставляем тока разрешенные теги
|
||||
$this->retag(True); # выкусываем теги
|
||||
$this->entity('xml'); # преобразовываем сущности не затрагивая теги
|
||||
$this->retag(False); # теги обратно
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function plaintext()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function html2()
|
||||
{
|
||||
|
||||
$this->space(); # убиваем лишние пробелы
|
||||
$this->strip_bak_tag(); # лишние и вредоносные теги
|
||||
$this->clean();//убиваем стайлы
|
||||
$this->special(); # спецзнаки
|
||||
$this->html_edit();
|
||||
$this->entity('cp1251');
|
||||
//$this->text_edit();
|
||||
$this->retag(True); # выкусываем теги
|
||||
$this->entity('html'); # преобразовываем сущности не затрагивая теги
|
||||
$this->retag(False); # теги обратно
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function entity_tiny()
|
||||
{
|
||||
|
||||
//удаление html-комментариев
|
||||
$this->text = preg_replace('/<!--.*-->/Uis', '', $this->text);
|
||||
|
||||
$this->retag(True); # выкусываем теги
|
||||
$this->entity('html'); # преобразовываем сущности не затрагивая теги
|
||||
$this->retag(False); # теги обратно
|
||||
|
||||
return $this->text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#отделяем аперанд от сущностей
|
||||
function entity_amp()
|
||||
{
|
||||
$this->text = preg_replace('"/\&(?![^&][^;]+;)/u"', '&', $this->text);
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//преобразовываемсущности в рамках HTML
|
||||
function entity($type, $amp = False)
|
||||
{
|
||||
|
||||
if ($type == 'cp1251') {
|
||||
$this->text = utf8_html_entity_decode($this->text);
|
||||
}
|
||||
else if($type == 'html'){
|
||||
$this->entity_amp(); //экранируем аперанд от сущностей
|
||||
$this->text = utf8_html_entity_encode($this->text);
|
||||
}
|
||||
else if($type == 'xml') {
|
||||
|
||||
$this->text = utf8_html_entity_decode($this->text, True);
|
||||
|
||||
//с аперандом
|
||||
$xmlentsamp = array(
|
||||
"\x26"=>'&',
|
||||
"\x22"=>'&quot;',
|
||||
"\x3c"=>'&lt;',
|
||||
"\x3e"=>'&gt;',
|
||||
' '=>'&#160;'
|
||||
);
|
||||
|
||||
//без аперанда
|
||||
$xmlents = array(
|
||||
"\x26"=>'&',
|
||||
"\x22"=>'"',
|
||||
"\x3c"=>'<',
|
||||
"\x3e"=>'>',
|
||||
' '=>' '
|
||||
);
|
||||
|
||||
|
||||
if ($amp) {
|
||||
foreach ($xmlentsamp as $key=>$element)
|
||||
$this->text = str_replace($key, $element, $this->text);
|
||||
}
|
||||
else { // без аперанда
|
||||
foreach ($xmlents as $key=>$element)
|
||||
$this->text = str_replace($key, $element, $this->text);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//преобразовываем p в ик
|
||||
function p2br($col = 1)
|
||||
{
|
||||
|
||||
$br = '<br />';
|
||||
|
||||
if ($col == 1)
|
||||
$r = $br;
|
||||
else {
|
||||
for ($i = 1; $i <= $col; $i++)
|
||||
$r .= $br;
|
||||
}
|
||||
|
||||
$this->text = preg_replace("!<p[^>]*?>(.*?)</p>!si","\\1".$r, $this->text);
|
||||
//плохие теги
|
||||
$this->text = preg_replace("'</?p[^>]*?>'",$r, $this->text);
|
||||
|
||||
//брейки в начале
|
||||
$this->text = preg_replace("'^(<br[^>]*>)+'",'', $this->text);
|
||||
|
||||
//брейки в конце
|
||||
$this->text = preg_replace("'(<br[^>]*>)+$'",'', $this->text);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function delete_gap_tag()
|
||||
{
|
||||
$this->text = preg_replace_callback('/(<s*/*s*)([a-z]+)(s*>)/im', create_function('$tag', 'return preg_replace("/s/i", "", $tag[0]);'), $this->CONTENT[$this->id]);
|
||||
|
||||
return $this->text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function preg_rec($preg, $repl)
|
||||
{
|
||||
while (preg_match($preg, $this->text))
|
||||
$this->text = preg_replace($preg, $repl, $this->text);
|
||||
|
||||
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
function text2p($type = 'p') {
|
||||
|
||||
$currtext = '<p>'.$this->text;
|
||||
|
||||
$txtlen = strlen($currtext) - 1;
|
||||
|
||||
$p_open = True; //открыт ли тег
|
||||
$pos = 0;
|
||||
|
||||
while ($pos !== False) {
|
||||
|
||||
$pos = strpos($currtext, chr(13).chr(10), $pos);
|
||||
|
||||
if ($pos !== False) {
|
||||
$rep_pos = $pos;
|
||||
$pos = $pos + 2;
|
||||
if ($txtlen == $pos) {
|
||||
$rep_simbol = '</p>';
|
||||
$p_open = False;
|
||||
}
|
||||
else {
|
||||
$rep_simbol = '</p><p>';
|
||||
$p_open = True;
|
||||
}
|
||||
$currtext = substr_replace($currtext, $rep_simbol, $rep_pos, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($p_open)
|
||||
$currtext = $currtext.'</p>';
|
||||
|
||||
$this->text = $currtext;
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function space_text()
|
||||
{
|
||||
|
||||
// Убираем лишние пустые символы
|
||||
$this->text = preg_replace( '"('.filter::TEXTSPACE.')+"', ' ', $this->text );
|
||||
|
||||
//пустые символы в начале строки
|
||||
$this->text = preg_replace('"^('.filter::TEXTSPACE.')+"', '',$this->text);
|
||||
|
||||
//пустые символы в конце строки
|
||||
$this->text = preg_replace('"('.filter::TEXTSPACE.')+$"', '',$this->text);
|
||||
$this->text = preg_replace('/['.filter::TEXTSPACE.']+('.filter::PARAGRAF.')/', '\\1', $this->text);
|
||||
$this->text = preg_replace('/('.filter::PARAGRAF.')['.filter::TEXTSPACE.']+$/', '\\1', $this->text);
|
||||
$this->text = preg_replace('/['.filter::TEXTSPACE.']+('.filter::PARAGRAF.')/', "\\1", $this->text);
|
||||
$this->text = preg_replace('/('.filter::PARAGRAF.')['.filter::TEXTSPACE.']+/', "\\1", $this->text);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function space()
|
||||
{
|
||||
|
||||
|
||||
|
||||
$nospace_tags = 'span|b|strong|i|em|a'; //теги с нежелетаелтельными начальными и конечными пробелами
|
||||
|
||||
|
||||
// кон. и нач. пробелы за пределы тега
|
||||
$this->text = preg_replace( '!(<('.$nospace_tags.')[^>]*?>)(('.filter::SPACE.')+)!si', '\\3\\1', $this->text );
|
||||
$this->text = preg_replace( '!(('.filter::SPACE.')+)(</('.$nospace_tags.')>)!si', '\\3\\1', $this->text );
|
||||
|
||||
//пробелы в начале цепочки тегов
|
||||
$this->text = $this->preg_rec('!^(('.filter::TAGALL.')+)('.filter::SPACE.')+!si', '\\1', $this->text);
|
||||
|
||||
//пробелы в конце цепочки тегов
|
||||
$this->text = $this->preg_rec('!('.filter::SPACE.')+(('.filter::TAGALL.')+)$!si', '\\2', $this->text);
|
||||
|
||||
|
||||
# ------------------- парагарфы и абазцы --------------------------------------------------------------------
|
||||
|
||||
$paragraph = 'p|pre|h1|h2|h3|h4|h5|h6|address|blockquote|center|li';
|
||||
|
||||
//бессмысленные пробелы перед br
|
||||
$this->text = preg_replace('!('.filter::SPACE.')+(<br ?/?>)!si', '\\2', $this->text);
|
||||
|
||||
//бессмысленные пробелы после br
|
||||
$this->text = preg_replace('!(<br ?/?>)('.filter::SPACE.')+!si', '\\1', $this->text);
|
||||
|
||||
|
||||
//бессмысленные пробелы перед параграфом
|
||||
$this->text = preg_replace('!('.filter::SPACE.')+(<'.$paragraph.'[^>]*?>)!si', '\\2', $this->text);
|
||||
|
||||
|
||||
//бессмысленные пробелы после параграфа
|
||||
$this->text = preg_replace('!(<\/('.$paragraph.')>)('.filter::SPACE.')+!si', '\\1', $this->text);
|
||||
|
||||
//бессмысленные пробелы в начале параграфа
|
||||
$this->text = preg_replace('!(<('.$paragraph.')[^>]*?>)('.filter::SPACE.')+!si', '\\1', $this->text);
|
||||
|
||||
//пробелы в конце параграфа
|
||||
$this->text = preg_replace('!<('.$paragraph.')[^>]*?>(.*?)('.filter::SPACE.')+</\\1>!si', '<\\1>\\2</\\1>', $this->text);
|
||||
|
||||
//бессмысленные пробелы в начале параграфа в куче тегов
|
||||
$this->text = $this->preg_rec('!(<('.$paragraph.')[^>]*?>)(('.filter::TAGALL.')+)('.filter::SPACE.')+!si', '\\1\\3', $this->text);
|
||||
|
||||
//бессмысленные пробелы в конце параграфа в куче тегов
|
||||
$this->text = $this->preg_rec('!('.filter::SPACE.')+(('.filter::TAGALL.')+)(</'.$paragraph.'>)!si', '\\2\\3', $this->text);
|
||||
|
||||
|
||||
# ---------- дочищаем хвосты ---------------------------------
|
||||
|
||||
//убиваем пустые теги
|
||||
$this->text = preg_replace('!<([a-z]+)[^>]*?><\/\\1>!si', '', $this->text);
|
||||
|
||||
// Убираем лишние пустые символы
|
||||
$this->text = preg_replace( '/[\s]+/', ' ', $this->text );
|
||||
|
||||
//если попадает
|
||||
$this->text = preg_replace( "'[\s]*(\ )+[\s]*'", ' ', $this->text);
|
||||
|
||||
//удаление начальных пробелов строки
|
||||
$this->text = preg_replace('"^('.filter::SPACE.')+"', '',$this->text);
|
||||
|
||||
//удаление пробелов в конце строки
|
||||
$this->text = preg_replace('"('.filter::SPACE.')+$"', '',$this->text);
|
||||
|
||||
|
||||
return $this->text;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// теги, которые вырезаются вместе с содержимым
|
||||
function strip_bak_tag()
|
||||
{
|
||||
$tags = 'script|style|pre|code|textarea';
|
||||
/* $tags .= 'applet|base|basefont|bgsound|blink|body|embed|frame|frameset|head|ilayer|layer|link|meta|object|title|input|form';*/
|
||||
$this->text = preg_replace('/< *('.$tags.').*?>.*?< *\/ *\1 *>/is', '', $this->text);
|
||||
|
||||
return $this;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function html_edit()
|
||||
{
|
||||
|
||||
//удаление html-комментариев
|
||||
$this->text = preg_replace('/<!--.*-->/Uis', '', $this->text);
|
||||
|
||||
|
||||
//$this->text = preg_replace( "'([а-яА-ЯёЁa-zA-Z]+)-([а-яА-ЯёЁa-zA-Z]+)'", '<nobr>$1-$2</nobr>', $this->text); //не обрывать слова, написанные через дефис
|
||||
|
||||
|
||||
$this->setUrls();//ссылки превращаем в ссылки
|
||||
|
||||
$this->text = preg_replace('"\n[\r]?"', '<br />', $this->text);
|
||||
|
||||
//праивльное обозначение размера
|
||||
$this->text = preg_replace( '~(\d+)[x|X|х|Х|*](\d+)~','$1×$2', $this->text );
|
||||
|
||||
//все за пределы ссылок
|
||||
$this->text = preg_replace( '/<a +href([^>]*)>(['.filter::PUNCT.']+)/', '\\2<a href\\1>', $this->text );
|
||||
$this->text = preg_replace( '/(!\.\.|\?\.\.)<\/a>/', '</a>\\1', $this->text );
|
||||
$this->text = preg_replace( '/(['.filter::PUNCT.']+)<\/a>/', '</a>\\1', $this->text );
|
||||
|
||||
|
||||
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// теги, которые вырезаются вместе с содержимым
|
||||
function replacetag($stags)
|
||||
{
|
||||
$tags = split(',',$stags);
|
||||
$nn = 0;
|
||||
|
||||
foreach ($tags as $tag){
|
||||
$nn++;
|
||||
if($nn > 0) $tg .= '|';
|
||||
$tg .= trim($tag);
|
||||
}
|
||||
|
||||
$this->text = preg_replace('/< *('.$tg.').*?>.*?< *\/ *\1 *>/is', '', $this->text);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Расстановка кавычек-"елочек"
|
||||
function quotes()
|
||||
{
|
||||
$this->text = preg_replace( '/(['.TAGEND.'\( ]|^)"([^"]*)([^ "\(])"/', '\\1«\\2\\3»', $this->text );
|
||||
if (stristr($this->text, '"' )) // Если есть вложенные кавычки
|
||||
{
|
||||
$text = preg_replace( '/(['.TAGEND.'( ]|^)"([^"]*)([^ "(])"/', '\\1«\\2\\3»', $this->text );
|
||||
while( preg_match( '/«[^»]*«[^»]*»/', $this->text ) )
|
||||
$text = preg_replace( '/«([^»]*)«([^»]*)»/', '«\\1„\\2“', $this->text);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function text_edit()
|
||||
{
|
||||
|
||||
|
||||
$this->text = str_replace( '',' ', $this->text ); //косяки верстки
|
||||
$this->text = str_replace( '',' ', $this->text );
|
||||
|
||||
$this->text = preg_replace('[^:print:]', '',$this->text); //вырезаем непечатные символы
|
||||
|
||||
|
||||
|
||||
$this->quotes();
|
||||
|
||||
|
||||
//знаки припинания
|
||||
//$this->text = preg_replace('"'.filter::PUNCT.'?('.filter::PUNCT.')"','\\1', $this->text );
|
||||
// $this->text = preg_replace('"(\w+)['.filter::PUNCT.'](\w+)"','\\1, \\2', $this->text);
|
||||
|
||||
|
||||
|
||||
//$this->text = $this->specialchars(0); //замены сущностей
|
||||
|
||||
//работа с текстом
|
||||
|
||||
$this->text = preg_replace( "'\.{3}'", '…', $this->text); //Многоточие
|
||||
|
||||
// $this->text = preg_replace("'\.+'",'.',$this->text); // двойные точки
|
||||
$this->text = preg_replace("'\,+'",',',$this->text); // двойные запятые
|
||||
$this->text = preg_replace("'\;+'",';',$this->text); // двойные ;
|
||||
$this->text = preg_replace("'\:+'",':',$this->text); // двойные :
|
||||
$this->text = preg_replace( "' +'", ' ', $this->text); // Убираем лишние пробелы
|
||||
$this->text = preg_replace( "'\t+'", ' ', $this->text); // Убираем лишние табуляторы
|
||||
|
||||
$this->text = str_replace( ','.NOBRSPACE.DASH.' ',','.DASH.' ', $this->text );
|
||||
$this->text = str_replace( '.'.NOBRSPACE.DASH.' ','.'.DASH.' ', $this->text );
|
||||
|
||||
|
||||
// пробелы
|
||||
$this->text = preg_replace( '/\( *([^)]+?) *\)/', '(\\1)', $this->text ); // удаляем пробелы после открывающей скобки и перед закрыващей скобкой
|
||||
$this->text = preg_replace( '/([а-яА-ЯёЁa-zA-Z.,!?:;…])\(/', '\\1 (', $this->text ); // добавляем пробел между словом и открывающей скобкой, если его
|
||||
|
||||
|
||||
// Русские денежные суммы, расставляя пробелы в нужных местах.
|
||||
$this->text = preg_replace( '~(\d+)\s?(руб.)~s','$1 $2', $this->text );
|
||||
$this->text = preg_replace( '~(\d+)\s?(млн.|тыс.){1}\s?(руб.)~s','$1 $2 $3', $this->text );
|
||||
|
||||
|
||||
//неразрывать
|
||||
$this->text = preg_replace( "'(\w\.)\s?(\w\.)\s(\w\w+)'", '$1 $2 $3', $this->text ); // Инициалы + фамилия
|
||||
$this->text = preg_replace( "'(\w\w+)\s?(\w\.)\s(\w\.)'", '$1 $2 $3', $this->text ); // фамилия + инициалы
|
||||
$this->text = preg_replace("'(\W\w\.)\s(\w\w+)'",'$1 $2',$this->text); //один инициал + фамилия
|
||||
|
||||
//последние обработки
|
||||
$this->text = str_replace( '!?','?!', $this->text ); // Правильно в таком порядке
|
||||
$this->text = str_replace( '№ №', '№№', $this->text ); // слитное написание "№№"
|
||||
$this->text = str_replace( '§ §', '§§', $this->text ); // слитное написание "§§"
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function strip($tags)
|
||||
{
|
||||
$this->text = preg_replace("!<р[^>]*?>!si",'',$this->text);
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
function replace_tag($t1, $t2)
|
||||
{
|
||||
|
||||
$this->text = preg_replace("!<".$t1."[^>]*?>(.*?)</".$t1.">!usi","<".$t2.">\\1</".$t2.">",$this->text);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// замена обилие тегов на разрешенные в xml или свои
|
||||
function xmltags()
|
||||
{
|
||||
|
||||
$this->replace_tag('div','p');
|
||||
$this->replace_tag('strong','b');
|
||||
$this->replace_tag('em','i');
|
||||
|
||||
|
||||
$this->text = strip_tags($this->text, '<p>, <br>, <li>, <table>, <tr>, <td>, <ol>, <ul>, <i>, <b>, <iframe>');
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//превращаем в ссылки
|
||||
private function setUrls()
|
||||
{
|
||||
|
||||
$prefix='(http|https|ftp|telnet|news|gopher|file|wais)://';
|
||||
$pureUrl='([[:alnum:]/\n+-=%&:_.~?]+[#[:alnum:]+]*)';
|
||||
$this->text=eregi_replace($prefix.$pureUrl, '<a href="\\1://\\2">\\1://\\2</a>', $this->text);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
//спецсимволика
|
||||
function special($revers = True)
|
||||
{
|
||||
|
||||
$special = array(
|
||||
'(tm)'=>'™', '(TM)'=>'™',
|
||||
'(r)'=>'®', '(R)'=>'®',
|
||||
'(c)'=>'©', '(C)'=>'©', '(с)'=>'©', '(С)'=>'©',
|
||||
'EUR'=>'€', 'eur'=>'€',
|
||||
'+/-'=>'±');
|
||||
|
||||
if ($revers) // на спецзнаки
|
||||
$this->text = strtr($this->text, $special);
|
||||
else //на обычные
|
||||
$this->text = strtr($this->text, array_flip($special));
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//очищаем теги от стилей идов и классов
|
||||
function clean()
|
||||
{
|
||||
|
||||
$this->text = preg_replace('!<([a-z]+)[\s]+[^>]*?>!si','<\\1>', $this->text);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function html2text($plain = False)
|
||||
{
|
||||
|
||||
$this->text = strip_tags($this->text);
|
||||
$this->text = trim($this->text);
|
||||
return $this;
|
||||
|
||||
//$params['wrap'] = 20, $params['br'] = 2;
|
||||
|
||||
//преобразования абзацев
|
||||
$para_repl = ($plain) ? "\n\n\t" : "\n\n";
|
||||
$this->text = preg_replace('/<p[^>]*>/ui',$para_repl , $this->text);
|
||||
|
||||
|
||||
$this->text = preg_replace('/<br[^>]*>/ui', "\n", $this->text);
|
||||
|
||||
$this->text = preg_replace('/<hr[^>]*>/ui',"\n-------------------------\n", $this->text);
|
||||
|
||||
//заголовки
|
||||
if ($plain){
|
||||
$this->text = preg_replace('/<h[123][^>]*>(.*?)<\/h[123]>/uie', "strtoupper(\"\n\n\\1\n\n\")", $this->text);
|
||||
$this->text = preg_replace('/<h[456][^>]*>(.*?)<\/h[456]>/uie', "ucwords(\"\n\n\\1\n\n\")", $this->text);
|
||||
}
|
||||
else
|
||||
$this->text = preg_replace('/<h[123456][^>]*>(.*?)<\/h[123456]>/uie', "strtoupper(\"\n\n\\1\n\n\")", $this->text);
|
||||
|
||||
//преобразования таблицы
|
||||
$this->text = preg_replace('/(<table[^>]*>|<\/table>)/ui',"\n\n",$this->text);
|
||||
$this->text = preg_replace('/<thead[^>]*>(.*?)<\/thead>/ui', "\\1\n", $this->text);
|
||||
|
||||
if ($plain)
|
||||
$this->text = preg_replace('/<th[^>]*>(.*?)<\/th>/ui', "strtoupper(\"\t\\1\")", $this->text);
|
||||
else
|
||||
$this->text = preg_replace('/<th[^>]*>(.*?)<\/th>/ui', "\t\\1", $this->text);
|
||||
|
||||
$this->text = preg_replace('/(<tr[^>]*>|<\/tr>)/ui', "\n", $this->text);
|
||||
$this->text = preg_replace('/<td[^>]*>(.*?)<\/td>/ui', "\t\\1", $this->text);
|
||||
|
||||
//списки
|
||||
$this->text = preg_replace('/(<ul[^>]*>|<\/ul>)/ui', "\n\n", $this->text);
|
||||
$this->text = preg_replace('/(<ol[^>]*>|<\/ol>)/iu', "\n\n", $this->text);
|
||||
|
||||
$this->text = preg_replace('/<li[^>]*>(.*?)<\/li>/ui', "\t* \\1\n", $this->text);
|
||||
|
||||
$this->text = preg_replace('/<li[^>]*>/ui', "\n\t* ", $this->text);
|
||||
|
||||
// ссылки
|
||||
$this->text = preg_replace('/<a [^>]*href="([^"]+)"[^>]*>(.*?)<\/a>/uie','\\1',$this->text);
|
||||
|
||||
|
||||
$this->text = trim($this->text);
|
||||
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
15
vendor/akdelf/akdmin/lib/log.php
vendored
Normal file
15
vendor/akdelf/akdmin/lib/log.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?function write_log($value, $file = 'log/error.log')
|
||||
{
|
||||
$log = set('site_fold_ad').$file;
|
||||
|
||||
if (file_exists($log))
|
||||
$fp = fopen($log,'a+');
|
||||
else {
|
||||
$fp = fopen($log,'w');
|
||||
chmod($log, 0660);
|
||||
}
|
||||
|
||||
fwrite($fp, '['.date('d.m.y\ H:i:s').'] '.$value.chr(13));
|
||||
fclose($fp);
|
||||
}
|
||||
?>
|
||||
5748
vendor/akdelf/akdmin/lib/pclzip.lib.2.5.php
vendored
Normal file
5748
vendor/akdelf/akdmin/lib/pclzip.lib.2.5.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
213
vendor/akdelf/akdmin/lib/photos.php
vendored
Normal file
213
vendor/akdelf/akdmin/lib/photos.php
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
<?
|
||||
|
||||
function showphotocadr($f, $newF, $type)
|
||||
{
|
||||
// f - имя файла
|
||||
// type - способ масштабирования
|
||||
// q - качество сжатия
|
||||
// src - исходное изображение
|
||||
// dest - результирующее изображение
|
||||
// w - ширниа изображения
|
||||
// ratio - коэффициент пропорциональности
|
||||
// str - текстовая строка
|
||||
|
||||
// тип преобразования, если не указаны размеры
|
||||
if ($type == 's') $w = 120;
|
||||
else if ($type == 'b') $w = 180;
|
||||
else if ($type == 'm') $w = 180;
|
||||
else return false;
|
||||
|
||||
|
||||
// качество jpeg по умолчанию
|
||||
if (!isset($q)) $q = 100;
|
||||
|
||||
|
||||
$src = imagecreatefromjpeg($f);
|
||||
$w_src = imagesx($src);
|
||||
$h_src = imagesy($src);
|
||||
|
||||
// если размер исходного изображения
|
||||
// отличается от требуемого размера
|
||||
if ($w_src != $w)
|
||||
{
|
||||
// операции для получения прямоугольного файла
|
||||
if ($type=='m')
|
||||
{
|
||||
// вычисление пропорц ий
|
||||
$ratio = $w_src/$w;
|
||||
$w_dest = round($w_src/$ratio);
|
||||
$h_dest = round($h_src/$ratio);
|
||||
|
||||
// создаём пустую картинку
|
||||
// важно именно truecolor!, иначе будем иметь 8-битный результат
|
||||
$dest = imagecreatetruecolor($w_dest,$h_dest);
|
||||
imagecopyresampled($dest, $src, 0, 0, 0, 0, $w_dest, $h_dest, $w_src, $h_src);
|
||||
}
|
||||
|
||||
|
||||
// операции для получения квадратного файла
|
||||
if (($type=='s')||($type=='b'))
|
||||
{
|
||||
// создаём пустую квадратную картинку
|
||||
// важно именно truecolor!, иначе будем иметь 8-битный результат
|
||||
$dest = imagecreatetruecolor($w,$w);
|
||||
|
||||
// вырезаем квадратную серединку по x, если фото горизонтальное
|
||||
if ($w_src>$h_src)
|
||||
imagecopyresampled($dest, $src, 0, 0,
|
||||
round((max($w_src,$h_src)-min($w_src,$h_src))/2),
|
||||
0, $w, $w, min($w_src,$h_src), min($w_src,$h_src));
|
||||
|
||||
// вырезаем квадратную верхушку по y,
|
||||
// если фото вертикальное (хотя можно тоже серединку)
|
||||
if ($w_src<$h_src)
|
||||
imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $w,
|
||||
min($w_src,$h_src), min($w_src,$h_src));
|
||||
|
||||
// квадратная картинка масштабируется без вырезок
|
||||
if ($w_src==$h_src)
|
||||
imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $w, $w_src, $w_src);
|
||||
}
|
||||
|
||||
// вывод картинки и очистка памяти
|
||||
imagejpeg($dest,$newF,$q);
|
||||
imagedestroy($dest);
|
||||
imagedestroy($src);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function img_resize($src, $dest, $width, $height, $rgb=0xFFFFFF, $quality=100)
|
||||
{
|
||||
// if (!file_exists($src)) return false;
|
||||
|
||||
$size = getimagesize($src);
|
||||
|
||||
if ($size == false) return false;
|
||||
|
||||
// Определяем исходный формат по MIME-информации, предоставленной
|
||||
// функцией getimagesize, и выбираем соответствующую формату
|
||||
// imagecreatefrom-функцию.
|
||||
$format = strtolower(substr($size['mime'], strpos($size['mime'], '/')+1));
|
||||
$icfunc = "imagecreatefrom" . $format;
|
||||
if (!function_exists($icfunc)) return false;
|
||||
|
||||
$x_ratio = $width / $size[0];
|
||||
$y_ratio = $height / $size[1];
|
||||
|
||||
$ratio = min($x_ratio, $y_ratio);
|
||||
$use_x_ratio = ($x_ratio == $ratio);
|
||||
|
||||
$new_width = $use_x_ratio ? $width : floor($size[0] * $ratio);
|
||||
$new_height = !$use_x_ratio ? $height : floor($size[1] * $ratio);
|
||||
$new_left = $use_x_ratio ? 0 : floor(($width - $new_width) / 2);
|
||||
$new_top = !$use_x_ratio ? 0 : floor(($height - $new_height) / 2);
|
||||
|
||||
|
||||
$isrc = $icfunc($src);
|
||||
$idest = imagecreatetruecolor($width, $height);
|
||||
|
||||
imagefill($idest, 0, 0, $rgb);
|
||||
imagecopyresampled($idest, $isrc, $new_left, $new_top, 0, 0, $new_width, $new_height, $size[0], $size[1]);
|
||||
|
||||
// echo($format);
|
||||
imagejpeg($idest,$dest,$quality);
|
||||
imagedestroy($isrc);
|
||||
imagedestroy($idest);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showphoto($publ_id, $number_id, $typeimg)
|
||||
{
|
||||
|
||||
if ($number_id < 54){
|
||||
$Folder = 'big';
|
||||
if ($typeimg == 'b')
|
||||
$typeimg = 's';
|
||||
}
|
||||
else
|
||||
$Folder = 'cashe';
|
||||
|
||||
$search = False;
|
||||
$filename = '';
|
||||
|
||||
if(file_exists(site_fold.'images/'.$Folder.'/'.$publ_id.$typeimg.'.jpg')){
|
||||
//$filename = 'http://www.argumenti.ru/images/'.$Folder.'/'.$publ_id.$typeimg.'.jpg';
|
||||
$filename = site.'images/'.$Folder.'/'.$publ_id.$typeimg.'.jpg';
|
||||
$search = True;
|
||||
}
|
||||
else if (file_exists(site_fold.'images/'.$Folder.'/'.$publ_id.$typeimg.'.JPG')){
|
||||
//$filename = 'http://www.argumenti.ru/images/'.$Folder.'/'.$publ_id.$typeimg.'.jpg';
|
||||
$filename = site.'images/'.$Folder.'/'.$publ_id.$typeimg.'.JPG';
|
||||
$search = True;
|
||||
}
|
||||
else if (file_exists(site_fold.'images/'.$Folder.'/'.$publ_id.$typeimg.'.gif')){
|
||||
// $filename = 'http://www.argumenti.ru/images/'.$Folder.'/'.$publ_id.$typeimg.'.jpg';
|
||||
$filename = site.'images/'.$Folder.'/'.$publ_id.$typeimg.'.gif';
|
||||
$search = True;
|
||||
}
|
||||
else if (file_exists(site_fold.'images/'.$Folder.'/'.$publ_id.$typeimg.'.GIF')){
|
||||
// $filename = 'http://www.argumenti.ru/images/'.$Folder.'/'.$publ_id.$typeimg.'.jpg';
|
||||
$filename = site.'images/'.$Folder.'/'.$publ_id.$typeimg.'.GIF';
|
||||
$search = True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!$search) {
|
||||
if ($typeimg == 's'){
|
||||
$width = 120;
|
||||
$height = 120;
|
||||
}
|
||||
else if ($typeimg == 'm'){
|
||||
$width = 200;
|
||||
$height = 200;
|
||||
}
|
||||
else if ($typeimg == 'b'){
|
||||
$width = 180;
|
||||
$height = 180;
|
||||
}
|
||||
|
||||
|
||||
if(file_exists(site_fold.'images/news/'.$publ_id.'.jpg')){
|
||||
if (showphotocadr(site_fold.'images/news/'.$publ_id.'.jpg', site_fold.'/images/cashe/'.$publ_id.$typeimg.'.jpg',$typeimg))
|
||||
//$filename = site.'images/cashe/'.$publ_id.$typeimg.'.jpg';
|
||||
$filename = site_fold.'images/cashe/'.$publ_id.$typeimg.'.jpg';
|
||||
}
|
||||
|
||||
if(file_exists(site_fold.'images/news/'.$publ_id.'.JPG')){
|
||||
if (showphotocadr(site_fold.'images/news/'.$publ_id.'.JPG', site_fold.'/images/cashe/'.$publ_id.$typeimg.'.JPG',$typeimg))
|
||||
// $filename = site.'images/cashe/'.$publ_id.$typeimg.'.JPG';
|
||||
$filename = site_fold.'images/cashe/'.$publ_id.$typeimg.'.JPG';
|
||||
}
|
||||
|
||||
if(file_exists(site_fold.'images/news/'.$publ_id.'.JPG')){
|
||||
if (showphotocadr(site_fold.'images/news/'.$publ_id.'.gif', site_fold.'/images/cashe/'.$publ_id.$typeimg.'.gif',$typeimg))
|
||||
//$filename = site.'images/cashe/'.$publ_id.$typeimg.'.gif';
|
||||
$filename = site_fold.'images/cashe/'.$publ_id.$typeimg.'.gif';
|
||||
}
|
||||
|
||||
if(file_exists(site_fold.'images/news/'.$publ_id.'.GIF')){
|
||||
if (showphotocadr(site_fold.'images/news/'.$publ_id.'.GIF', site_fold.'/images/cashe/'.$publ_id.$typeimg.'.GIF',$typeimg))
|
||||
//$filename = site.'images/cashe/'.$publ_id.$typeimg.'.GIF';
|
||||
$filename = site_fold.'images/cashe/'.$publ_id.$typeimg.'.GIF';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $filename;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
32
vendor/akdelf/akdmin/lib/rabbit.php
vendored
Normal file
32
vendor/akdelf/akdmin/lib/rabbit.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
|
||||
function add_q($table, $id) {
|
||||
|
||||
$fconfig = '/vhosts/adanar.argumenti.ru/config/config.json';
|
||||
|
||||
$set = json_decode(file_get_contents($fconfig), True);
|
||||
$config = $set['rabbit'];
|
||||
|
||||
$data = json_encode(['table' => $table, 'id' => $id]);
|
||||
|
||||
return;
|
||||
|
||||
$rabbit_key = 'adanar_update';
|
||||
|
||||
$rabbit = new AMQPConnection($config);
|
||||
$rabbit->connect();
|
||||
|
||||
$testChannel = new AMQPChannel($rabbit);
|
||||
$testExchange = new AMQPExchange($testChannel);
|
||||
|
||||
$testExchange->setName('amq.direct');
|
||||
|
||||
$data = json_encode(['table' => $table, 'id' => $id]);
|
||||
|
||||
$testExchange->publish($data, $rabbit_key);
|
||||
|
||||
$rabbit->disconnect();
|
||||
|
||||
|
||||
}
|
||||
152
vendor/akdelf/akdmin/lib/table.php
vendored
Normal file
152
vendor/akdelf/akdmin/lib/table.php
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
class ORM {
|
||||
|
||||
|
||||
static $config = array(); //конфиги подключения к базе
|
||||
static $conn = array(); // все подключения
|
||||
|
||||
private $ORM = '';
|
||||
private $conf = 'default';
|
||||
private $filters = array();
|
||||
private $sort = array();
|
||||
private $limit = null;
|
||||
private $columns = '*';
|
||||
|
||||
static function from($ORM, $conf = 'default') {
|
||||
return new ORM($ORM, $conf);
|
||||
}
|
||||
|
||||
|
||||
function __construct($ORM, $conf = 'default'){
|
||||
$this->ORM = $ORM;
|
||||
$this->config = $conf; //текущая конфигурация
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* добавляем конфигурацию подключения к базе
|
||||
*/
|
||||
static function config($name, $host, $user, $pswd){
|
||||
ORM::$config[$name] = array('host'=>$host, 'user'=>$user, 'pswd'=>$pswd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function conn($conf){
|
||||
|
||||
if (!isset(ORM::$conn[$conf])){
|
||||
if (is_array(ORM::$config[$conf])){
|
||||
$config =ORM::$config[$conf];
|
||||
ORM::$conn[$conf] = new mysqli($config['dbhost'], $config['dbuser'],$config['dbpswd'], $config['dbname']);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
return False;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* функции добавления
|
||||
*/
|
||||
|
||||
function separ($value){
|
||||
return '`'.$value.'`';
|
||||
}
|
||||
|
||||
function quote($value){
|
||||
return chr(39).$value.chr(39);
|
||||
}
|
||||
|
||||
function add($column){
|
||||
$this->columns[] = $column;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function columns($columns = array()){
|
||||
$this->columns = $columns;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function filter($column, $value, $op ='=', $type = 'AND') {
|
||||
$this->filters[] = array('column'=>$column, 'value'=>$value, 'op'=>$op, 'type'=>$type);
|
||||
return $this;
|
||||
}
|
||||
|
||||
function sort($column, $type = 'ASC') {
|
||||
$this->sort[$column] = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function build(){
|
||||
|
||||
$sql = 'SELECT';
|
||||
|
||||
|
||||
$sql .= ' '.$this->columns.' FROM '.$this->separ($this->ORM);
|
||||
$sql .= $this->build_filters();
|
||||
$sql .= $this->build_sort();
|
||||
|
||||
if ($this->limit !== null)
|
||||
$sql .= 'LIMIT '.$this->limit;
|
||||
|
||||
$sql .= ';';
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function build_filters(){
|
||||
|
||||
$res = '';
|
||||
|
||||
foreach ($this->filters as $filter){
|
||||
|
||||
if ($res !== '')
|
||||
$res .= ' '.$filter['type'].' ';
|
||||
|
||||
$res .= $this->separ($filter['column']).$filter['op'].$this->quote($filter['value']);
|
||||
|
||||
}
|
||||
|
||||
return ' WHERE '.$res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function build_sort(){
|
||||
|
||||
$res = '';
|
||||
|
||||
foreach ($this->sort as $key => $sort){
|
||||
|
||||
if ($res !== '')
|
||||
$res = ',';
|
||||
|
||||
$res .= $this->separ($key).' '.$sort;
|
||||
}
|
||||
|
||||
return ' ORDER BY '.$res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function all() {
|
||||
|
||||
$sql = $this->build();
|
||||
$result = $this->query($sql)->fetch();
|
||||
var_dump($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static function query($sql){
|
||||
$this->conn();
|
||||
return ORM::$conn[$conf]->query($sql);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
128
vendor/akdelf/akdmin/lib/tipograf.php
vendored
Normal file
128
vendor/akdelf/akdmin/lib/tipograf.php
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
<?
|
||||
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
|
||||
define('NOBRSPACE', "\x03");
|
||||
define('NOBRHYPHEN', "\x04");
|
||||
define('THINSP', "\x05");
|
||||
define('DASH', "\x06");
|
||||
define('NUMDASH', "\x07");
|
||||
|
||||
|
||||
|
||||
function entity_code($text,$ctype){
|
||||
$htmlents = array(
|
||||
'„'=>'„','‛'=>'“','“'=>'”','‘'=>'‘','’'=>'’',
|
||||
'«'=>'«','»'=>'»','…'=>'…','€'=>'€','‰'=>'‰',
|
||||
'•'=>'•','·'=>'·','–'=>'–','—'=>'—',' '=>' ',
|
||||
'™'=>'™','©'=>'©','®'=>'®','§'=>'§','№'=>'№',
|
||||
'±'=>'±','°'=>'°');
|
||||
|
||||
if (ctype == 0)
|
||||
$text = strtr($text, $htmlents ); // Делаем замены html entity на символы из cp1251
|
||||
else {
|
||||
$text = strtr($text, array_flip($htmlents)); // Делаем замены на html-entity
|
||||
$text = str_replace( '"','"', $text ); // Заменяем " на "
|
||||
$text = str_replace( "'",''', $text ); // Заменяем ' на '
|
||||
}
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function tipograf($text, $type, $stylekill)
|
||||
{
|
||||
|
||||
|
||||
//ОБЩИЕ
|
||||
// $text = entity_code($text,0); //замены сущностей
|
||||
// $text = str_replace( ' ',' ', $text);//преобразовываем пробелы
|
||||
$text = trim($text); // начальные и конечные пробелы
|
||||
|
||||
|
||||
//обработка стилистики тегов
|
||||
if ($stylekill) {
|
||||
//работа с тегами
|
||||
$text = preg_replace("!<div[^>]*?>(.*?)</div>!si","<p>\\1</p>",$text);
|
||||
$text = preg_replace("!<strong[^>]*?>(.*?)</strong>!si","<b>\\1</b>",$text);
|
||||
$text = preg_replace("!<em[^>]*?>(.*?)</em>!si","<i>\\1</i>",$text);
|
||||
|
||||
//вырезаем ненужные теги
|
||||
$text = strip_tags($text,"<b><i><p><br><ul><ol><li><img>");
|
||||
}
|
||||
|
||||
|
||||
if ($type == 'tags') {
|
||||
$text = nl2br($text);// разрывы строк на <br />
|
||||
$text = preg_replace( "'<br ?/?>'", '</p><p>', $text ); //преобразуем переносы в параграфы
|
||||
$text = preg_replace("'<p.*?>(.*?)</p>'si","<p>\\1</p>",$text); //убиваем стилистики абзацев
|
||||
$text = preg_replace( "'<p>(.*?)<(.*?)> *</\\2>(.*?)</p>'si", '<p>\\1\\3</p>', $text ); //убиваем пустые вложенные теги
|
||||
$text = preg_replace("'<p> +(.*?)</p>'",'<p> \\1</p>', $text);//пробелы в начале абазца преобразовываем в табуляцию<p>
|
||||
$text = preg_replace("'<p>(.*?) +</p>'",'<p>\\1</p>', $text);//убиваем пробелы в конце <p>
|
||||
$text = preg_replace( "'</p> +<p>'", '</p><p>', $text );//убиваем пробелы между параграфами
|
||||
$text = preg_replace( "'<([a-zA-Z]+)>[ | ]*</\\1>'", '', $text ); //убиваем пустые теги или теги из пробелов
|
||||
}
|
||||
|
||||
|
||||
//работа с текстом
|
||||
$text = preg_replace( "'\.{3}'", '…', $text); //Многоточие
|
||||
// $text = preg_replace("'\.+'",'.',$text); // двойные точки
|
||||
$text = preg_replace("'\,+'",',',$text); // двойные запятые
|
||||
$text = preg_replace("'\;+'",';',$text); // двойные ;
|
||||
$text = preg_replace("'\:+'",':',$text); // двойные :
|
||||
|
||||
$text = preg_replace( "' +'", ' ', $text); // Убираем лишние пробелы
|
||||
$text = preg_replace( "'\t+'", ' ', $text); // Убираем лишние табуляторы
|
||||
$text = preg_replace( '/\( *([^)]+?) *\)/', '(\\1)', $text ); // удаляем пробелы после открывающей скобки и перед закрыващей скобкой
|
||||
$text = preg_replace( '/([а-яА-ЯёЁa-zA-Z.,!?:;…])\(/', '\\1 (', $text ); // добавляем пробел между словом и открывающей скобкой, если его
|
||||
|
||||
//знаки припинания
|
||||
$text = preg_replace("' ?(\.|,|\!|\?)'",'\\1', $text ); // Убираем пробелы перед знаками препинания*/
|
||||
$text = preg_replace("'(\w+),(\w+)'",'\\1, \\2', $text); // Пробелы после знаков препинания
|
||||
$text = preg_replace("'(\d+), ?(\d+)'",'\\1,\\2', $text); // Пробелы между цифрами
|
||||
|
||||
//$text = preg_replace( "'(\S+)-(\S+)'", '<nobr>$1-$2</nobr>', $text ); //не обрывать слова, написанные через дефис
|
||||
|
||||
|
||||
// Русские денежные суммы, расставляя пробелы в нужных местах.
|
||||
$text = preg_replace( '~(\d+)\s?(руб.)~s','$1 $2', $text );
|
||||
$text = preg_replace( '~(\d+)\s?(млн.|тыс.)?\s?(руб.)~s','$1 $2 $3', $text );
|
||||
|
||||
//праивльное обозначение размера
|
||||
$text = preg_replace( '~(\d+)[x|X|х|Х|*](\d+)~','$1×$2', $text );
|
||||
|
||||
//спецсимволы
|
||||
$text = preg_replace( '/\((c|C|с|С)\)/','©', $text);//копирант
|
||||
$text = str_replace( '(tm)','™', $text );
|
||||
$text = str_replace( '(TM)','™', $text ); // trademark
|
||||
|
||||
//неразрывать
|
||||
$text = preg_replace( "'(\w\.)\s?(\w\.)\s(\w\w+)'", '$1 $2 $3', $text ); // Инициалы + фамилия
|
||||
$text = preg_replace( "'(\w\w+)\s?(\w\.)\s(\w\.)'", '$1 $2 $3', $text ); // фамилия + инициалы
|
||||
$text = preg_replace("'(\W\w\.)\s(\w\w+)'",'$1 $2',$text); //один инициал + фамилия
|
||||
|
||||
//последние обработки
|
||||
$text = str_replace( '!?','?!', $text ); // Правильно в таком порядке
|
||||
$text = str_replace( '№ №', '№№', $text ); // слитное написание "№№"
|
||||
$text = str_replace( '§ §', '§§', $text ); // слитное написание "§§"
|
||||
|
||||
$text = entity_code($text,1); //обратные замены
|
||||
|
||||
$text = str_replace( '',' ', $text);//старые косяки
|
||||
$text = str_replace( '',' ', $text);//старые косяки
|
||||
|
||||
return $text;
|
||||
|
||||
|
||||
//убийца шрифтов
|
||||
/*$text = preg_replace("!<font[^>]*?>(.*?)</font>!si","\\1",$text); //убиваем стилистики абзацев
|
||||
$text = preg_replace("!<span[^>]*?>(.*?)</span>!si","\\1",$text); //убиваем стилистики абзацев*/
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
653
vendor/akdelf/akdmin/lib/utf8_ents.php
vendored
Normal file
653
vendor/akdelf/akdmin/lib/utf8_ents.php
vendored
Normal file
@@ -0,0 +1,653 @@
|
||||
<?
|
||||
/**
|
||||
* Converts a UNICODE codepoint to a UTF-8 character
|
||||
*
|
||||
* @param int $cp Unicode codepoint
|
||||
* @return string UTF-8 character
|
||||
*
|
||||
* @license http://creativecommons.org/licenses/by-sa/3.0/
|
||||
* @author Nasibullin Rinat, http://orangetie.ru/
|
||||
* @charset ANSI
|
||||
* @version 1.0.0
|
||||
*/
|
||||
function utf8_chr($cp) # = utf8_from_unicode() or unicode_to_utf8()
|
||||
{
|
||||
static $cache = array();
|
||||
$cp = intval($cp);
|
||||
if (array_key_exists($cp, $cache)) return $cache[$cp]; #speed improve
|
||||
|
||||
if ($cp <= 0x7f) return $cache[$cp] = chr($cp);
|
||||
if ($cp <= 0x7ff) return $cache[$cp] = chr(0xc0 | ($cp >> 6)) .
|
||||
chr(0x80 | ($cp & 0x3f));
|
||||
if ($cp <= 0xffff) return $cache[$cp] = chr(0xe0 | ($cp >> 12)) .
|
||||
chr(0x80 | (($cp >> 6) & 0x3f)) .
|
||||
chr(0x80 | ($cp & 0x3f));
|
||||
if ($cp <= 0x10ffff) return $cache[$cp] = chr(0xf0 | ($cp >> 18)) .
|
||||
chr(0x80 | (($cp >> 12) & 0x3f)) .
|
||||
chr(0x80 | (($cp >> 6) & 0x3f)) .
|
||||
chr(0x80 | ($cp & 0x3f));
|
||||
#U+FFFD REPLACEMENT CHARACTER
|
||||
return $cache[$cp] = "\xEF\xBF\xBD";
|
||||
}
|
||||
|
||||
|
||||
function utf8_html_entity_encode($s)
|
||||
{
|
||||
$table = array_flip(array(
|
||||
#Latin-1 Entities:
|
||||
' ' => "\xc2\xa0", #no-break space = non-breaking space
|
||||
'¡' => "\xc2\xa1", #inverted exclamation mark
|
||||
'¢' => "\xc2\xa2", #cent sign
|
||||
'£' => "\xc2\xa3", #pound sign
|
||||
'¤' => "\xc2\xa4", #currency sign
|
||||
'¥' => "\xc2\xa5", #yen sign = yuan sign
|
||||
'¦' => "\xc2\xa6", #broken bar = broken vertical bar
|
||||
'§' => "\xc2\xa7", #section sign
|
||||
'¨' => "\xc2\xa8", #diaeresis = spacing diaeresis
|
||||
'©' => "\xc2\xa9", #copyright sign
|
||||
'ª' => "\xc2\xaa", #feminine ordinal indicator
|
||||
'«' => "\xc2\xab", #left-pointing double angle quotation mark = left pointing guillemet («)
|
||||
'¬' => "\xc2\xac", #not sign
|
||||
'­' => "\xc2\xad", #soft hyphen = discretionary hyphen;
|
||||
#non-breaking hyphen (неразрывный дефис): "\xe2\x80\x91" (U+2011)
|
||||
'®' => "\xc2\xae", #registered sign = registered trade mark sign
|
||||
'¯' => "\xc2\xaf", #macron = spacing macron = overline = APL overbar
|
||||
'°' => "\xc2\xb0", #degree sign
|
||||
'±' => "\xc2\xb1", #plus-minus sign = plus-or-minus sign
|
||||
'²' => "\xc2\xb2", #superscript two = superscript digit two = squared
|
||||
'³' => "\xc2\xb3", #superscript three = superscript digit three = cubed
|
||||
'´' => "\xc2\xb4", #acute accent = spacing acute
|
||||
'µ' => "\xc2\xb5", #micro sign
|
||||
'¶' => "\xc2\xb6", #pilcrow sign = paragraph sign
|
||||
'·' => "\xc2\xb7", #middle dot = Georgian comma = Greek middle dot
|
||||
'¸' => "\xc2\xb8", #cedilla = spacing cedilla
|
||||
'¹' => "\xc2\xb9", #superscript one = superscript digit one
|
||||
'º' => "\xc2\xba", #masculine ordinal indicator
|
||||
'»' => "\xc2\xbb", #right-pointing double angle quotation mark = right pointing guillemet (ї)
|
||||
'¼' => "\xc2\xbc", #vulgar fraction one quarter = fraction one quarter
|
||||
'½' => "\xc2\xbd", #vulgar fraction one half = fraction one half
|
||||
'¾' => "\xc2\xbe", #vulgar fraction three quarters = fraction three quarters
|
||||
'¿' => "\xc2\xbf", #inverted question mark = turned question mark
|
||||
#Latin capital letter
|
||||
'À' => "\xc3\x80", #Latin capital letter A with grave = Latin capital letter A grave
|
||||
'Á' => "\xc3\x81", #Latin capital letter A with acute
|
||||
'Â' => "\xc3\x82", #Latin capital letter A with circumflex
|
||||
'Ã' => "\xc3\x83", #Latin capital letter A with tilde
|
||||
'Ä' => "\xc3\x84", #Latin capital letter A with diaeresis
|
||||
'Å' => "\xc3\x85", #Latin capital letter A with ring above = Latin capital letter A ring
|
||||
'Æ' => "\xc3\x86", #Latin capital letter AE = Latin capital ligature AE
|
||||
'Ç' => "\xc3\x87", #Latin capital letter C with cedilla
|
||||
'È' => "\xc3\x88", #Latin capital letter E with grave
|
||||
'É' => "\xc3\x89", #Latin capital letter E with acute
|
||||
'Ê' => "\xc3\x8a", #Latin capital letter E with circumflex
|
||||
'Ë' => "\xc3\x8b", #Latin capital letter E with diaeresis
|
||||
'Ì' => "\xc3\x8c", #Latin capital letter I with grave
|
||||
'Í' => "\xc3\x8d", #Latin capital letter I with acute
|
||||
'Î' => "\xc3\x8e", #Latin capital letter I with circumflex
|
||||
'Ï' => "\xc3\x8f", #Latin capital letter I with diaeresis
|
||||
'Ð' => "\xc3\x90", #Latin capital letter ETH
|
||||
'Ñ' => "\xc3\x91", #Latin capital letter N with tilde
|
||||
'Ò' => "\xc3\x92", #Latin capital letter O with grave
|
||||
'Ó' => "\xc3\x93", #Latin capital letter O with acute
|
||||
'Ô' => "\xc3\x94", #Latin capital letter O with circumflex
|
||||
'Õ' => "\xc3\x95", #Latin capital letter O with tilde
|
||||
'Ö' => "\xc3\x96", #Latin capital letter O with diaeresis
|
||||
'×' => "\xc3\x97", #multiplication sign
|
||||
'Ø' => "\xc3\x98", #Latin capital letter O with stroke = Latin capital letter O slash
|
||||
'Ù' => "\xc3\x99", #Latin capital letter U with grave
|
||||
'Ú' => "\xc3\x9a", #Latin capital letter U with acute
|
||||
'Û' => "\xc3\x9b", #Latin capital letter U with circumflex
|
||||
'Ü' => "\xc3\x9c", #Latin capital letter U with diaeresis
|
||||
'Ý' => "\xc3\x9d", #Latin capital letter Y with acute
|
||||
'Þ' => "\xc3\x9e", #Latin capital letter THORN
|
||||
#Latin small letter
|
||||
'ß' => "\xc3\x9f", #Latin small letter sharp s = ess-zed
|
||||
'à' => "\xc3\xa0", #Latin small letter a with grave = Latin small letter a grave
|
||||
'á' => "\xc3\xa1", #Latin small letter a with acute
|
||||
'â' => "\xc3\xa2", #Latin small letter a with circumflex
|
||||
'ã' => "\xc3\xa3", #Latin small letter a with tilde
|
||||
'ä' => "\xc3\xa4", #Latin small letter a with diaeresis
|
||||
'å' => "\xc3\xa5", #Latin small letter a with ring above = Latin small letter a ring
|
||||
'æ' => "\xc3\xa6", #Latin small letter ae = Latin small ligature ae
|
||||
'ç' => "\xc3\xa7", #Latin small letter c with cedilla
|
||||
'è' => "\xc3\xa8", #Latin small letter e with grave
|
||||
'é' => "\xc3\xa9", #Latin small letter e with acute
|
||||
'ê' => "\xc3\xaa", #Latin small letter e with circumflex
|
||||
'ë' => "\xc3\xab", #Latin small letter e with diaeresis
|
||||
'ì' => "\xc3\xac", #Latin small letter i with grave
|
||||
'í' => "\xc3\xad", #Latin small letter i with acute
|
||||
'î' => "\xc3\xae", #Latin small letter i with circumflex
|
||||
'ï' => "\xc3\xaf", #Latin small letter i with diaeresis
|
||||
'ð' => "\xc3\xb0", #Latin small letter eth
|
||||
'ñ' => "\xc3\xb1", #Latin small letter n with tilde
|
||||
'ò' => "\xc3\xb2", #Latin small letter o with grave
|
||||
'ó' => "\xc3\xb3", #Latin small letter o with acute
|
||||
'ô' => "\xc3\xb4", #Latin small letter o with circumflex
|
||||
'õ' => "\xc3\xb5", #Latin small letter o with tilde
|
||||
'ö' => "\xc3\xb6", #Latin small letter o with diaeresis
|
||||
'÷' => "\xc3\xb7", #division sign
|
||||
'ø' => "\xc3\xb8", #Latin small letter o with stroke = Latin small letter o slash
|
||||
'ù' => "\xc3\xb9", #Latin small letter u with grave
|
||||
'ú' => "\xc3\xba", #Latin small letter u with acute
|
||||
'û' => "\xc3\xbb", #Latin small letter u with circumflex
|
||||
'ü' => "\xc3\xbc", #Latin small letter u with diaeresis
|
||||
'ý' => "\xc3\xbd", #Latin small letter y with acute
|
||||
'þ' => "\xc3\xbe", #Latin small letter thorn
|
||||
'ÿ' => "\xc3\xbf", #Latin small letter y with diaeresis
|
||||
#Symbols and Greek Letters:
|
||||
'ƒ' => "\xc6\x92", #Latin small f with hook = function = florin
|
||||
'Α' => "\xce\x91", #Greek capital letter alpha
|
||||
'Β' => "\xce\x92", #Greek capital letter beta
|
||||
'Γ' => "\xce\x93", #Greek capital letter gamma
|
||||
'Δ' => "\xce\x94", #Greek capital letter delta
|
||||
'Ε' => "\xce\x95", #Greek capital letter epsilon
|
||||
'Ζ' => "\xce\x96", #Greek capital letter zeta
|
||||
'Η' => "\xce\x97", #Greek capital letter eta
|
||||
'Θ' => "\xce\x98", #Greek capital letter theta
|
||||
'Ι' => "\xce\x99", #Greek capital letter iota
|
||||
'Κ' => "\xce\x9a", #Greek capital letter kappa
|
||||
'Λ' => "\xce\x9b", #Greek capital letter lambda
|
||||
'Μ' => "\xce\x9c", #Greek capital letter mu
|
||||
'Ν' => "\xce\x9d", #Greek capital letter nu
|
||||
'Ξ' => "\xce\x9e", #Greek capital letter xi
|
||||
'Ο' => "\xce\x9f", #Greek capital letter omicron
|
||||
'Π' => "\xce\xa0", #Greek capital letter pi
|
||||
'Ρ' => "\xce\xa1", #Greek capital letter rho
|
||||
'Σ' => "\xce\xa3", #Greek capital letter sigma
|
||||
'Τ' => "\xce\xa4", #Greek capital letter tau
|
||||
'Υ' => "\xce\xa5", #Greek capital letter upsilon
|
||||
'Φ' => "\xce\xa6", #Greek capital letter phi
|
||||
'Χ' => "\xce\xa7", #Greek capital letter chi
|
||||
'Ψ' => "\xce\xa8", #Greek capital letter psi
|
||||
'Ω' => "\xce\xa9", #Greek capital letter omega
|
||||
'α' => "\xce\xb1", #Greek small letter alpha
|
||||
'β' => "\xce\xb2", #Greek small letter beta
|
||||
'γ' => "\xce\xb3", #Greek small letter gamma
|
||||
'δ' => "\xce\xb4", #Greek small letter delta
|
||||
'ε' => "\xce\xb5", #Greek small letter epsilon
|
||||
'ζ' => "\xce\xb6", #Greek small letter zeta
|
||||
'η' => "\xce\xb7", #Greek small letter eta
|
||||
'θ' => "\xce\xb8", #Greek small letter theta
|
||||
'ι' => "\xce\xb9", #Greek small letter iota
|
||||
'κ' => "\xce\xba", #Greek small letter kappa
|
||||
'λ' => "\xce\xbb", #Greek small letter lambda
|
||||
'μ' => "\xce\xbc", #Greek small letter mu
|
||||
'ν' => "\xce\xbd", #Greek small letter nu
|
||||
'ξ' => "\xce\xbe", #Greek small letter xi
|
||||
'ο' => "\xce\xbf", #Greek small letter omicron
|
||||
'π' => "\xcf\x80", #Greek small letter pi
|
||||
'ρ' => "\xcf\x81", #Greek small letter rho
|
||||
'ς' => "\xcf\x82", #Greek small letter final sigma
|
||||
'σ' => "\xcf\x83", #Greek small letter sigma
|
||||
'τ' => "\xcf\x84", #Greek small letter tau
|
||||
'υ' => "\xcf\x85", #Greek small letter upsilon
|
||||
'φ' => "\xcf\x86", #Greek small letter phi
|
||||
'χ' => "\xcf\x87", #Greek small letter chi
|
||||
'ψ' => "\xcf\x88", #Greek small letter psi
|
||||
'ω' => "\xcf\x89", #Greek small letter omega
|
||||
'ϑ'=> "\xcf\x91", #Greek small letter theta symbol
|
||||
'ϒ' => "\xcf\x92", #Greek upsilon with hook symbol
|
||||
'ϖ' => "\xcf\x96", #Greek pi symbol
|
||||
|
||||
'•' => "\xe2\x80\xa2", #bullet = black small circle
|
||||
'…' => "\xe2\x80\xa6", #horizontal ellipsis = three dot leader
|
||||
'′' => "\xe2\x80\xb2", #prime = minutes = feet (для обозначения минут и футов)
|
||||
'″' => "\xe2\x80\xb3", #double prime = seconds = inches (для обозначения секунд и діймов).
|
||||
'‾' => "\xe2\x80\xbe", #overline = spacing overscore
|
||||
'⁄' => "\xe2\x81\x84", #fraction slash
|
||||
'℘' => "\xe2\x84\x98", #script capital P = power set = Weierstrass p
|
||||
'ℑ' => "\xe2\x84\x91", #blackletter capital I = imaginary part
|
||||
'ℜ' => "\xe2\x84\x9c", #blackletter capital R = real part symbol
|
||||
'™' => "\xe2\x84\xa2", #trade mark sign
|
||||
'ℵ' => "\xe2\x84\xb5", #alef symbol = first transfinite cardinal
|
||||
'←' => "\xe2\x86\x90", #leftwards arrow
|
||||
'↑' => "\xe2\x86\x91", #upwards arrow
|
||||
'→' => "\xe2\x86\x92", #rightwards arrow
|
||||
'↓' => "\xe2\x86\x93", #downwards arrow
|
||||
'↔' => "\xe2\x86\x94", #left right arrow
|
||||
'↵' => "\xe2\x86\xb5", #downwards arrow with corner leftwards = carriage return
|
||||
'⇐' => "\xe2\x87\x90", #leftwards double arrow
|
||||
'⇑' => "\xe2\x87\x91", #upwards double arrow
|
||||
'⇒' => "\xe2\x87\x92", #rightwards double arrow
|
||||
'⇓' => "\xe2\x87\x93", #downwards double arrow
|
||||
'⇔' => "\xe2\x87\x94", #left right double arrow
|
||||
'∀' => "\xe2\x88\x80", #for all
|
||||
'∂' => "\xe2\x88\x82", #partial differential
|
||||
'∃' => "\xe2\x88\x83", #there exists
|
||||
'∅' => "\xe2\x88\x85", #empty set = null set = diameter
|
||||
'∇' => "\xe2\x88\x87", #nabla = backward difference
|
||||
'∈' => "\xe2\x88\x88", #element of
|
||||
'∉' => "\xe2\x88\x89", #not an element of
|
||||
'∋' => "\xe2\x88\x8b", #contains as member
|
||||
'∏' => "\xe2\x88\x8f", #n-ary product = product sign
|
||||
'∑' => "\xe2\x88\x91", #n-ary sumation
|
||||
'−' => "\xe2\x88\x92", #minus sign
|
||||
'∗' => "\xe2\x88\x97", #asterisk operator
|
||||
'√' => "\xe2\x88\x9a", #square root = radical sign
|
||||
'∝' => "\xe2\x88\x9d", #proportional to
|
||||
'∞' => "\xe2\x88\x9e", #infinity
|
||||
'∠' => "\xe2\x88\xa0", #angle
|
||||
'∧' => "\xe2\x88\xa7", #logical and = wedge
|
||||
'∨' => "\xe2\x88\xa8", #logical or = vee
|
||||
'∩' => "\xe2\x88\xa9", #intersection = cap
|
||||
'∪' => "\xe2\x88\xaa", #union = cup
|
||||
'∫' => "\xe2\x88\xab", #integral
|
||||
'∴' => "\xe2\x88\xb4", #therefore
|
||||
'∼' => "\xe2\x88\xbc", #tilde operator = varies with = similar to
|
||||
'≅' => "\xe2\x89\x85", #approximately equal to
|
||||
'≈' => "\xe2\x89\x88", #almost equal to = asymptotic to
|
||||
'≠' => "\xe2\x89\xa0", #not equal to
|
||||
'≡' => "\xe2\x89\xa1", #identical to
|
||||
'≤' => "\xe2\x89\xa4", #less-than or equal to
|
||||
'≥' => "\xe2\x89\xa5", #greater-than or equal to
|
||||
'⊂' => "\xe2\x8a\x82", #subset of
|
||||
'⊃' => "\xe2\x8a\x83", #superset of
|
||||
'⊄' => "\xe2\x8a\x84", #not a subset of
|
||||
'⊆' => "\xe2\x8a\x86", #subset of or equal to
|
||||
'⊇' => "\xe2\x8a\x87", #superset of or equal to
|
||||
'⊕' => "\xe2\x8a\x95", #circled plus = direct sum
|
||||
'⊗' => "\xe2\x8a\x97", #circled times = vector product
|
||||
'⊥' => "\xe2\x8a\xa5", #up tack = orthogonal to = perpendicular
|
||||
'⋅' => "\xe2\x8b\x85", #dot operator
|
||||
'⌈' => "\xe2\x8c\x88", #left ceiling = APL upstile
|
||||
'⌉' => "\xe2\x8c\x89", #right ceiling
|
||||
'⌊' => "\xe2\x8c\x8a", #left floor = APL downstile
|
||||
'⌋' => "\xe2\x8c\x8b", #right floor
|
||||
'⟨' => "\xe2\x8c\xa9", #left-pointing angle bracket = bra
|
||||
'⟩' => "\xe2\x8c\xaa", #right-pointing angle bracket = ket
|
||||
'◊' => "\xe2\x97\x8a", #lozenge
|
||||
'♠' => "\xe2\x99\xa0", #black spade suit
|
||||
'♣' => "\xe2\x99\xa3", #black club suit = shamrock
|
||||
'♥' => "\xe2\x99\xa5", #black heart suit = valentine
|
||||
'♦' => "\xe2\x99\xa6", #black diamond suit
|
||||
#Other Special Characters:
|
||||
'Œ' => "\xc5\x92", #Latin capital ligature OE
|
||||
'œ' => "\xc5\x93", #Latin small ligature oe
|
||||
'Š' => "\xc5\xa0", #Latin capital letter S with caron
|
||||
'š' => "\xc5\xa1", #Latin small letter s with caron
|
||||
'Ÿ' => "\xc5\xb8", #Latin capital letter Y with diaeresis
|
||||
'ˆ' => "\xcb\x86", #modifier letter circumflex accent
|
||||
'˜' => "\xcb\x9c", #small tilde
|
||||
' ' => "\xe2\x80\x82", #en space
|
||||
' ' => "\xe2\x80\x83", #em space
|
||||
' ' => "\xe2\x80\x89", #thin space
|
||||
'‌' => "\xe2\x80\x8c", #zero width non-joiner
|
||||
'‍' => "\xe2\x80\x8d", #zero width joiner
|
||||
'‎' => "\xe2\x80\x8e", #left-to-right mark
|
||||
'‏' => "\xe2\x80\x8f", #right-to-left mark
|
||||
'–' => "\xe2\x80\x93", #en dash
|
||||
'—' => "\xe2\x80\x94", #em dash
|
||||
'‘' => "\xe2\x80\x98", #left single quotation mark
|
||||
'’' => "\xe2\x80\x99", #right single quotation mark (and apostrophe!)
|
||||
'‚' => "\xe2\x80\x9a", #single low-9 quotation mark
|
||||
'“' => "\xe2\x80\x9c", #left double quotation mark
|
||||
'”' => "\xe2\x80\x9d", #right double quotation mark
|
||||
'„' => "\xe2\x80\x9e", #double low-9 quotation mark
|
||||
'†' => "\xe2\x80\xa0", #dagger
|
||||
'‡' => "\xe2\x80\xa1", #double dagger
|
||||
'‰' => "\xe2\x80\xb0", #per mille sign
|
||||
'‹' => "\xe2\x80\xb9", #single left-pointing angle quotation mark
|
||||
'›' => "\xe2\x80\xba", #single right-pointing angle quotation mark
|
||||
'€' => "\xe2\x82\xac"
|
||||
));
|
||||
|
||||
|
||||
$s = str_replace("\x22", '"', $s);
|
||||
//$s = str_replace("\x3c", '<', $s);
|
||||
//$s = str_replace("\x3e", '>', $s);
|
||||
|
||||
#заменяем utf8-символы на именованные сущности:
|
||||
#оптимизация скорости: заменяем только те символы, которые используются в html коде!
|
||||
preg_match_all('/ [\xc2\xc3\xc5\xc6\xcb\xce\xcf][\x80-\xbf] #2 bytes
|
||||
| \xe2[\x80-\x99][\x82-\xac] #3 bytes
|
||||
/sxSX', $s, $m);
|
||||
foreach (array_unique($m[0]) as $char)
|
||||
{
|
||||
if (array_key_exists($char, $table)) $s = str_replace($char, $table[$char], $s);
|
||||
}#foreach
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert all HTML entities to native UTF-8 characters
|
||||
* Функция декодирует гораздо больше именованных сущностей, чем стандартная html_entity_decode()
|
||||
* Все dec и hex сущности так же переводятся в UTF-8.
|
||||
*
|
||||
* Example: '"' or '"' or '"' will be converted to '"'.
|
||||
*
|
||||
* @param string $s
|
||||
* @param bool $is_htmlspecialchars обрабатывать специальные html сущности? (< > & ")
|
||||
* @return string
|
||||
* @link http://www.htmlhelp.com/reference/html40/entities/
|
||||
* @link http://www.alanwood.net/demos/ent4_frame.html (HTML 4.01 Character Entity References)
|
||||
* @link http://msdn.microsoft.com/workshop/author/dhtml/reference/charsets/charset1.asp?frame=true
|
||||
* @link http://msdn.microsoft.com/workshop/author/dhtml/reference/charsets/charset2.asp?frame=true
|
||||
* @link http://msdn.microsoft.com/workshop/author/dhtml/reference/charsets/charset3.asp?frame=true
|
||||
*
|
||||
* @license http://creativecommons.org/licenses/by-sa/3.0/
|
||||
* @author Nasibullin Rinat, http://orangetie.ru/
|
||||
* @charset ANSI
|
||||
* @version 2.1.12
|
||||
*/
|
||||
function utf8_html_entity_decode($s, $is_htmlspecialchars = false)
|
||||
{
|
||||
#оптимизация скорости
|
||||
if (strlen($s) < 4 #по минимальной длине сущности - 4 байта: &#d; &xx;
|
||||
|| ($pos = strpos($s, '&') === false) || strpos($s, ';', $pos) === false) return $s;
|
||||
$table = array(
|
||||
#Latin-1 Entities:
|
||||
' ' => "\xc2\xa0", #no-break space = non-breaking space
|
||||
'¡' => "\xc2\xa1", #inverted exclamation mark
|
||||
'¢' => "\xc2\xa2", #cent sign
|
||||
'£' => "\xc2\xa3", #pound sign
|
||||
'¤' => "\xc2\xa4", #currency sign
|
||||
'¥' => "\xc2\xa5", #yen sign = yuan sign
|
||||
'¦' => "\xc2\xa6", #broken bar = broken vertical bar
|
||||
'§' => "\xc2\xa7", #section sign
|
||||
'¨' => "\xc2\xa8", #diaeresis = spacing diaeresis
|
||||
'©' => "\xc2\xa9", #copyright sign
|
||||
'ª' => "\xc2\xaa", #feminine ordinal indicator
|
||||
'«' => "\xc2\xab", #left-pointing double angle quotation mark = left pointing guillemet («)
|
||||
'¬' => "\xc2\xac", #not sign
|
||||
'­' => "\xc2\xad", #soft hyphen = discretionary hyphen
|
||||
'®' => "\xc2\xae", #registered sign = registered trade mark sign
|
||||
'¯' => "\xc2\xaf", #macron = spacing macron = overline = APL overbar
|
||||
'°' => "\xc2\xb0", #degree sign
|
||||
'±' => "\xc2\xb1", #plus-minus sign = plus-or-minus sign
|
||||
'²' => "\xc2\xb2", #superscript two = superscript digit two = squared
|
||||
'³' => "\xc2\xb3", #superscript three = superscript digit three = cubed
|
||||
'´' => "\xc2\xb4", #acute accent = spacing acute
|
||||
'µ' => "\xc2\xb5", #micro sign
|
||||
'¶' => "\xc2\xb6", #pilcrow sign = paragraph sign
|
||||
'·' => "\xc2\xb7", #middle dot = Georgian comma = Greek middle dot
|
||||
'¸' => "\xc2\xb8", #cedilla = spacing cedilla
|
||||
'¹' => "\xc2\xb9", #superscript one = superscript digit one
|
||||
'º' => "\xc2\xba", #masculine ordinal indicator
|
||||
'»' => "\xc2\xbb", #right-pointing double angle quotation mark = right pointing guillemet (»)
|
||||
'¼' => "\xc2\xbc", #vulgar fraction one quarter = fraction one quarter
|
||||
'½' => "\xc2\xbd", #vulgar fraction one half = fraction one half
|
||||
'¾' => "\xc2\xbe", #vulgar fraction three quarters = fraction three quarters
|
||||
'¿' => "\xc2\xbf", #inverted question mark = turned question mark
|
||||
#Latin capital letter
|
||||
'À' => "\xc3\x80", #Latin capital letter A with grave = Latin capital letter A grave
|
||||
'Á' => "\xc3\x81", #Latin capital letter A with acute
|
||||
'Â' => "\xc3\x82", #Latin capital letter A with circumflex
|
||||
'Ã' => "\xc3\x83", #Latin capital letter A with tilde
|
||||
'Ä' => "\xc3\x84", #Latin capital letter A with diaeresis
|
||||
'Å' => "\xc3\x85", #Latin capital letter A with ring above = Latin capital letter A ring
|
||||
'Æ' => "\xc3\x86", #Latin capital letter AE = Latin capital ligature AE
|
||||
'Ç' => "\xc3\x87", #Latin capital letter C with cedilla
|
||||
'È' => "\xc3\x88", #Latin capital letter E with grave
|
||||
'É' => "\xc3\x89", #Latin capital letter E with acute
|
||||
'Ê' => "\xc3\x8a", #Latin capital letter E with circumflex
|
||||
'Ë' => "\xc3\x8b", #Latin capital letter E with diaeresis
|
||||
'Ì' => "\xc3\x8c", #Latin capital letter I with grave
|
||||
'Í' => "\xc3\x8d", #Latin capital letter I with acute
|
||||
'Î' => "\xc3\x8e", #Latin capital letter I with circumflex
|
||||
'Ï' => "\xc3\x8f", #Latin capital letter I with diaeresis
|
||||
'Ð' => "\xc3\x90", #Latin capital letter ETH
|
||||
'Ñ' => "\xc3\x91", #Latin capital letter N with tilde
|
||||
'Ò' => "\xc3\x92", #Latin capital letter O with grave
|
||||
'Ó' => "\xc3\x93", #Latin capital letter O with acute
|
||||
'Ô' => "\xc3\x94", #Latin capital letter O with circumflex
|
||||
'Õ' => "\xc3\x95", #Latin capital letter O with tilde
|
||||
'Ö' => "\xc3\x96", #Latin capital letter O with diaeresis
|
||||
'×' => "\xc3\x97", #multiplication sign
|
||||
'Ø' => "\xc3\x98", #Latin capital letter O with stroke = Latin capital letter O slash
|
||||
'Ù' => "\xc3\x99", #Latin capital letter U with grave
|
||||
'Ú' => "\xc3\x9a", #Latin capital letter U with acute
|
||||
'Û' => "\xc3\x9b", #Latin capital letter U with circumflex
|
||||
'Ü' => "\xc3\x9c", #Latin capital letter U with diaeresis
|
||||
'Ý' => "\xc3\x9d", #Latin capital letter Y with acute
|
||||
'Þ' => "\xc3\x9e", #Latin capital letter THORN
|
||||
#Latin small letter
|
||||
'ß' => "\xc3\x9f", #Latin small letter sharp s = ess-zed
|
||||
'à' => "\xc3\xa0", #Latin small letter a with grave = Latin small letter a grave
|
||||
'á' => "\xc3\xa1", #Latin small letter a with acute
|
||||
'â' => "\xc3\xa2", #Latin small letter a with circumflex
|
||||
'ã' => "\xc3\xa3", #Latin small letter a with tilde
|
||||
'ä' => "\xc3\xa4", #Latin small letter a with diaeresis
|
||||
'å' => "\xc3\xa5", #Latin small letter a with ring above = Latin small letter a ring
|
||||
'æ' => "\xc3\xa6", #Latin small letter ae = Latin small ligature ae
|
||||
'ç' => "\xc3\xa7", #Latin small letter c with cedilla
|
||||
'è' => "\xc3\xa8", #Latin small letter e with grave
|
||||
'é' => "\xc3\xa9", #Latin small letter e with acute
|
||||
'ê' => "\xc3\xaa", #Latin small letter e with circumflex
|
||||
'ë' => "\xc3\xab", #Latin small letter e with diaeresis
|
||||
'ì' => "\xc3\xac", #Latin small letter i with grave
|
||||
'í' => "\xc3\xad", #Latin small letter i with acute
|
||||
'î' => "\xc3\xae", #Latin small letter i with circumflex
|
||||
'ï' => "\xc3\xaf", #Latin small letter i with diaeresis
|
||||
'ð' => "\xc3\xb0", #Latin small letter eth
|
||||
'ñ' => "\xc3\xb1", #Latin small letter n with tilde
|
||||
'ò' => "\xc3\xb2", #Latin small letter o with grave
|
||||
'ó' => "\xc3\xb3", #Latin small letter o with acute
|
||||
'ô' => "\xc3\xb4", #Latin small letter o with circumflex
|
||||
'õ' => "\xc3\xb5", #Latin small letter o with tilde
|
||||
'ö' => "\xc3\xb6", #Latin small letter o with diaeresis
|
||||
'÷' => "\xc3\xb7", #division sign
|
||||
'ø' => "\xc3\xb8", #Latin small letter o with stroke = Latin small letter o slash
|
||||
'ù' => "\xc3\xb9", #Latin small letter u with grave
|
||||
'ú' => "\xc3\xba", #Latin small letter u with acute
|
||||
'û' => "\xc3\xbb", #Latin small letter u with circumflex
|
||||
'ü' => "\xc3\xbc", #Latin small letter u with diaeresis
|
||||
'ý' => "\xc3\xbd", #Latin small letter y with acute
|
||||
'þ' => "\xc3\xbe", #Latin small letter thorn
|
||||
'ÿ' => "\xc3\xbf", #Latin small letter y with diaeresis
|
||||
#Symbols and Greek Letters:
|
||||
'ƒ' => "\xc6\x92", #Latin small f with hook = function = florin
|
||||
'Α' => "\xce\x91", #Greek capital letter alpha
|
||||
'Β' => "\xce\x92", #Greek capital letter beta
|
||||
'Γ' => "\xce\x93", #Greek capital letter gamma
|
||||
'Δ' => "\xce\x94", #Greek capital letter delta
|
||||
'Ε' => "\xce\x95", #Greek capital letter epsilon
|
||||
'Ζ' => "\xce\x96", #Greek capital letter zeta
|
||||
'Η' => "\xce\x97", #Greek capital letter eta
|
||||
'Θ' => "\xce\x98", #Greek capital letter theta
|
||||
'Ι' => "\xce\x99", #Greek capital letter iota
|
||||
'Κ' => "\xce\x9a", #Greek capital letter kappa
|
||||
'Λ' => "\xce\x9b", #Greek capital letter lambda
|
||||
'Μ' => "\xce\x9c", #Greek capital letter mu
|
||||
'Ν' => "\xce\x9d", #Greek capital letter nu
|
||||
'Ξ' => "\xce\x9e", #Greek capital letter xi
|
||||
'Ο' => "\xce\x9f", #Greek capital letter omicron
|
||||
'Π' => "\xce\xa0", #Greek capital letter pi
|
||||
'Ρ' => "\xce\xa1", #Greek capital letter rho
|
||||
'Σ' => "\xce\xa3", #Greek capital letter sigma
|
||||
'Τ' => "\xce\xa4", #Greek capital letter tau
|
||||
'Υ' => "\xce\xa5", #Greek capital letter upsilon
|
||||
'Φ' => "\xce\xa6", #Greek capital letter phi
|
||||
'Χ' => "\xce\xa7", #Greek capital letter chi
|
||||
'Ψ' => "\xce\xa8", #Greek capital letter psi
|
||||
'Ω' => "\xce\xa9", #Greek capital letter omega
|
||||
'α' => "\xce\xb1", #Greek small letter alpha
|
||||
'β' => "\xce\xb2", #Greek small letter beta
|
||||
'γ' => "\xce\xb3", #Greek small letter gamma
|
||||
'δ' => "\xce\xb4", #Greek small letter delta
|
||||
'ε' => "\xce\xb5", #Greek small letter epsilon
|
||||
'ζ' => "\xce\xb6", #Greek small letter zeta
|
||||
'η' => "\xce\xb7", #Greek small letter eta
|
||||
'θ' => "\xce\xb8", #Greek small letter theta
|
||||
'ι' => "\xce\xb9", #Greek small letter iota
|
||||
'κ' => "\xce\xba", #Greek small letter kappa
|
||||
'λ' => "\xce\xbb", #Greek small letter lambda
|
||||
'μ' => "\xce\xbc", #Greek small letter mu
|
||||
'ν' => "\xce\xbd", #Greek small letter nu
|
||||
'ξ' => "\xce\xbe", #Greek small letter xi
|
||||
'ο' => "\xce\xbf", #Greek small letter omicron
|
||||
'π' => "\xcf\x80", #Greek small letter pi
|
||||
'ρ' => "\xcf\x81", #Greek small letter rho
|
||||
'ς' => "\xcf\x82", #Greek small letter final sigma
|
||||
'σ' => "\xcf\x83", #Greek small letter sigma
|
||||
'τ' => "\xcf\x84", #Greek small letter tau
|
||||
'υ' => "\xcf\x85", #Greek small letter upsilon
|
||||
'φ' => "\xcf\x86", #Greek small letter phi
|
||||
'χ' => "\xcf\x87", #Greek small letter chi
|
||||
'ψ' => "\xcf\x88", #Greek small letter psi
|
||||
'ω' => "\xcf\x89", #Greek small letter omega
|
||||
'ϑ'=> "\xcf\x91", #Greek small letter theta symbol
|
||||
'ϒ' => "\xcf\x92", #Greek upsilon with hook symbol
|
||||
'ϖ' => "\xcf\x96", #Greek pi symbol
|
||||
|
||||
'•' => "\xe2\x80\xa2", #bullet = black small circle
|
||||
'…' => "\xe2\x80\xa6", #horizontal ellipsis = three dot leader
|
||||
'′' => "\xe2\x80\xb2", #prime = minutes = feet (для обозначения минут и футов)
|
||||
'″' => "\xe2\x80\xb3", #double prime = seconds = inches (для обозначения секунд и дюймов).
|
||||
'‾' => "\xe2\x80\xbe", #overline = spacing overscore
|
||||
'⁄' => "\xe2\x81\x84", #fraction slash
|
||||
'℘' => "\xe2\x84\x98", #script capital P = power set = Weierstrass p
|
||||
'ℑ' => "\xe2\x84\x91", #blackletter capital I = imaginary part
|
||||
'ℜ' => "\xe2\x84\x9c", #blackletter capital R = real part symbol
|
||||
'™' => "\xe2\x84\xa2", #trade mark sign
|
||||
'ℵ' => "\xe2\x84\xb5", #alef symbol = first transfinite cardinal
|
||||
'←' => "\xe2\x86\x90", #leftwards arrow
|
||||
'↑' => "\xe2\x86\x91", #upwards arrow
|
||||
'→' => "\xe2\x86\x92", #rightwards arrow
|
||||
'↓' => "\xe2\x86\x93", #downwards arrow
|
||||
'↔' => "\xe2\x86\x94", #left right arrow
|
||||
'↵' => "\xe2\x86\xb5", #downwards arrow with corner leftwards = carriage return
|
||||
'⇐' => "\xe2\x87\x90", #leftwards double arrow
|
||||
'⇑' => "\xe2\x87\x91", #upwards double arrow
|
||||
'⇒' => "\xe2\x87\x92", #rightwards double arrow
|
||||
'⇓' => "\xe2\x87\x93", #downwards double arrow
|
||||
'⇔' => "\xe2\x87\x94", #left right double arrow
|
||||
'∀' => "\xe2\x88\x80", #for all
|
||||
'∂' => "\xe2\x88\x82", #partial differential
|
||||
'∃' => "\xe2\x88\x83", #there exists
|
||||
'∅' => "\xe2\x88\x85", #empty set = null set = diameter
|
||||
'∇' => "\xe2\x88\x87", #nabla = backward difference
|
||||
'∈' => "\xe2\x88\x88", #element of
|
||||
'∉' => "\xe2\x88\x89", #not an element of
|
||||
'∋' => "\xe2\x88\x8b", #contains as member
|
||||
'∏' => "\xe2\x88\x8f", #n-ary product = product sign
|
||||
'∑' => "\xe2\x88\x91", #n-ary sumation
|
||||
'−' => "\xe2\x88\x92", #minus sign
|
||||
'∗' => "\xe2\x88\x97", #asterisk operator
|
||||
'√' => "\xe2\x88\x9a", #square root = radical sign
|
||||
'∝' => "\xe2\x88\x9d", #proportional to
|
||||
'∞' => "\xe2\x88\x9e", #infinity
|
||||
'∠' => "\xe2\x88\xa0", #angle
|
||||
'∧' => "\xe2\x88\xa7", #logical and = wedge
|
||||
'∨' => "\xe2\x88\xa8", #logical or = vee
|
||||
'∩' => "\xe2\x88\xa9", #intersection = cap
|
||||
'∪' => "\xe2\x88\xaa", #union = cup
|
||||
'∫' => "\xe2\x88\xab", #integral
|
||||
'∴' => "\xe2\x88\xb4", #therefore
|
||||
'∼' => "\xe2\x88\xbc", #tilde operator = varies with = similar to
|
||||
'≅' => "\xe2\x89\x85", #approximately equal to
|
||||
'≈' => "\xe2\x89\x88", #almost equal to = asymptotic to
|
||||
'≠' => "\xe2\x89\xa0", #not equal to
|
||||
'≡' => "\xe2\x89\xa1", #identical to
|
||||
'≤' => "\xe2\x89\xa4", #less-than or equal to
|
||||
'≥' => "\xe2\x89\xa5", #greater-than or equal to
|
||||
'⊂' => "\xe2\x8a\x82", #subset of
|
||||
'⊃' => "\xe2\x8a\x83", #superset of
|
||||
'⊄' => "\xe2\x8a\x84", #not a subset of
|
||||
'⊆' => "\xe2\x8a\x86", #subset of or equal to
|
||||
'⊇' => "\xe2\x8a\x87", #superset of or equal to
|
||||
'⊕' => "\xe2\x8a\x95", #circled plus = direct sum
|
||||
'⊗' => "\xe2\x8a\x97", #circled times = vector product
|
||||
'⊥' => "\xe2\x8a\xa5", #up tack = orthogonal to = perpendicular
|
||||
'⋅' => "\xe2\x8b\x85", #dot operator
|
||||
'⌈' => "\xe2\x8c\x88", #left ceiling = APL upstile
|
||||
'⌉' => "\xe2\x8c\x89", #right ceiling
|
||||
'⌊' => "\xe2\x8c\x8a", #left floor = APL downstile
|
||||
'⌋' => "\xe2\x8c\x8b", #right floor
|
||||
'⟨' => "\xe2\x8c\xa9", #left-pointing angle bracket = bra
|
||||
'⟩' => "\xe2\x8c\xaa", #right-pointing angle bracket = ket
|
||||
'◊' => "\xe2\x97\x8a", #lozenge
|
||||
'♠' => "\xe2\x99\xa0", #black spade suit
|
||||
'♣' => "\xe2\x99\xa3", #black club suit = shamrock
|
||||
'♥' => "\xe2\x99\xa5", #black heart suit = valentine
|
||||
'♦' => "\xe2\x99\xa6", #black diamond suit
|
||||
#Other Special Characters:
|
||||
'Œ' => "\xc5\x92", #Latin capital ligature OE
|
||||
'œ' => "\xc5\x93", #Latin small ligature oe
|
||||
'Š' => "\xc5\xa0", #Latin capital letter S with caron
|
||||
'š' => "\xc5\xa1", #Latin small letter s with caron
|
||||
'Ÿ' => "\xc5\xb8", #Latin capital letter Y with diaeresis
|
||||
'ˆ' => "\xcb\x86", #modifier letter circumflex accent
|
||||
'˜' => "\xcb\x9c", #small tilde
|
||||
' ' => "\xe2\x80\x82", #en space
|
||||
' ' => "\xe2\x80\x83", #em space
|
||||
' ' => "\xe2\x80\x89", #thin space
|
||||
'‌' => "\xe2\x80\x8c", #zero width non-joiner
|
||||
'‍' => "\xe2\x80\x8d", #zero width joiner
|
||||
'‎' => "\xe2\x80\x8e", #left-to-right mark
|
||||
'‏' => "\xe2\x80\x8f", #right-to-left mark
|
||||
'–' => "\xe2\x80\x93", #en dash
|
||||
'—' => "\xe2\x80\x94", #em dash
|
||||
'‘' => "\xe2\x80\x98", #left single quotation mark
|
||||
'’' => "\xe2\x80\x99", #right single quotation mark (and apostrophe!)
|
||||
'‚' => "\xe2\x80\x9a", #single low-9 quotation mark
|
||||
'“' => "\xe2\x80\x9c", #left double quotation mark
|
||||
'”' => "\xe2\x80\x9d", #right double quotation mark
|
||||
'„' => "\xe2\x80\x9e", #double low-9 quotation mark
|
||||
'†' => "\xe2\x80\xa0", #dagger
|
||||
'‡' => "\xe2\x80\xa1", #double dagger
|
||||
'‰' => "\xe2\x80\xb0", #per mille sign
|
||||
'‹' => "\xe2\x80\xb9", #single left-pointing angle quotation mark
|
||||
'›' => "\xe2\x80\xba", #single right-pointing angle quotation mark
|
||||
'€' => "\xe2\x82\xac", #euro sign
|
||||
);
|
||||
$htmlspecialchars = array(
|
||||
'"' => "\x22", #quotation mark = APL quote (") "
|
||||
'&' => "\x26", #ampersand (&) &
|
||||
'<' => "\x3c", #less-than sign (<) <
|
||||
'>' => "\x3e", #greater-than sign (>) >
|
||||
);
|
||||
|
||||
if ($is_htmlspecialchars) $table += $htmlspecialchars;
|
||||
|
||||
#заменяем именованные сущности:
|
||||
#оптимизация скорости: заменяем только те сущности, которые используются в html коде!
|
||||
#эта часть кода работает быстрее, чем $s = strtr($s, $table);
|
||||
preg_match_all('/&[a-zA-Z]++\d*+;/sSX', $s, $m, null, $pos);
|
||||
foreach (array_unique($m[0]) as $entity)
|
||||
{
|
||||
if (array_key_exists($entity, $table)) $s = str_replace($entity, $table[$entity], $s);
|
||||
}#foreach
|
||||
|
||||
if (($pos = strpos($s, '&#')) !== false) #speed optimization
|
||||
{
|
||||
#заменяем числовые dec и hex сущности:
|
||||
$htmlspecialchars_flip = array_flip($htmlspecialchars);
|
||||
$s = preg_replace('/&#((x)[\da-fA-F]{1,6}+|\d{1,7}+);/seS', #1,114,112 sumbols total in UTF-16
|
||||
'(array_key_exists($char = pack("C", $codepoint = ("$2") ? hexdec("$1") : "$1"),
|
||||
$htmlspecialchars_flip
|
||||
)
|
||||
&& ! $is_htmlspecialchars
|
||||
) ? $htmlspecialchars_flip[$char]
|
||||
: utf8_chr($codepoint)', $s, -1, $pos);
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!function_exists('mb_str_replace')) {
|
||||
function mb_str_replace($search, $replace, $subject) {
|
||||
if (is_array($subject)) {
|
||||
foreach ($subject as $key => $val) {
|
||||
$subject[$key] = mb_str_replace((string)$search, $replace, $subject[$key]);
|
||||
}
|
||||
return $subject;
|
||||
}
|
||||
$pattern = '/['.preg_quote(implode('', (array)$search), '/').']/u';
|
||||
if (is_array($search)) {
|
||||
if (is_array($replace)) {
|
||||
$len = min(count($search), count($replace));
|
||||
$table = array_combine(array_slice($search, 0, $len), array_slice($replace, 0, $len));
|
||||
$f = create_function('$match', '$table = '.var_export($table, true).'; return array_key_exists($match[0], $table) ? $table[$match[0]] : $match[0];');
|
||||
$subject = preg_replace_callback($pattern, $f, $subject);
|
||||
return $subject;
|
||||
}
|
||||
}
|
||||
$subject = preg_replace($pattern, (string)$replace, $subject);
|
||||
return $subject;
|
||||
}
|
||||
}?>
|
||||
25
vendor/akdelf/akdmin/lib/validate.php
vendored
Normal file
25
vendor/akdelf/akdmin/lib/validate.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?
|
||||
|
||||
function validate($txt, $vald_type)
|
||||
{
|
||||
|
||||
switch (strtolower(trim($vald_type))) {
|
||||
case 'notnull':
|
||||
return ($txt == '') ? 0 : 1;
|
||||
break;
|
||||
case 'mail':
|
||||
return (!eregi("^[a-z]+[a-z0-9_-]*(([.]{1})|([a-z0-9_-]*))[a-z0-9_-]+[@]{1}[a-z0-9_-]+[.](([a-z]{2,3})|([a-z]{3}[.]{1}[a-z]{2}))$", $txt)) ? 0 : 1;
|
||||
break;
|
||||
case 'phone':
|
||||
return (!eregi("^[0-9]{3}-*[0-9]{3}-*[0-9]{4}$", $txt)) ? 0 : 1;
|
||||
break;
|
||||
case 'mysqldate':
|
||||
return (!eregi("^[0-9]{4}-*[0-9]{2}-*[0-9]{2}$", $txt)) ? 0 : 1;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user