ACC SHELL

Path : /var/lib/ntp/proc/self/root/srv/www/vhosts/duklavysco/app/model/
File Upload :
Current File : //var/lib/ntp/proc/self/root/srv/www/vhosts/duklavysco/app/model/MyString.php

<?php

class MyString {
  public static function truncate($string, $length, $e = '&hellip;', $isHTML = TRUE){
    $i = 0;
    $tags = array();

    if($isHTML) {
      preg_match_all('/<[^>]+>([^<]*)/', $string, $match, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);

      foreach($match as $object) {
        if($object[0][1] - $i >= $length) break;

        $tag = substr(strtok($object[0][0], " \t\n\r\0\x0B>"), 1);

        if($tag[0] != '/') $tags[] = $tag;
        elseif(end($tags) == substr($tag, 1)) array_pop($tags);

        $i += $object[1][1] - $object[0][1];
      }
    }

    return rtrim(substr($string, 0, $length = min(strlen($string),  $length + $i)))
      . (count($tags = array_reverse($tags)) ? ($e . '</') . implode('></', $tags) . '>' : '');
  }
}

ACC SHELL 2018