Overview

Packages

  • None
  • PHPShopAjaxElements
  • PHPShopAjaxElementsDepricated
  • PHPShopArray
  • PHPShopClass
    • Helper
  • PHPShopCore
  • PHPShopCoreDepricated
  • PHPShopCoreFunction
  • PHPShopDepricated
  • PHPShopElements
  • PHPShopElementsDepricated
  • PHPShopGUI
  • PHPShopInc
  • PHPShopObj
  • PHPShopParser
  • PHPShopShopCore
  • PHPShopTest

Classes

  • AjaxNotice
  • AjaxPricemail
  • AjaxReview
  • fase4_rdf
  • inwords
  • PHPShop404
  • PHPShopAdminRule
  • PHPShopAnalitica
  • PHPShopArray
  • PHPShopBannerElement
  • PHPShopBase
  • PHPShopBaseXml
  • PHPShopBonus
  • PHPShopBrandsElement
  • PHPShopCart
  • PHPShopCartElement
  • PHPShopCategory
  • PHPShopCategoryArray
  • PHPShopClients
  • PHPShopCloudElement
  • PHPShopCommerceML
  • PHPShopCompanyArray
  • PHPShopCompare
  • PHPShopCore
  • PHPShopCoreElement
  • PHPShopCoretest
  • PHPShopCssParser
  • PHPShopCurrencyElement
  • PHPShopDate
  • PHPShopDebug
  • PHPShopDelivery
  • PHPShopDeliveryArray
  • PHPShopDoc
  • PHPShopDone
  • PHPShopElements
  • PHPShopError
  • PHPShopExcel
  • PHPShopFail
  • PHPShopFile
  • PHPShopForma
  • PHPShopFrontInterface
  • PHPShopGbook
  • PHPShopGbookElement
  • PHPShopGUI
  • PHPShopIndex
  • PHPShopInterface
  • PHPShopLang
  • PHPShopLinks
  • PHPShopMail
  • PHPShopMailFile
  • PHPShopMap
  • PHPShopMath
  • PHPShopModules
  • PHPShopNav
  • PHPShopNewprice
  • PHPShopNews
  • PHPShopNewsElement
  • PHPShopNewtip
  • PHPShopObj
  • PHPShopOpros
  • PHPShopOprosElement
  • PHPShopOrder
  • PHPShopOrderDelivery
  • PHPShopOrderFunction
  • PHPShopOrderStatusArray
  • PHPShopOrm
  • PHPShopPage
  • PHPShopPageCatalogElement
  • PHPShopPageCategory
  • PHPShopPageCategoryArray
  • PHPShopPages
  • PHPShopParentNameArray
  • PHPShopParser
  • PHPShopPayment
  • PHPShopPaymentArray
  • PHPShopPaymentResult
  • PHPShopPhoto
  • PHPShopPhotoCategory
  • PHPShopPhotoCategoryArray
  • PHPShopPhotoElement
  • PHPShopPrice
  • PHPShopPricemail
  • PHPShopPrint
  • PHPShopProduct
  • PHPShopProductArray
  • PHPShopProductElements
  • PHPShopProductFunction
  • PHPShopProductIconElements
  • PHPShopProductIndexElements
  • PHPShopPromotions
  • PHPShopPush
  • PHPShopReadCsvNative
  • PHPShopRecaptchaElement
  • PHPShopRestore
  • PHPShopRssParser
  • PHPShopSearch
  • PHPShopSecurity
  • PHPShopSelection
  • PHPShopSelectioncat
  • PHPShopShop
  • PHPShopShopCatalogElement
  • PHPShopShopCore
  • PHPShopSkinElement
  • PHPShopSliderElement
  • PHPShopSort
  • PHPShopSortAjax
  • PHPShopSortArray
  • PHPShopSortCategoryArray
  • PHPShopSortElement
  • PHPShopSortSearch
  • PHPShopSpec
  • PHPShopString
  • PHPShopSuccess
  • PHPShopSystem
  • PHPShopTemplates
  • PHPShopText
  • PHPShopTextElement
  • PHPShopUnsubscribe
  • PHPShopUpdate
  • PHPShopUser
  • PHPShopUserElement
  • PHPShopUserFunction
  • PHPShopUsers
  • PHPShopUserStatus
  • PHPShopUserStatusArray
  • PHPShopValuta
  • PHPShopValutaArray
  • rateForComment
  • XMLparser

