Example #1
0
 *
 * @package Smarty
 * @subpackage PluginsShared
 */
if (!function_exists('smarty_mb_str_replace')) {
    /**
     * Multibyte string replace
     *
     * @param string $search  the string to be searched
     * @param string $replace the replacement string
     * @param string $subject the source string
     * @param int    &$count  number of matches found
     * @return string replaced string
     * @author Rodney Rehm
     */
    function smarty_mb_str_replace($search, $replace, $subject, &$count = 0)
    {
        if (!is_array($search) && is_array($replace)) {
            return false;
        }
        if (is_array($subject)) {
            // call mb_replace for each single string in $subject
            foreach ($subject as &$string) {
                $string =& smarty_mb_str_replace($search, $replace, $string, $c);
                $count += $c;
            }
        } elseif (is_array($search)) {
            if (!is_array($replace)) {
                foreach ($search as &$string) {
                    $subject = smarty_mb_str_replace($string, $replace, $subject, $c);
                    $count += $c;
                }
            } else {
                $n = max(count($search), count($replace));
 /**
  * Defined by Zend_Filter_Interface
  *
  * Returns $value translitered to ASCII
  *
  * @param  string $value
  * @return string
  */
 public function filter($value)
 {
     //translitere specific chars
     $value = $this->_transliterateCzech($value);
     $value = $this->_transliterateSlovak($value);
     $value = $this->_transliterateRussian($value);
     $value = $this->_transliterateGerman($value);
     $value = $this->_transliterateFrench($value);
     $value = $this->_transliterateHungarian($value);
     $value = $this->_transliteratePolish($value);
     $value = $this->_transliterateDanish($value);
     $value = $this->_transliterateCroatian($value);
     //split string to single characters
     $characters = mb_split("~(.)~", $value);
     $return = '';
     foreach ($characters as $character) {
         /*  maybe should contain also //IGNORE  */
         $converted = iconv("utf-8", "ASCII//TRANSLIT", $character);
         //if character was converted, strip out wrong marks
         if ($character !== $converted) {
             $return .= preg_replace('~["\'^]+~', '', $converted);
         } else {
             $return .= $converted;
         }
     }
     return $return;
 }
 /**
  * Inject span tags for each line to indicate direction.
  *
  * @param  string  $text  Single line's worth of text.
  * @return string
  */
 protected function unmarkedText($text)
 {
     $newText = "";
     if ($this->breaksEnabled) {
         $parts = mb_split('[ ]*\\n', $text);
     } else {
         $parts = mb_split('(?:[ ][ ]+|[ ]*\\\\)\\n', $text);
     }
     foreach ($parts as $index => &$part) {
         if ($index > 0) {
             $newText .= "<br />\n";
         }
         // Remove trailing spaces.
         $part = mb_ereg_replace('/[ ]*\\n/', "\n", $part);
         // Determine directon
         $ltr = $this->getLtrStrLen($part);
         $rtl = $this->getRtlStrLen($part);
         $dir = null;
         if ($this->isLtr() && $rtl > 0 && $rtl > $ltr) {
             $dir = "rtl";
         } else {
             if ($this->isRtl() && $ltr > 0 && $ltr > $rtl) {
                 $dir = "ltr";
             }
         }
         if (!is_null($dir)) {
             $newText .= "<div dir=\"{$dir}\">{$part}</div>";
         } else {
             $newText .= $part;
         }
     }
     return $newText;
 }
Example #4
0
function CheckThrottle()
{
    global $opt, $tpl;
    $ip_string = $_SERVER['REMOTE_ADDR'];
    $ip_blocks = mb_split('\\.', $ip_string);
    $ip_numeric = $ip_blocks[3] + $ip_blocks[2] * 256 + $ip_blocks[1] * 65536 + $ip_blocks[0] * 16777216;
    sql('CREATE TABLE IF NOT EXISTS &tmpdb.`sys_accesslog`
        (`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `ip` INT UNSIGNED NOT NULL,
         `access_time` TIMESTAMP NOT NULL, INDEX (`access_time`), INDEX (`ip`)) ENGINE = MEMORY');
    $rsStaus = sql("SHOW STATUS LIKE 'Threads_connected'");
    $rStatus = sql_fetch_array($rsStaus);
    sql_free_result($rsStaus);
    if ($rStatus) {
        if ($rStatus[1] > $opt['db']['throttle_connection_count']) {
            $access_count = sql_value("SELECT COUNT(*) FROM &tmpdb.`sys_accesslog` WHERE ip ='&1'", 0, $ip_numeric);
            if ($access_count > $opt['db']['throttle_access_count']) {
                $tpl->error(ERROR_THROOTLE);
            }
        }
    }
    // remove old entries every 100st call
    if (mt_rand(0, 100) == 50) {
        sql("DELETE FROM &tmpdb.`sys_accesslog` WHERE `access_time`<CURRENT_TIMESTAMP()-'&2'", $ip_numeric, $opt['db']['throttle_access_time']);
    }
    sql("INSERT INTO &tmpdb.`sys_accesslog` (`ip`, `access_time`) VALUES ('&1', CURRENT_TIMESTAMP())", $ip_numeric);
}
Example #5
0
 protected static function get_alphabet()
 {
     if (!empty(self::$alphabet)) {
         return;
     }
     /* translators: List the aphabet of your language in the order that your language prefers. list as groups of identical meanings but different characters together, e.g. in English we group A with a because they are both the same letter but different character-code. Each character group should be followed by a comma separating it from the next group. Any amount of characters per group are acceptible, and there is no requirement for all the groups to contain the same amount of characters as all the others. Be careful with the character you place first in each group as that will be used as the identifier for the group which gets displayed on the page, e.g. in English a group definition of "Aa" will indicate that we display all the posts in the group, i.e. whose titles begin with either "A" or "a", listed under a heading of "A" (the first character in the definition). */
     $alphabet = apply_filters('a-z-listing-alphabet', __('AÁÀÄÂaáàäâ,Bb,Cc,Dd,EÉÈËÊeéèëê,Ff,Gg,Hh,IÍÌÏÎiíìïî,Jj,Kk,Ll,Mm,Nn,OÓÒÖÔoóòöô,Pp,Qq,Rr,Ssß,Tt,UÚÙÜÛuúùüû,Vv,Ww,Xx,Yy,Zz'));
     /* translators: This should be a single character to denote "all entries that didn't fit under one of the alphabet character groups defined". This is used in English to categorise posts whose title begins with a numeric (0 through to 9), or some other character that is not a standard English alphabet letter. */
     $others = apply_filters('a-z-listing-non-alpha-char', __('#', 'a-z-listing'));
     $alphabet_groups = mb_split(',', $alphabet);
     $letters = array_reduce($alphabet_groups, function ($return, $group) {
         $group = A_Z_Listing::mb_string_to_array($group);
         $group_index_character = $group[0];
         $group = array_reduce($group, function ($group, $character) use($group_index_character) {
             $group[$character] = $group_index_character;
             return $group;
         });
         if (!is_array($return)) {
             return $group;
         }
         return array_merge($return, $group);
     });
     self::$alphabet = $letters;
     self::$unknown_letters = $others;
 }
Example #6
0
 public static function detect($string)
 {
     $string = mb_strtolower($string, "UTF-8");
     // make it lowercase
     $matchWords = mb_split(" ", $string);
     array_walk($matchWords, 'trim');
     foreach ($matchWords as $key => $item) {
         if ($item == '' || strlen($item) <= 6) {
             unset($matchWords[$key]);
         }
     }
     $wordCountArr = array();
     if (is_array($matchWords)) {
         foreach ($matchWords as $key => $val) {
             $val = mb_strtolower($val, "UTF-8");
             if (isset($wordCountArr[$val])) {
                 $wordCountArr[$val]++;
             } else {
                 $wordCountArr[$val] = 1;
             }
         }
     }
     arsort($wordCountArr);
     $wordCountArr = array_slice($wordCountArr, 0, 10);
     $returnArr = array();
     foreach ($wordCountArr as $word => $count) {
         if ($count > 3) {
             $returnArr[] = $word;
         }
     }
     return $returnArr;
 }
Example #7
0
 public function split($string = '', $pattern = '', $limit = -1)
 {
     if (!is_string($string) || !is_string($pattern)) {
         return Error::set('Error', 'stringParameter', '1.(string) & 2.(pattern)');
     }
     return mb_split($pattern, $string, $limit);
 }
 /**
  * accept the request or CLI parameters
  * @param string $pty request data priority:
  *                                    J - json
  *                                    P - post
  *                                    G - get
  */
 public function __construct($pty = 'JPG')
 {
     global $argc, $argv;
     if (empty($argc)) {
         // request parameters
         $jsn = @json_decode(file_get_contents('php://input'), true);
         // check for json body
         if (is_array($jsn)) {
             $this->jsn = $jsn;
             // json request
         } else {
             $this->jsn = isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'json') !== false ? array() : false;
             // empty json body?
             $jsn = array();
             // no json data
         }
         $this->Merge(array('J' => $jsn, 'P' => $_POST, 'G' => $_GET), strtoupper($pty));
         // save
     } else {
         // CLI arguments
         for ($i = 1; $i < $argc; $i++) {
             // loop the arguments
             $arg = mb_split('=', $argv[$i]);
             // split to key/value
             $this->rqt[$arg[0]] = $arg[1];
             // save
         }
     }
 }
 /**
  * Parse title of the question by
  * tokenizing it
  * Overrides parent's parse and users mb_split
  * instead of preg_split to be UTF-8 Safe
  * because title can be a UTF-8 string
  *
  * @return array tokens;
  */
 public function parse()
 {
     if (empty($this->origString)) {
         d('string was empty, returning empty array');
         return array();
     }
     \mb_regex_encoding('UTF-8');
     $aTokens = \mb_split('([\\s,;\\"\\?]+)', $this->origString);
     $aTokens = \array_unique($aTokens);
     $aStopwords = getStopwords();
     \array_walk($aTokens, function (&$val) use($aStopwords) {
         $val = \trim($val);
         $val = strlen($val) > 1 && !in_array($val, $aStopwords) ? $val : false;
     });
     /**
      * Remove empty values
      *
      */
     $aTokens = \array_filter($aTokens);
     /**
      * Call array_values to reindex from 0
      * otherwise if filter removed some
      * elements then Mongo will not
      * treat this as normal array
      */
     return \array_values($aTokens);
 }
Example #10
0
/**
 * @param announcement  Server announcement string. UTF-8 assumed.
 * @param addr          Remote server address.
 */
function update_server($announcement, $addr)
{
    mb_regex_encoding('UTF-8');
    mb_internal_encoding('UTF-8');
    // First we must determine if the announcement is valid.
    $lines = mb_split("\r\n|\n|\r", $announcement);
    $info = new ServerInfo();
    while (list($line_number, $line) = each($lines)) {
        // Separate the label from the value.
        $colon = strpos($line, ":");
        // It must exist near the beginning.
        if ($colon === false || $colon >= 16) {
            continue;
        }
        $label = substr($line, 0, $colon);
        $value = substr($line, $colon + 1, strlen($line) - $colon - 1);
        if (strlen($value) >= 128) {
            continue;
        }
        // Ensure the label identifies a known property.
        if (isset($info[$label])) {
            // This will be included in the datafile.
            $info[$label] = $value;
        }
    }
    // Also include the remote address.
    $info['at'] = $addr;
    $info['time'] = time();
    // Let's write this info into the datafile.
    write_server($info);
}
Example #11
0
 function do_url()
 {
     $page = $this->getcurrentPage();
     if ($page->isexist()) {
         $html = convert_Page($page);
         if (keys_exists(Vars::$get, 'word', 'type')) {
             $list = mb_split('[\\s ]', Vars::$get['word']);
             $smarty = $this->getSmarty();
             $smarty->assign('word', $list);
             $smarty->assign('type', Vars::$get['type']);
             $smarty->assign('body', Search::getinstance()->mark($html, $list, Vars::$get['type']));
             $html = $smarty->fetch('highlight.tpl.htm');
         }
         $ret['body'] = $html;
         $ret['title'] = $page->getpagename();
         $ret['pagename'] = $page->getpagename();
         $ret['lastmodified'] = $page->gettimestamp();
     } else {
         $smarty = $this->getSmarty();
         $smarty->assign('pagename', $page->getpagename());
         $ret['body'] = $smarty->fetch('notexist.tpl.htm');
         $ret['title'] = $page->getpagename() . ' は存在しません';
         $ret['pagename'] = $page->getpagename();
     }
     return $ret;
 }
Example #12
0
 function load($lang)
 {
     $col = $this->languages[$lang];
     if (!$col) {
         $col = 1;
     }
     $this->messages = array();
     $path = CONF_DIR . 'messages/common.csv';
     $fin = fopen($path, 'r');
     while ($line = fgets($fin)) {
         $line = rtrim($line);
         if ($line[0] == "#") {
             continue;
         }
         $cells = mb_split(';', $line);
         if (count($cells) <= 1) {
             continue;
         }
         $key = trim($cells[0]);
         $value = $cells[$col];
         if (!$value) {
             continue;
         }
         $this->messages[$key] = $value;
     }
     fclose($fin);
 }
 public function wordwrapFilter($value, $length = 60, $separator = "\n", $preserve = false)
 {
     $lines = array();
     $value = str_replace("<p>", "", $value);
     $value = str_replace("</p>", "\n\n", $value);
     $value = preg_replace("/<br\\W*?\\/>/", "\n", $value);
     if (substr($value, -2) == "\n\n") {
         $value = substr($value, 0, -2);
     }
     $previous = mb_regex_encoding();
     mb_regex_encoding(craft()->templates->getTwig()->getCharset());
     $pieces = mb_split($separator, $value);
     mb_regex_encoding($previous);
     foreach ($pieces as $piece) {
         while (!$preserve && mb_strlen($piece, craft()->templates->getTwig()->getCharset()) > $length) {
             $count = count($lines);
             $lines[] = mb_substr($piece, 0, $length, craft()->templates->getTwig()->getCharset());
             $lastSpacePosition = strrpos($lines[$count], ' ', 0);
             $finalCharacters = trim(substr($lines[$count], $lastSpacePosition, 60));
             $lines[$count] = substr($lines[$count], 0, $lastSpacePosition);
             $piece = $finalCharacters . $piece;
             $piece = mb_substr($piece, $length, 2048, craft()->templates->getTwig()->getCharset());
         }
         $lines[] = $piece;
     }
     return implode($separator, $lines);
 }
Example #14
0
 public static function getLastGames($count = 5)
 {
     $var = Yii::app()->redis->getClient()->get("lastGames");
     if (!$var) {
         return [];
     }
     $varArr = mb_split(":", $var);
     $out = [];
     foreach ($varArr as $item) {
         $t = mb_split("\\|", $item);
         $tmp = ["time" => $t[0], "gameId" => $t[1], "gameLink" => Yii::app()->createUrl("/stats/" . Yii::app()->params['gameTypes'][$t[2]]["url"] . "/view", ["id" => $t[1]]), "type" => $t[2], "typeLink" => Yii::app()->createUrl("/stats/" . Yii::app()->params['gameTypes'][$t[2]]["url"] . "/list"), "typeName" => Yii::app()->params['gameTypes'][$t[2]]["name"]];
         if (Yii::app()->params['gameTypes'][$t[2]]["isTeams"]) {
             $tmp['winner'] = Yii::app()->params['gameTypes'][$t[2]]["teams"][$t[3]] . " команда выиграла ";
         } else {
             $tmp['winner'] = Users::model()->getUsernameWithAvatarAndLink($t[3], 15) . " выиграл";
         }
         $out[] = $tmp;
     }
     $out = array_reverse($out);
     $out1 = [];
     $i = 1;
     foreach ($out as $item) {
         if ($i <= $count) {
             $out1[] = $item;
         } else {
             break;
         }
         $i++;
     }
     return $out1;
 }
Example #15
0
 protected function wordsearch()
 {
     if (!isset(Vars::$get['andor']) || !isset(Vars::$get['type'])) {
         throw new CommandException('パラメータが足りません。', $this);
     }
     $word = array();
     foreach (mb_split('[\\s ]+', Vars::$get['keyword']) as $w) {
         if ($w != '') {
             $word[] = $w;
         }
     }
     if ($word == array()) {
         return $this->showform();
     }
     $search = Search::getinstance();
     $andsearch = Vars::$get['andor'] == 'and';
     switch (Vars::$get['type']) {
         case 'fuzzy':
             $list = $search->fuzzysearch($word, $andsearch);
             break;
         case 'ereg':
             $list = $search->eregsearch($word, $andsearch);
             break;
         default:
             $list = $search->normalsearch($word, $andsearch);
             break;
     }
     $smarty = $this->getSmarty();
     $smarty->assign('word', join(' ', $word));
     $smarty->assign('type', Vars::$get['type']);
     $smarty->assign('list', $list);
     $ret['title'] = '検索結果';
     $ret['body'] = $smarty->fetch('wordsearchresult.tpl.htm');
     return $ret;
 }
Example #16
0
 /**
  * @param string $string The string to parse
  * @param ClassObject $extend optional, set if this ClassObject should extend another one
  */
 public function __construct($string, ClassObject $extend = null)
 {
     if ($extend !== null) {
         $this->attributes = $extend->getAttributes();
         $this->methods = $extend->getMethods();
     }
     $pattern = '/' . self::PATTERN . '/i';
     preg_match($pattern, $string, $matches);
     $this->name = $matches[self::PATTERN_NAME_GROUP];
     if (count($matches) > 2) {
         $blocks = preg_split('/\\|/', $matches[2]);
         // Attributes block
         if (count($blocks) > 1) {
             foreach (mb_split(';', $blocks[1]) as $attribute) {
                 if (!empty($attribute)) {
                     $this->attributes[] = new Variable($attribute);
                 }
             }
         }
         // Methods block
         if (count($blocks) > 2) {
             foreach (mb_split(';', $blocks[2]) as $method) {
                 try {
                     $this->methods[] = new Method($method);
                 } catch (\InvalidArgumentException $e) {
                 }
             }
         }
     }
 }
Example #17
0
 /** \brief Generate abstract from body text.
     \zfb_read FeedItem..generateAbstract */
 public function generateAbstract($check = false)
 {
     if ($check && $this->abstract != '') {
         return $this;
     }
     $length = $this->_autoAbstractLength;
     $text = strip_tags($this->text);
     if (mb_strlen($text) < $length) {
         $this->abstract = $text;
         return $this;
     }
     $minLenght = $length / 4;
     $abstract = mb_substr($text, 0, $length);
     $split = mb_split('[.!?]', $abstract);
     $splitCnt = count($split);
     $tail = $split[$splitCnt - 1];
     $tailLen = mb_strlen($tail);
     if ($splitCnt == 1 || $tailLen > $length - $minLenght) {
         $abstract = mb_substr($abstract, 0, mb_strrpos($abstract, ' '));
         $abstract .= $this->_autoAbstractDots;
     } else {
         $abstract = mb_substr($abstract, 0, $length - $tailLen);
     }
     $this->abstract = $abstract;
     return $this;
 }
 function loadTable($path)
 {
     $f = fopen($path, 'r');
     while ($line = fgets($f)) {
         $line = rtrim($line);
         $cells = mb_split(',', $line);
         $index = array_shift($cells);
         $items = array('index' => $index);
         $word = null;
         foreach ($cells as $cell) {
             $kv = mb_split('=', $cell);
             if ($kv[0] === '' || $kv[1] === '') {
                 continue;
             }
             if ($kv[0] === 'word') {
                 $word = $kv[1];
             } else {
                 $items[$kv[0]] = $kv[1];
             }
         }
         if (is_null($word)) {
             continue;
         }
         $this->m_Table[$word] = $items;
     }
     fclose($f);
 }
Example #19
0
function yarpp_extract_keywords($source, $max = 20)
{
    global $overusedwords;
    if (function_exists('mb_split')) {
        mb_regex_encoding(get_option('blog_charset'));
        $wordlist = mb_split('\\s*\\W+\\s*', mb_strtolower($source));
    } else {
        $wordlist = preg_split('%\\s*\\W+\\s*%', strtolower($source));
    }
    // Build an array of the unique words and number of times they occur.
    $tokens = array_count_values($wordlist);
    // Remove the stop words from the list.
    foreach ($overusedwords as $word) {
        unset($tokens[$word]);
    }
    // Remove words which are only a letter
    foreach (array_keys($tokens) as $word) {
        if (function_exists('mb_strlen')) {
            if (mb_strlen($word) < 2) {
                unset($tokens[$word]);
            } else {
                if (strlen($word) < 2) {
                    unset($tokens[$word]);
                }
            }
        }
    }
    arsort($tokens, SORT_NUMERIC);
    $types = array_keys($tokens);
    if (count($types) > $max) {
        $types = array_slice($types, 0, $max);
    }
    return implode(' ', $types);
}
Example #20
0
function cs2cs_core2($lat, $lon, $to)
{
    $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    if (mb_eregi('^[a-z0-9_ ,.\\+\\-=]*$', $to) == 0) {
        die("invalid arguments in command: " . $to . "\n");
    }
    $command = CS2CS . " +proj=latlong +ellps=WGS84 +to " . $to;
    $process = proc_open($command, $descriptorspec, $pipes);
    if (is_resource($process)) {
        fwrite($pipes[0], $lon . " " . $lat);
        fclose($pipes[0]);
        $stdout = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        $stderr = stream_get_contents($pipes[2]);
        fclose($pipes[2]);
        //
        // $procstat = proc_get_status($process);
        //
        // neither proc_close nor proc_get_status return reasonable results with PHP5 and linux 2.6.11,
        // see http://bugs.php.net/bug.php?id=32533
        //
        // as temporary (?) workaround, check stderr output.
        // (Vinnie, 2006-02-09)
        if ($stderr) {
            die("proc_open() failed:<br />command='{$command}'<br />stderr='" . $stderr . "'");
        }
        proc_close($process);
        return mb_split("\t|\n| ", mb_trim($stdout));
    } else {
        die("proc_open() failed, command={$command}\n");
    }
}
 public function buildFromString($data)
 {
     $text = $data['l_make'] . " " . $data['l_model'];
     if ($data['l_year']) {
         $text .= " שנת " . $data['l_year'] . "";
     }
     $text .= ". " . $data['l_d_price'] . " ש''ח. " . " פרטים באתר";
     $tmp = mb_split(" ", $text);
     $l = count($tmp);
     $i = 0;
     $this->ga_headline = 'מוכרים אותנו! ';
     while (mb_strlen($new, 'utf-8') < 36) {
         $old = $new;
         $new .= " " . $tmp[$i];
         $i++;
     }
     $this->ga_description1 = trim($old);
     $new = $tmp[$i - 1];
     $old = '';
     while (mb_strlen($new, 'utf-8') < 36) {
         $old = $new;
         $new .= " " . $tmp[$i];
         $i++;
     }
     $this->ga_description2 = trim($old);
     $old = '';
     if (!$this->ga_description2) {
         $this->ga_description2 = '{KEYWORD:כל המודעות באתר אחד}';
     }
 }
Example #22
0
function downloadpictures()
{
    global $opt;
    // Bilder abrufen?
    if ($opt['pictures']['download'] != 1) {
        return;
    }
    $rs = sql('SELECT COUNT(*) `c` FROM `pictures` WHERE `local`=0');
    $rCount = sql_fetch_array($rs);
    mysql_free_result($rs);
    $nFileNr = 0;
    $rs = sql('SELECT `id`, `url` FROM `pictures` WHERE `local`=0');
    while ($r = sql_fetch_array($rs)) {
        $nFileNr++;
        $fileparts = mb_split('/', $r['url']);
        $filename = $fileparts[count($fileparts) - 1];
        echo 'Downloading file ' . $nFileNr . ' of ' . $rCount['c'] . ': ' . $filename . "\n";
        $success = true;
        if (!file_exists($opt['pictures']['directory'] . $filename)) {
            if (!@copy($r['url'], $opt['pictures']['directory'] . $filename)) {
                echo 'error: Download nicht erfolgreich' . "\n";
                $success = false;
            }
        }
        if ($success == true) {
            sql("UPDATE `pictures` SET `local`=1, `url`='&1' WHERE `id`='&2'", $opt['pictures']['url'] . $filename, $r['id']);
        }
    }
    mysql_free_result($rs);
}
 function processAttribute($shortcode, $attr)
 {
     $default = array();
     $Validation = new PBValidation();
     $repeat = 1;
     $shortcode = str_replace(PLUGIN_PAGE_BUILDER_SHORTCODE_PREFIX . $this->getComponentId(), '', $shortcode, $repeat);
     if (mb_substr($shortcode, 0, 1) == '_') {
         $shortcode = mb_substr($shortcode, 1);
     }
     foreach ($this->component['structure']['element'] as $element) {
         $path = mb_split('/', preg_replace('/\\*/', '', $element['shortcode']['path']));
         $count = count($path);
         if (!(mb_substr($path[$count - 1], 0, 1) == '@' && $path[$count - 1] != '@content')) {
             continue;
         }
         $name = mb_substr($path[$count - 1], 1);
         if ($name == 'param') {
             $name = $element['id'];
         }
         if ($count == 1) {
             if ($Validation->isEmpty($shortcode)) {
                 $default[$name] = $element['shortcode']['default'];
             }
         } else {
             if ($shortcode == $path[$count - 2]) {
                 $default[$name] = $element['shortcode']['default'];
             }
         }
     }
     return shortcode_atts($default, $attr);
 }
Example #24
0
 public function truncateParagraph($value, $length)
 {
     if ($value === '' || $length === 0) {
         return '';
     }
     $value = array_filter(array_map('trim', mb_split(PHP_EOL, $value)));
     return implode(PHP_EOL . PHP_EOL, array_slice($value, 0, $length));
 }
 public function addKeywordList($data)
 {
     $this->del($data['id_keyword']);
     $keyword = array_unique(array_filter(mb_split('[,,\\t\\r\\n\\s]+', $data['keyword'])));
     foreach ($keyword as $Key => $value) {
         $dta = array('id_keyword' => $data['id_keyword'], 'keyword' => strtolower($value), 'cat_id' => $data['cat_id'], 'category' => $data['category']);
         $this->insert_replace($dta);
     }
 }
function convert_patterns($patterns)
{
    $patterns = mb_split(' ', $patterns);
    $new_patterns = array();
    for ($i = 0; $i < count($patterns); $i++) {
        $value = $patterns[$i];
        $new_patterns[preg_replace('/[0-9]/', '', $value)] = $value;
    }
    return $new_patterns;
}
Example #27
0
 /**
  * Конвертиррования в транслит
  *
  * @param string $str
  * @param string $delimiter
  * @param int    $crop
  *
  * @return string
  */
 public static function t15n($str, $delimiter = '-', $crop = 0)
 {
     $result = mb_strtolower($str, 'UTF-8');
     $result = $crop > 0 ? self::cropText($result, $crop) : $result;
     $rus = mb_split('-', 'а-б-в-г-д-е-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ы-э-ж-з-ч-ш-щ-ю-я');
     $tra = mb_split('-', 'a-b-v-g-d-e-i-y-k-l-m-n-o-p-r-s-t-u-f-h-c-y-e-zh-z-ch-sh-shch-u-ya');
     $result = str_replace($rus, $tra, $result);
     $result = preg_replace("/[^a-zA-Z0-9\\/_|+ -]/", '', $result);
     $result = preg_replace("/[\\/_|+ -]+/", $delimiter, $result);
     return $result;
 }
 function load()
 {
     $file = fopen(ConfPath::replyList($this->name), "r");
     while ($line = fgets($file)) {
         $line = rtrim($line);
         $cells = mb_split(',', $line);
         $sample = array('from' => array_shift($cells), 'to' => array_shift($cells), 'dimension' => $cells);
         $this->list[] = $sample;
     }
     fclose($file);
 }
	/**
	 * Constructor.
	 * This should be able to handle complex ranges like
	 * "45(iv)45-(v)7, 45(ii)52-61, and 45(ix)99-100".
	 * A dash or hyphen will be interpreted as a range, unless the number is
	 * enclosed in quotation marks.
	 * @param WCCitation $citation = the WCCitation object
	 * @param WCScopeEnum $scope = the scope (i.e., work, container, series, etc.)
	 * @param WCParameterEnum $type = the type of property.
	 * @param string $text = the unprocessed locator text.
	 */
	public function __construct( $text ) {
		$this->ranges = mb_split( self::$listTerms, $text ); # Split by range-delimiting terms like comma or and
		foreach( $this->ranges as &$range ) {
			if ( !preg_match( self::$rangeTerms, $range, $matches ) ) {
				$range = array( $range );
				continue;
			}
			$range = array( $matches[1], $matches[2] );
		}
		return;
	}
Example #30
0
 public static function isIPInNetArray($theip, $thearray)
 {
     $exit_c = false;
     foreach ($thearray as $subnet) {
         list($net, $mask) = mb_split("/", $subnet);
         if (self::isIPInNet($theip, $net, $mask)) {
             $exit_c = true;
             break;
         }
     }
     return $exit_c;
 }