226 lines
6.6 KiB
PHP
226 lines
6.6 KiB
PHP
<?php
|
|
/* ----------------------------------------------------------------------
|
|
|
|
MyOOS [Shopsystem]
|
|
https://www.oos-shop.de
|
|
|
|
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
|
----------------------------------------------------------------------
|
|
Released under the GNU General Public License
|
|
---------------------------------------------------------------------- */
|
|
|
|
/** ensure this file is being included by a parent file */
|
|
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
|
|
|
|
|
/**
|
|
* Decode string encoded with htmlspecialchars()
|
|
*
|
|
* @param $sStr
|
|
* @return string
|
|
*/
|
|
function oos_decode_special_chars($sStr){
|
|
$sStr = str_replace('>', '>', $sStr);
|
|
$sStr = str_replace('<', '<', $sStr);
|
|
$sStr = str_replace(''', "'", $sStr);
|
|
$sStr = str_replace('"', "\"", $sStr);
|
|
$sStr = str_replace('&', '&', $sStr);
|
|
|
|
return $sStr;
|
|
}
|
|
|
|
|
|
/**
|
|
* string encoded
|
|
*
|
|
* @param $sStr
|
|
* @return string
|
|
*/
|
|
function oos_make_filename($sStr) {
|
|
|
|
static $aFrom = array(
|
|
' ',
|
|
|
|
'Ä',
|
|
'ä',
|
|
|
|
'Ö',
|
|
'ö',
|
|
|
|
'Ü',
|
|
'ü',
|
|
|
|
'ß',
|
|
|
|
'é',
|
|
'è',
|
|
'ê',
|
|
|
|
'í',
|
|
'ì',
|
|
'î',
|
|
|
|
'á',
|
|
'à',
|
|
'â',
|
|
'å',
|
|
|
|
'ó',
|
|
'ò',
|
|
'ô',
|
|
'õ',
|
|
|
|
'ú',
|
|
'ù',
|
|
'û',
|
|
|
|
'ç',
|
|
'Ç',
|
|
|
|
'ñ',
|
|
|
|
'ý');
|
|
|
|
static $aTo = array(
|
|
'-',
|
|
|
|
'AE',
|
|
'ae',
|
|
|
|
'OE',
|
|
'oe',
|
|
|
|
'UE',
|
|
'ue',
|
|
|
|
'ss',
|
|
|
|
'e',
|
|
'e',
|
|
'e',
|
|
|
|
'i',
|
|
'i',
|
|
'i',
|
|
|
|
'a',
|
|
'a',
|
|
'a',
|
|
'a',
|
|
|
|
'o',
|
|
'o',
|
|
'o',
|
|
'o',
|
|
|
|
'u',
|
|
'u',
|
|
'u',
|
|
|
|
'c',
|
|
'C',
|
|
|
|
'n',
|
|
|
|
'y');
|
|
// Replace international chars not detected by every locale
|
|
$sStr = str_replace($aFrom, $aTo, $sStr);
|
|
|
|
$special_chars = array("?",
|
|
"[",
|
|
"]",
|
|
"/",
|
|
"\\",
|
|
"=",
|
|
"<",
|
|
">",
|
|
":",
|
|
";",
|
|
",",
|
|
"'",
|
|
"\"",
|
|
"&",
|
|
"$",
|
|
"#",
|
|
"*",
|
|
"(",
|
|
")",
|
|
"|",
|
|
"~",
|
|
"`",
|
|
"!",
|
|
"{",
|
|
"}",
|
|
"%",
|
|
"+",
|
|
chr(0));
|
|
//strip html tags from text
|
|
$sStr = strip_tags($sStr);
|
|
|
|
// Nuke chars not allowed in our URI
|
|
$sStr = preg_replace('#[^0-9a-z\.\_!;,\+\-]#i', '', $sStr);
|
|
|
|
// Recover delimiters as spaces
|
|
$sStr = str_replace("\x01", " ", $sStr);
|
|
|
|
$sStr = preg_replace( "#\x{00a0}#siu", '', $sStr );
|
|
$sStr = str_replace( $special_chars, '', $sStr );
|
|
$sStr = str_replace( array( '%20', '+' ), '-', $sStr );
|
|
$sStr = preg_replace( '/[\r\n\t -]+/', '-', $sStr );
|
|
$sStr = trim( $sStr, '.-_' );
|
|
$sStr = strtolower($sStr);
|
|
|
|
return $sStr;
|
|
}
|
|
|
|
/**
|
|
* string encoded
|
|
*
|
|
* @param $sStr
|
|
* @return string
|
|
*/
|
|
function oos_html_to_xml($sStr) {
|
|
|
|
//Taken from Reverend's Jim feedparser
|
|
//http://revjim.net/code/feedParser/feedParser-0.5.phps
|
|
|
|
static $aEntities = array(
|
|
' ' => " ", '¡' => "¡", '¢' => "¢",
|
|
'£' => "£", '¤' => "¤", '¥' => "¥",
|
|
'¦' => "¦", '§' => "§", '¨' => "¨",
|
|
'©' => "©", 'ª' => "ª", '«' => "«",
|
|
'¬' => "¬", '­' => "­", '®' => "®",
|
|
'¯' => "¯", '°' => "°", '±' => "±",
|
|
'²' => "²", '³' => "³", '´' => "´",
|
|
'µ' => "µ", '¶' => "¶", '·' => "·",
|
|
'¸' => "¸", '¹' => "¹", 'º' => "º",
|
|
'»' => "»", '¼' => "¼", '½' => "½",
|
|
'¾' => "¾", '¿' => "¿", 'À' => "À",
|
|
'Á' => "Á", 'Â' => "Â", 'Ã' => "Ã",
|
|
'Ä' => "Ä", 'Å' => "Å", 'Æ' => "Æ",
|
|
'Ç' => "Ç", 'È' => "È", 'É' => "É",
|
|
'Ê' => "Ê", 'Ë' => "Ë", 'Ì' => "Ì",
|
|
'Í' => "Í", 'Î' => "Î", 'Ï' => "Ï",
|
|
'Ð' => "Ð", 'Ñ' => "Ñ", 'Ò' => "Ò",
|
|
'Ó' => "Ó", 'Ô' => "Ô", 'Õ' => "Õ",
|
|
'Ö' => "Ö", '×' => "×", 'Ø' => "Ø",
|
|
'Ù' => "Ù", 'Ú' => "Ú", 'Û' => "Û",
|
|
'Ü' => "Ü", 'Ý' => "Ý", 'Þ' => "Þ",
|
|
'ß' => "ß", 'à' => "à", 'á' => "á",
|
|
'â' => "â", 'ã' => "ã", 'ä' => "ä",
|
|
'å' => "å", 'æ' => "æ", 'ç' => "ç",
|
|
'è' => "è", 'é' => "é", 'ê' => "ê",
|
|
'ë' => "ë", 'ì' => "ì", 'í' => "í",
|
|
'î' => "î", 'ï' => "ï", 'ð' => "ð",
|
|
'ñ' => "ñ", 'ò' => "ò", 'ó' => "ó",
|
|
'ô' => "ô", 'õ' => "õ", 'ö' => "ö",
|
|
'÷' => "÷", 'ø' => "ø", 'ù' => "ù",
|
|
'ú' => "ú", 'û' => "û", 'ü' => "ü",
|
|
'ý' => "ý", 'þ' => "þ", 'ÿ' => "ÿ"
|
|
);
|
|
$sStr = strtr($sStr, $aEntities);
|
|
|
|
return $sStr;
|
|
}
|
|
|