Functions

  • __
  • __hide
  • _e
  • action_order_info
  • allowedFunctions
  • array2iconv
  • avg_rate
  • calendar
  • catalog_meta
  • CheckCanGzip
  • comment_rate
  • debug
  • delivery
  • DispComment
  • evalstr
  • GetDeliveryPrice
  • getExcelInfoUid
  • GetFile
  • getFotoIconPodrobno
  • getfullname
  • getgoodname
  • getLicense
  • GetVoteValue
  • getYandexSearchSql
  • GzDocOut
  • image_gallery
  • import
  • json_encode
  • json_fix_cyr
  • json_fix_utf
  • mailcartforma
  • makeCalendar
  • message_activation
  • message_register_success
  • MessageList
  • moname
  • Nav_comment
  • Nav_messages
  • notice_add
  • notice_list
  • notice_mail
  • NumFrom
  • option_check
  • option_select
  • option_select_add
  • order_list
  • ordercartforma
  • Page_comment
  • Page_messages
  • parse_ini_file_true
  • parseDatabase
  • Parser
  • ParseTemplate
  • ParseTemplateReturn
  • PHPShopAutoLoadClass
  • phpshopparserevalstr
  • preExtractCallBack
  • product_meta
  • query_filter
  • query_multibase
  • rating
  • ratingshort
  • ratingtop
  • readDatabase
  • returnSmile
  • search_base
  • set_meta
  • setAutokeyword
  • ShowStars
  • ShowStars2
  • sort_table
  • sorttemplateexample
  • stripslashes_deep
  • SysValueReturn
  • timer
  • tmpGetFile
  • user_message
  • usercartforma
  • userdeleveryforma
  • userfiles
  • userorderdoclink
  • userorderfiles
  • userorderpaymentlink
  • utf8_win1251
  • writeLangFile
  • xml2array
  • Overview
  • Package
  • Class
  • Tree
  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 
<?php

include_once dirname(__DIR__) . '/lib/mobiledetect/Mobile_Detect.php';

/**

 * @author PHPShop Software
 * @version 2.1
 * @package PHPShopClass
 * @subpackage Helper
 */
class PHPShopString {

    /**



     * @return string
     */
    static function check_idna($str, $path = false) {
        global $_classPath;
        if (strstr($str, 'xn--')) {

            if (empty($path))
                include_once($GLOBALS['SysValue']['file']['idna']);
            else
                include_once($_classPath . '.' . $GLOBALS['SysValue']['file']['idna']);

            $idna_convert = new idna_convert();
            $str = PHPShopString::utf8_win1251($idna_convert->decode($str));
        }
        return $str;
    }

    /**

     * @param string $data
     * @return Bool
     */
    static function is_serialized($data) {
        return (is_string($data) && preg_match("#^((N;)|((a|O|s):[0-9]+:.*[;}])|((b|i|d):[0-9.E-]+;))$#um", $data));
    }

    /**

     * @param string $var
     * @return string
     */
    static function json_safe_encode($var) {
        return json_encode(json_fix_cyr($var));
    }

    /**



     * @return string
     */
    static function win_utf8($in_text, $utf_check=false) {

        if ($GLOBALS['PHPShopBase']->codBase == 'utf-8' and !$utf_check)
            return $in_text;

        if (function_exists('iconv')) {
            $output = iconv("windows-1251", "utf-8", $in_text);
        } else {

            $output = null;
            $other[1025] = "";
            $other[1105] = "";
            $other[1028] = "";
            $other[1108] = "";
            $other[1030] = "I";
            $other[1110] = "i";
            $other[1031] = "";
            $other[1111] = "";

            for ($i = 0; $i < strlen($in_text); $i++) {
                if (ord($in_text[$i]) > 191) {
                    $output .= "&#" . (ord($in_text[$i]) + 848) . ";";
                } else {
                    if (array_search($in_text[$i], $other) === false) {
                        $output .= $in_text[$i];
                    } else {
                        $output .= "&#" . array_search($in_text[$i], $other) . ";";
                    }
                }
            }
        }

        return $output;
    }

    /**


     * @return string
     */
    static function utf8_win1251($s) {

        if ($GLOBALS['PHPShopBase']->codBase == 'utf-8')
            return $s;

        $s = strtr($s, array("\xD0\xB0" => "", "\xD0\x90" => "", "\xD0\xB1" => "", "\xD0\x91" => "", "\xD0\xB2" => "", "\xD0\x92" => "", "\xD0\xB3" => "", "\xD0\x93" => "", "\xD0\xB4" => "", "\xD0\x94" => "", "\xD0\xB5" => "", "\xD0\x95" => "", "\xD1\x91" => "", "\xD0\x81" => "", "\xD0\xB6" => "", "\xD0\x96" => "", "\xD0\xB7" => "", "\xD0\x97" => "", "\xD0\xB8" => "", "\xD0\x98" => "", "\xD0\xB9" => "", "\xD0\x99" => "", "\xD0\xBA" => "", "\xD0\x9A" => "", "\xD0\xBB" => "", "\xD0\x9B" => "", "\xD0\xBC" => "", "\xD0\x9C" => "", "\xD0\xBD" => "", "\xD0\x9D" => "", "\xD0\xBE" => "", "\xD0\x9E" => "", "\xD0\xBF" => "", "\xD0\x9F" => "", "\xD1\x80" => "", "\xD0\xA0" => "", "\xD1\x81" => "", "\xD0\xA1" => "", "\xD1\x82" => "", "\xD0\xA2" => "", "\xD1\x83" => "", "\xD0\xA3" => "", "\xD1\x84" => "", "\xD0\xA4" => "", "\xD1\x85" => "", "\xD0\xA5" => "", "\xD1\x86" => "", "\xD0\xA6" => "", "\xD1\x87" => "", "\xD0\xA7" => "", "\xD1\x88" => "", "\xD0\xA8" => "", "\xD1\x89" => "", "\xD0\xA9" => "", "\xD1\x8A" => "", "\xD0\xAA" => "", "\xD1\x8B" => "", "\xD0\xAB" => "", "\xD1\x8C" => "", "\xD0\xAC" => "", "\xD1\x8D" => "", "\xD0\xAD" => "", "\xD1\x8E" => "", "\xD0\xAE" => "", "\xD1\x8F" => "", "\xD0\xAF" => ""));
        return $s;
    }

    /**

     * @param string $str
     * @return string
     */
    static function toLatin($str) {
        $str = strtolower($str);

        //
        /*
        $num = intval($str);
        if (!empty($num))
            $str = '_' . $str;
         */

        $str = str_replace("&nbsp;", "", $str);
        $str = str_replace("/", "-", $str); //
        $str = str_replace("\\", "", $str);
        $str = str_replace("(", "", $str);
        $str = str_replace(")", "", $str);
        $str = str_replace(":", "", $str);
        //
        $str = str_replace(" ", "_", $str);
        $str = str_replace("!", "", $str);
        $str = str_replace("|", "_", $str);
        $str = str_replace(".", "_", $str);
        $str = str_replace("", "N", $str);
        $str = str_replace("?", "", $str);
        $str = str_replace("&nbsp", "_", $str);
        $str = str_replace("&amp;", '_', $str);
        $str = str_replace("", "", $str);
        $str = str_replace("", "", $str);
        $str = str_replace("", "", $str);
        $str = str_replace("", "", $str);
        $str = str_replace("", "", $str);
        $str = str_replace("", "", $str);
        $str = str_replace(",", "", $str);
        $str = str_replace("", "", $str);
        $str = str_replace("", "", $str);
        $str = str_replace("", "", $str);
        $str = str_replace(array('&#43;', '&#43'), '+', $str);

        $new_str = '';
        $_Array = array(" " => "_", "" => "a", "" => "b", "" => "v", "" => "g", "" => "d", "" => "e", "" => "e", "" => "e", "" => "yi", "" => "e", "" => "yi", "" => "zh", "" => "z", "" => "i", "" => "y", "" => "k", "" => "l", "" => "m", "" => "n", "" => "o", "" => "p", "" => "r", "" => "s", "" => "t", "" => "u", "" => "f", "" => "h", "" => "c", "" => "ch", "" => "sh", "" => "sch", "" => "i", "" => "y", "" => "i", "" => "e", "" => "u", "" => "ya", "" => "a", "" => "b", "" => "v", "" => "g", "" => "d", "" => "e", "" => "e", "" => "zh", "" => "z", "" => "i", "" => "y", "" => "k", "" => "l", "" => "m", "" => "n", "" => "o", "" => "p", "" => "r", "" => "s", "" => "t", "" => "Y", "" => "u", "" => "f", "" => "h", "" => "c", "" => "ch", "" => "sh", "" => "sch", "" => "e", "" => "u", "" => "ya", "." => "_", "$" => "i", "%" => "i", "&" => "_and_");

        $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);

        foreach ($chars as $val)
            if (empty($_Array[$val]))
                $new_str .= $val;
            else
                $new_str .= $_Array[$val];

        return preg_replace('([^a-z0-9/_\.-])', '', $new_str);
    }

    //
    static function mySubstr($str, $a, $add = "...") {
        $str = htmlspecialchars(strip_tags(trim($str)), ENT_QUOTES, 'windows-1251');
        $len = strlen($str);

        if ($len < $a)
            return $str;

        for ($i = 1; $i <= $a; $i++) {
            if ($str[$i] == ".")
                $T = $i;
        }

        if (substr($str, -1) == '&')
            $str = substr($str, 0, $len - 1);

        if ($T < 1)
            return substr($str, 0, $a) . $add;
        else
            return substr($str, 0, $T + 1);
    }

    /**



     * @return float
     */
    static function toFloat($price, $direct = false) {
        if ($direct) {
            if (strpos($price, ','))
                $price = str_replace(',', '.', $price);
        }
        else {
            if (strpos($price, '.'))
                $price = str_replace('.', ',', $price);
        }
        return trim($price);
    }

    /*


     * @return string
     */

    static function getColor($str) {
        $colorArray = array(
            '' => '#ffffff',
            '' => '#000000',
            '' => '#FF0000',
            '' => '#008000',
            '' => '#0000FF',
            '' => '#00FFFF',
            '' => '#FFFF00',
            '' => '#FFC0CB',
            '' => '#FFA500',
            '' => '#EE82EE',
            '' => '#A0522D',
            '' => '#808080',
            '' => '#C0C0C0'
        );
        $code = $colorArray[trim(mb_strtolower($str, 'windows-1251'))];
        if (empty($code) and ! empty($str))
            $code = '';
        return $code;
    }

    /**

     * @param string $agent HTTP_USER_AGENT
     * @return string
     */
    static function getBrowser($agent = false) {

        if (empty($agent))
            $agent = $_SERVER["HTTP_USER_AGENT"];

        preg_match("/(MSIE|Opera|Firefox|Chrome|Version|Opera Mini|Netscape|Konqueror|SeaMonkey|Camino|Minefield|Iceweasel|K-Meleon|Maxthon)(?:\/| )([0-9.]+)/", $agent, $browser_info); //
        list(, $browser, $version) = $browser_info;
        if (preg_match("/Opera ([0-9.]+)/i", $agent, $opera))
            return 'Opera ' . $opera[1];
        if ($browser == 'MSIE') {
            preg_match("/(Maxthon|Avant Browser|MyIE2)/i", $agent, $ie);
            if ($ie)
                return $ie[1] . ' based on IE ' . $version;
            return 'IE ' . $version;
        }
        if ($browser == 'Firefox') {
            preg_match("/(Flock|Navigator|Epiphany)\/([0-9.]+)/", $agent, $ff);
            if ($ff)
                return $ff[1] . ' ' . $ff[2];
        }
        if ($browser == 'Opera' && $version == '9.80')
            return 'Opera ' . substr($agent, -5);
        if ($browser == 'Version')
            return 'Safari ' . $version;
        if (!$browser && strpos($agent, 'Gecko'))
            return 'Browser based on Gecko';
        return $browser . ' ' . $version;
    }
    
    
    /**

     * @return boolean
     */
    static function is_mobile() {
        $detect = new Mobile_Detect();

        return $detect->isMobile();
    }

}

/**


 * @return array
 */
function json_fix_cyr($var) {
    if (is_array($var)) {
        $new = array();
        foreach ($var as $k => $v) {
            $new[json_fix_cyr($k)] = json_fix_cyr($v);
        }
        $var = $new;
    } elseif (is_string($var)) {
        $var = PHPShopString::win_utf8($var);
    }
    return $var;
}

/**


 * @return array
 */
function json_fix_utf($var) {
    if (is_array($var)) {
        $new = array();
        foreach ($var as $k => $v) {
            $new[json_fix_utf($k)] = json_fix_utf($v);
        }
        $var = $new;
    } elseif (is_string($var)) {
        $var = PHPShopString::utf8_win1251($var);
    }
    return $var;
}

/**
 * Native json_encode function
 */
if (!function_exists('json_encode')) {

    function json_encode($data) {
        if (is_array($data) || is_object($data)) {
            $islist = is_array($data) && ( empty($data) || array_keys($data) === range(0, count($data) - 1) );

            if ($islist) {
                $json = '[' . implode(',', array_map('json_encode', $data)) . ']';
            } else {
                $items = Array();
                foreach ($data as $key => $value) {
                    $items[] = json_encode("$key") . ':' . json_encode($value);
                }
                $json = '{' . implode(',', $items) . '}';
            }
        } elseif (is_string($data)) {
            # Escape non-printable or Non-ASCII characters.
            # I also put the \\ character first, as suggested in comments on the 'addclashes' page.
            $string = '"' . addcslashes($data, "\\\"\n\r\t/" . chr(8) . chr(12)) . '"';
            $json = '';
            $len = strlen($string);
            # Convert UTF-8 to Hexadecimal Codepoints.
            for ($i = 0; $i < $len; $i++) {

                $char = $string[$i];
                $c1 = ord($char);

                # Single byte;
                if ($c1 < 128) {
                    $json .= ($c1 > 31) ? $char : sprintf("\\u%04x", $c1);
                    continue;
                }

                # Double byte
                $c2 = ord($string[++$i]);
                if (($c1 & 32) === 0) {
                    $json .= sprintf("\\u%04x", ($c1 - 192) * 64 + $c2 - 128);
                    continue;
                }

                # Triple
                $c3 = ord($string[++$i]);
                if (($c1 & 16) === 0) {
                    $json .= sprintf("\\u%04x", (($c1 - 224) << 12) + (($c2 - 128) << 6) + ($c3 - 128));
                    continue;
                }

                # Quadruple
                $c4 = ord($string[++$i]);
                if (($c1 & 8 ) === 0) {
                    $u = (($c1 & 15) << 2) + (($c2 >> 4) & 3) - 1;

                    $w1 = (54 << 10) + ($u << 6) + (($c2 & 15) << 2) + (($c3 >> 4) & 3);
                    $w2 = (55 << 10) + (($c3 & 15) << 6) + ($c4 - 128);
                    $json .= sprintf("\\u%04x\\u%04x", $w1, $w2);
                }
            }
        } else {
            # int, floats, bools, null
            $json = strtolower(var_export($data, true));
        }
        return $json;
    }

}
?>
PHPShop 6.X API documentation generated by ApiGen