Ejemplo n.º 1
2
/**
 * utf8::str_pad
 *
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007 Kohana Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
{
    if (utf8::is_ascii($str) and utf8::is_ascii($pad_str)) {
        return str_pad($str, $final_str_length, $pad_str, $pad_type);
    }
    $str_length = utf8::strlen($str);
    if ($final_str_length <= 0 or $final_str_length <= $str_length) {
        return $str;
    }
    $pad_str_length = utf8::strlen($pad_str);
    $pad_length = $final_str_length - $str_length;
    if ($pad_type == STR_PAD_RIGHT) {
        $repeat = ceil($pad_length / $pad_str_length);
        return utf8::substr($str . str_repeat($pad_str, $repeat), 0, $final_str_length);
    }
    if ($pad_type == STR_PAD_LEFT) {
        $repeat = ceil($pad_length / $pad_str_length);
        return utf8::substr(str_repeat($pad_str, $repeat), 0, floor($pad_length)) . $str;
    }
    if ($pad_type == STR_PAD_BOTH) {
        $pad_length /= 2;
        $pad_length_left = floor($pad_length);
        $pad_length_right = ceil($pad_length);
        $repeat_left = ceil($pad_length_left / $pad_str_length);
        $repeat_right = ceil($pad_length_right / $pad_str_length);
        $pad_left = utf8::substr(str_repeat($pad_str, $repeat_left), 0, $pad_length_left);
        $pad_right = utf8::substr(str_repeat($pad_str, $repeat_right), 0, $pad_length_left);
        return $pad_left . $str . $pad_right;
    }
    trigger_error('utf8::str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR);
}
Ejemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     if (!config::item('news_blog', 'news') && uri::segment(1) != 'news') {
         router::redirect('news/' . utf8::substr(uri::getURI(), 5));
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns an array of the names of the days, using the current locale.
  *
  * @param   integer  left of day names
  * @return  array
  */
 public static function days($length = TRUE)
 {
     // strftime day format
     $format = $length > 3 ? '%A' : '%a';
     // Days of the week
     $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
     if (Calendar::$start_monday === TRUE) {
         // Push Sunday to the end of the days
         array_push($days, array_shift($days));
     }
     if (strpos(Kohana::config('locale.language.0'), 'en') !== 0) {
         // This is a bit awkward, but it works properly and is reliable
         foreach ($days as $i => $day) {
             // Convert the English names to i18n names
             $days[$i] = strftime($format, strtotime($day));
         }
     }
     if (is_int($length) or ctype_digit($length)) {
         foreach ($days as $i => $day) {
             // Shorten the days to the expected length
             $days[$i] = utf8::substr($day, 0, $length);
         }
     }
     return $days;
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     parent::__construct();
     if (!config::item('news_active', 'news')) {
         error::show404();
     } elseif (!session::permission('news_access', 'news')) {
         view::noAccess();
     } elseif (config::item('news_blog', 'news') && uri::segment(1) != 'blog') {
         router::redirect('blog/' . utf8::substr(uri::getURI(), 5));
     }
     loader::model('news/news');
 }
Ejemplo n.º 5
0
 public static function number_to_text($value, $separator = ' ')
 {
     $digits = (string) $value;
     if (utf8::strpos($digits, '.') !== FALSE) {
         $digits = explode('.', $digits);
         return static::number_to_text($digits[0]) . $separator . static::number_to_text($digits[1]);
     }
     $jednosci = array('zero', 'jeden', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć', 'siedem', 'osiem', 'dziewięć');
     $dziesiatki = array('', 'dziesięć', 'dwadzieścia', 'trzydzieści', 'czterdzieści', 'piećdziesiąt', 'sześćdziesiąt', 'siedemdziesiąt', 'osiemdziesiąt', 'dziewiećdziesiąt');
     $setki = array('', 'sto', 'dwieście', 'trzysta', 'czterysta', 'piećset', 'sześćset', 'siedemset', 'osiemset', 'dziewiećset');
     $nastki = array('dziesieć', 'jedenaście', 'dwanaście', 'trzynaście', 'czternaście', 'piętnaście', 'szesnaście', 'siedemnaście', 'osiemnaście', 'dzięwietnaście');
     $tysiace = array('tysiąc', 'tysiące', 'tysięcy');
     $digits = (string) $value;
     $digits = utf8::strrev($digits);
     $i = utf8::strlen($digits);
     $string = '';
     if ($i > 5 && $digits[5] > 0) {
         $string .= $setki[$digits[5]] . ' ';
     }
     if ($i > 4 && $digits[4] > 1) {
         $string .= $dziesiatki[$digits[4]] . ' ';
     } elseif ($i > 3 && $digits[4] == 1) {
         $string .= $nastki[$digits[3]] . ' ';
     }
     if ($i > 3 && $digits[3] > 0 && $digits[4] != 1) {
         $string .= $jednosci[$digits[3]] . ' ';
     }
     $tmpStr = utf8::substr(utf8::strrev($digits), 0, -3);
     if (utf8::strlen($tmpStr) > 0) {
         $tmpInt = (int) $tmpStr;
         if ($tmpInt == 1) {
             $string .= $tysiace[0] . ' ';
         } elseif ($tmpInt % 10 > 1 && $tmpInt % 10 < 5 && ($tmpInt < 10 || $tmpInt > 20)) {
             $string .= $tysiace[1] . ' ';
         } else {
             $string .= $tysiace[2] . ' ';
         }
     }
     if ($i > 2 && $digits[2] > 0) {
         $string .= $setki[$digits[2]] . ' ';
     }
     if ($i > 1 && $digits[1] > 1) {
         $string .= $dziesiatki[$digits[1]] . ' ';
     } elseif ($i > 0 && $digits[1] == 1) {
         $string .= $nastki[$digits[0]] . ' ';
     }
     if ($digits[0] > 0 && $digits[1] != 1) {
         $string .= $jednosci[$digits[0]] . ' ';
     }
     return $string;
 }
Ejemplo n.º 6
0
/**
 * utf8::strrpos
 *
 * @package    Kohana
 * @author     Kohana Team
 * @copyright  (c) 2007-2008 Kohana Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _strrpos($str, $search, $offset = 0)
{
    $offset = (int) $offset;
    if (utf8::is_ascii($str) and utf8::is_ascii($search)) {
        return strrpos($str, $search, $offset);
    }
    if ($offset == 0) {
        $array = explode($search, $str, -1);
        return isset($array[0]) ? utf8::strlen(implode($search, $array)) : FALSE;
    }
    $str = utf8::substr($str, $offset);
    $pos = utf8::strrpos($str, $search);
    return $pos === FALSE ? FALSE : $pos + $offset;
}
Ejemplo n.º 7
0
 /**
  * Limits a phrase to a given number of characters.
  *
  * @param   string   phrase to limit characters of
  * @param   integer  number of characters to limit to
  * @param   string   end character or entity
  * @param   boolean  enable or disable the preservation of words while limiting
  * @return  string
  */
 public static function limit_chars($str, $limit = 100, $end_char = NULL, $preserve_words = FALSE)
 {
     $end_char = $end_char === NULL ? '&#8230;' : $end_char;
     $limit = (int) $limit;
     if (trim($str) === '' or utf8::strlen($str) <= $limit) {
         return $str;
     }
     if ($limit <= 0) {
         return $end_char;
     }
     if ($preserve_words == FALSE) {
         return rtrim(utf8::substr($str, 0, $limit)) . $end_char;
     }
     preg_match('/^.{' . ($limit - 1) . '}\\S*/us', $str, $matches);
     return rtrim($matches[0]) . (strlen($matches[0]) == strlen($str) ? '' : $end_char);
 }
Ejemplo n.º 8
0
/**
 * utf8::strcspn
 *
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007 Kohana Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _strcspn($str, $mask, $offset = NULL, $length = NULL)
{
    if ($str == '' or $mask == '') {
        return 0;
    }
    if (utf8::is_ascii($str) and utf8::is_ascii($mask)) {
        return $offset === NULL ? strcspn($str, $mask) : ($length === NULL ? strcspn($str, $mask, $offset) : strcspn($str, $mask, $offset, $length));
    }
    if ($start !== NULL or $length !== NULL) {
        $str = utf8::substr($str, $offset, $length);
    }
    // Escape these characters:  - [ ] . : \ ^ /
    // The . and : are escaped to prevent possible warnings about POSIX regex elements
    $mask = preg_replace('#[-[\\].:\\\\^/]#', '\\\\$0', $mask);
    preg_match('/^[^' . $mask . ']+/u', $str, $matches);
    return isset($matches[0]) ? utf8::strlen($matches[0]) : 0;
}
Ejemplo n.º 9
0
 /**
  * Limits a phrase to a given number of characters.
  *
  * $text = static::limit_chars($text);
  *
  * @param   string   phrase to limit characters of
  * @param   integer  number of characters to limit to
  * @param   string   end character or entity
  * @param   boolean  enable or disable the preservation of words while limiting
  * @return  string
  * @uses    \utf8::strlen
  */
 public static function limit_chars($str, $limit = 100, $end_char = null, $preserve_words = false)
 {
     $end_char = $end_char === null ? '…' : $end_char;
     $limit = (int) $limit;
     if (\trim($str) === '' || \utf8::strlen($str) <= $limit) {
         return $str;
     }
     if ($limit <= 0) {
         return $end_char;
     }
     if ($preserve_words === false) {
         return \rtrim(\utf8::substr($str, 0, $limit)) . $end_char;
     }
     // Don't preserve words. The limit is considered the top limit.
     // No strings with a length longer than $limit should be returned.
     if (!\preg_match('/^.{0,' . $limit . '}\\s/us', $str, $matches)) {
         return $end_char;
     }
     return \rtrim($matches[0]) . (\strlen($matches[0]) === \strlen($str) ? '' : $end_char);
 }
Ejemplo n.º 10
0
 /**
  * 获取文章详情
  * @param int $id
  * @return array $data;
  */
 public function detail($id)
 {
     // $memkey = MEMPREFIX . 'article:detail' . $id;
     $data = false;
     if (is_numeric($id)) {
         //$data = $this->memcache->get($memkey);
         // $data = false;
         if ($data == false) {
             $detail = $this->db->get('news', ['id', 'catid', 'title', 'keywords', 'description', 'listorder', 'uid', 'username', 'url', 'islink', 'inputtime', 'updatetime'], ['AND' => ['id' => $id, 'status' => 99]]);
             // $data != false;
             if ($detail != false) {
                 $data = $this->db->get('news_data', ['content', 'fromweb'], ['id' => $id]);
                 $data == false && ($data = []);
                 $data = array_merge($detail, $data);
                 $data['description'] == false && ($data['description'] = utf8::substr(strip_tags($data['content']), 0, 78) . '...');
             }
             // $data <> false && $this->memcache->set($memkey, $data, MEMCACHE_COMPRESSED, 3600 * 24);
         }
     }
     return $data;
 }
Ejemplo n.º 11
0
 /**
  * Returns an array of the names of the days, using the current locale.
  *
  * @param   integer  left of day names
  * @return  array
  */
 public static function days($length = TRUE)
 {
     // strftime day format
     $format = $length > 3 ? '%A' : '%a';
     // Days of the week
     for ($i = 0; $i < 7; $i++) {
         //	$days[] = strftime($format, strtotime('+'.$i.' day', 300000));
         //	$days[] = strftime($format, ($i * 60*60*24 + 300000));
         $days[] = strftime($format, $i * 86400 + 300000);
     }
     if (Calendar::$start_monday === TRUE) {
         // Push Sunday to the end of the days
         array_push($days, array_shift($days));
     }
     if (is_int($length) or ctype_digit($length)) {
         foreach ($days as $i => $day) {
             // Shorten the days to the expected length
             $days[$i] = utf8::substr($day, 0, $length);
         }
     }
     return $days;
 }
Ejemplo n.º 12
0
 public function upload()
 {
     if (!$_FILES) {
         return;
     }
     $surfix = Kohana::config('torn')->surfix->temp;
     $surfix_len = utf8::strlen($surfix);
     foreach ($_POST as $key => $tmp_name) {
         if (utf8::substr($key, -$surfix_len) == $surfix) {
             $field = utf8::substr($key, 0, -$surfix_len);
             $this->parent->model->set($field, $tmp_name);
         }
     }
     $cache = Cache::instance();
     foreach ($_FILES as $key => $upload) {
         $this->parent->model->set($key, $upload);
         if (!isset($this->parent->fields[$key]) or !$this->parent->fields[$key] instanceof Torn_Field_File) {
             continue;
         }
         if (upload::not_empty($upload) and upload::valid($upload)) {
             $seed = Arr::get($_POST, '__SEED__', md5(Request::current()->uri() . time()));
             $tmp_name = $seed . '-' . md5_file($upload['tmp_name']);
             if (upload::save($upload, $tmp_name, Kohana::$cache_dir) !== FALSE) {
                 $timestamp = 24 * 60 * 60;
                 $cache->set($tmp_name, array('upload' => $upload, 'timestamp' => $timestamp), $timestamp);
                 $tmp_old_file = Arr::get($_POST, $key . $surfix);
                 if (!empty($tmp_old_file) and file_exists(Kohana::$cache_dir . DIRECTORY_SEPARATOR . $tmp_old_file)) {
                     try {
                         unlink(Kohana::$cache_dir . DIRECTORY_SEPARATOR . $tmp_old_file);
                         $cache->delete($tmp_old_file);
                     } catch (Exception $e) {
                     }
                 }
                 $this->parent->model->set($key, $tmp_name);
             }
         }
     }
 }
Ejemplo n.º 13
0
 public function account_number($p_iNRB)
 {
     // Usuniecie spacji
     $iNRB = utf8::str_ireplace(' ', '', $p_iNRB);
     // Sprawdzenie czy przekazany numer zawiera 26 znaków
     if (utf8::strlen($iNRB) != 26) {
         die('fail #1');
         return false;
     }
     // Zdefiniowanie tablicy z wagami poszczególnych cyfr
     $aWagiCyfr = array(1, 10, 3, 30, 9, 90, 27, 76, 81, 34, 49, 5, 50, 15, 53, 45, 62, 38, 89, 17, 73, 51, 25, 56, 75, 71, 31, 19, 93, 57);
     // Dodanie kodu kraju (w tym przypadku dodajemy kod PL)
     $iNRB = $iNRB . '2521';
     $iNRB = utf8::substr($iNRB, 2) . utf8::substr($iNRB, 0, 2);
     // Wyzerowanie zmiennej
     $iSumaCyfr = 0;
     // Pćtla obliczająca sumć cyfr w numerze konta
     for ($i = 0; $i < 30; $i++) {
         $iSumaCyfr += $iNRB[29 - $i] * $aWagiCyfr[$i];
     }
     // Sprawdzenie czy modulo z sumy wag poszczegolnych cyfr jest rowne 1
     return $iSumaCyfr % 97 == 1;
 }
Ejemplo n.º 14
0
 /**
  * Outputs the Captcha image.
  *
  * @param boolean $html HTML output
  * @return mixed
  */
 public function render($html = TRUE)
 {
     // Creates $this->image
     $this->image_create(Captcha::$config['background']);
     // Add a random gradient
     if (empty(Captcha::$config['background'])) {
         $color1 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255));
         $color2 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255));
         $this->image_gradient($color1, $color2);
     }
     // Add a few random lines
     for ($i = 0, $count = mt_rand(5, Captcha::$config['complexity'] * 4); $i < $count; $i++) {
         $color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(100, 255), mt_rand(50, 120));
         imageline($this->image, mt_rand(0, Captcha::$config['width']), 0, mt_rand(0, Captcha::$config['width']), Captcha::$config['height'], $color);
     }
     // Calculate character font-size and spacing
     $default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / (utf8::strlen($this->response) + 1);
     $spacing = (int) (Captcha::$config['width'] * 0.9 / utf8::strlen($this->response));
     // Draw each Captcha character with varying attributes
     for ($i = 0, $strlen = utf8::strlen($this->response); $i < $strlen; $i++) {
         // Use different fonts if available
         $font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
         // Allocate random color, size and rotation attributes to text
         $color = imagecolorallocate($this->image, mt_rand(0, 150), mt_rand(0, 150), mt_rand(0, 150));
         $angle = mt_rand(-40, 20);
         // Scale the character size on image height
         $size = $default_size / 10 * mt_rand(8, 12);
         $box = imageftbbox($size, $angle, $font, utf8::substr($this->response, $i, 1));
         // Calculate character starting coordinates
         $x = $spacing / 4 + $i * $spacing;
         $y = Captcha::$config['height'] / 2 + ($box[2] - $box[5]) / 4;
         // Write text character to image
         imagefttext($this->image, $size, $angle, $x, $y, $color, $font, utf8::substr($this->response, $i, 1));
     }
     // Output
     return $this->image_render($html);
 }
Ejemplo n.º 15
0
 public static function shorten_string($str, $max_length, $mid_cut = false)
 {
     if (!is_scalar($str)) {
         return false;
     }
     if (!is_int($max_length)) {
         return false;
     }
     $length = utf8::strlen($str);
     if ($length <= $max_length) {
         return $str;
     } elseif ($mid_cut) {
         $mid = (int) ceil($max_length / 2);
         $string = utf8::substr($str, 0, $mid) . '...' . utf8::substr($str, $mid);
     } else {
         return utf8::substr($str, 0, $max_length) . '...';
     }
 }
Ejemplo n.º 16
0
Archivo: text.php Proyecto: Toushi/flow
 /**
  * Generates a random string of a given type and length.
  *
  * @param   string   a type of pool, or a string of characters to use as the pool
  * @param   integer  length of string to return
  * @return  string
  *
  * @tutorial  alnum    - alpha-numeric characters
  * @tutorial  alpha    - alphabetical characters
  * @tutorial  numeric  - digit characters, 0-9
  * @tutorial  nozero   - digit characters, 1-9
  * @tutorial  distinct - clearly distinct alpha-numeric characters
  */
 public static function random($type = 'alnum', $length = 8)
 {
     $utf8 = FALSE;
     switch ($type) {
         case 'alnum':
             $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
             break;
         case 'alpha':
             $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
             break;
         case 'numeric':
             $pool = '0123456789';
             break;
         case 'nozero':
             $pool = '123456789';
             break;
         case 'distinct':
             $pool = '2345679ACDEFHJKLMNPRSTUVWXYZ';
             break;
         default:
             $pool = (string) $type;
             $utf8 = !utf8::is_ascii($pool);
             break;
     }
     $str = '';
     $pool_size = $utf8 === TRUE ? utf8::strlen($pool) : strlen($pool);
     for ($i = 0; $i < $length; $i++) {
         $str .= $utf8 === TRUE ? utf8::substr($pool, mt_rand(0, $pool_size - 1), 1) : substr($pool, mt_rand(0, $pool_size - 1), 1);
     }
     return $str;
 }
Ejemplo n.º 17
0
function sql_timestamp_to_unix_timestamp($s)
{
    return mktime(utf8::substr($s, 11, 2), utf8::substr($s, 14, 2), utf8::substr($s, 17, 2), utf8::substr($s, 5, 2), utf8::substr($s, 8, 2), utf8::substr($s, 0, 4));
}
Ejemplo n.º 18
0
 function mb_substr($str, $start, $length = NULL)
 {
     return utf8::substr($str, $start, $length);
 }
Ejemplo n.º 19
0
function format_quotes($s)
{
    $old_s = '';
    while ($old_s != $s) {
        $old_s = $s;
        //-- Find First Occurrence Of [/quote]
        $close = strpos($s, "[/quote]");
        if ($close === false) {
            return $s;
        }
        //-- Find Last [quote] Before First [/quote] --//
        //-- Note That There Is No Check For Correct Syntax --//
        $open = strripos(utf8::substr($s, 0, $close), "[quote");
        if ($open === false) {
            return $s;
        }
        $quote = utf8::substr($s, $open, $close - $open + 8);
        //-- [quote]Text[/quote] --//
        $quote = preg_replace("/\\[quote\\]\\s*((\\s|.)+?)\\s*\\[\\/quote\\]\\s*/i", "<span class='sub'><strong>Quote:</strong></span><table class='main' border='1' cellspacing='0' cellpadding='10'><tr><td style='border: 1px black dotted'>\\1</td></tr></table><br />", $quote);
        //-- [quote=Author]Text[/quote] --//
        $quote = preg_replace("/\\[quote=(.+?)\\]\\s*((\\s|.)+?)\\s*\\[\\/quote\\]\\s*/i", "<span class='sub'><strong>\\1 wrote:</strong></span><table class='main' border='1' cellspacing='0' cellpadding='10'><tr><td style='border: 1px black dotted'>\\2</td></tr></table><br />", $quote);
        $s = utf8::substr($s, 0, $open) . $quote . utf8::substr($s, $close + 8);
    }
    return $s;
}
Ejemplo n.º 20
0
 public function feeds_format(&$feed)
 {
     $date = array();
     if (!empty($feed)) {
         $clicknum = 0;
         $feed['dateline'] = date("m月d日 H:i", $feed['dateline']);
         $avatar_src = 'upload/avatar/' . image::get_dir($feed['uid']) . '/' . $feed['uid'] . '_avatar_middle.jpg';
         $feed['avatar'] = file_exists($avatar_src) ? $avatar_src : './Tpl/image/user_icon50.jpg';
         if (!empty($feed['fid'])) {
             $foruminfo = $this->forum->where("fid = {$feed['fid']}")->find();
             if (!empty($foruminfo)) {
                 $feed['forumname'] = $foruminfo['name'];
             }
         }
         $app_url = C("APP_URL");
         switch ($feed['type']) {
             case 'post':
                 $threadinfo = $this->thread->where("fid = {$feed['fid']} and tid = {$feed['tid']}")->find();
                 if (!empty($threadinfo)) {
                     $feed['username'] = $threadinfo['username'];
                     $feed['subject'] = utf8::substr($threadinfo['subject'], 0, 18);
                     $img1 = 'upload/attach/' . $threadinfo['coversrc1'];
                     $feed['coversrc1'] = file_exists($img1) && !empty($threadinfo['coversrc1']) ? $app_url . 'upload/attach/' . $threadinfo['coversrc1'] : '';
                     $feed['coversrc2'] = $threadinfo['coversrc2'];
                     $feed['coversrc3'] = $threadinfo['coversrc3'];
                     $feed['summary'] = utf8::substr($threadinfo['summary'], 0, 100);
                     $feed['views'] = $threadinfo['views'];
                     $feed['posts'] = $threadinfo['posts'];
                     $feed['astars'] = $threadinfo['astars'];
                 }
                 break;
             case 'message':
                 if (!empty($feed['feedid'])) {
                     $messageinfo = $this->forummessage->where("mid = {$feed['feedid']}")->find();
                     if (!empty($messageinfo)) {
                         //$feed['message'] = utf8::substr($messageinfo['message'], 0, 20);
                         $feed['message'] = $messageinfo['message'];
                     }
                 }
                 break;
             case 'reply':
                 $threadinfo = $this->thread->where("fid = {$feed['fid']} and tid = {$feed['tid']}")->find();
                 if (!empty($threadinfo)) {
                     $feed['authoruid'] = $threadinfo['uid'];
                     $feed['author'] = $threadinfo['username'];
                     $authoravatar_src = 'upload/avatar/' . image::get_dir($threadinfo['uid']) . '/' . $threadinfo['uid'] . '_avatar_middle.jpg';
                     $feed['authoravatar'] = file_exists($authoravatar_src) ? $authoravatar_src : './Tpl/image/user_icon50.jpg';
                     $feed['subject'] = utf8::substr($threadinfo['subject'], 0, 18);
                     $img1 = 'upload/attach/' . $threadinfo['coversrc1'];
                     $feed['coversrc1'] = file_exists($img1) && !empty($threadinfo['coversrc1']) ? $app_url . 'upload/attach/' . $threadinfo['coversrc1'] : '';
                     $feed['coversrc2'] = $threadinfo['coversrc2'];
                     $feed['coversrc3'] = $threadinfo['coversrc3'];
                     $feed['summary'] = utf8::substr($threadinfo['summary'], 0, 100);
                     $feed['views'] = $threadinfo['views'];
                     $feed['posts'] = $threadinfo['posts'];
                     $feed['astars'] = $threadinfo['astars'];
                     $threadreply = $this->threadreply->where("fid = {$feed['fid']} and tid = {$feed['tid']} and uid = {$feed['uid']}")->order("replyid DESC")->limit(0, 1)->select();
                     $feed['replyinfo'] = array();
                     if (!empty($threadreply)) {
                         foreach ($threadreply as &$rep) {
                             $rep['message'] = utf8::substr($rep['message'], 0, 80);
                             $avatar_src = 'upload/avatar/' . image::get_dir($rep['uid']) . '/' . $rep['uid'] . '_avatar_middle.jpg';
                             $rep['avatar'] = file_exists($avatar_src) ? $avatar_src : 'Tpl/image/user_icon50.jpg';
                             $rep['dateline'] = date("m月d日 H:i", $rep['dateline']);
                             array_push($feed['replyinfo'], $rep);
                         }
                     }
                 }
                 break;
             case 'threadgrade':
                 $threadinfo = $this->thread->where("fid = {$feed['fid']} and tid = {$feed['tid']}")->find();
                 if (!empty($threadinfo)) {
                     $feed['subject'] = utf8::substr($threadinfo['subject'], 0, 18);
                     $feed['authoruid'] = $threadinfo['uid'];
                     $feed['author'] = $threadinfo['username'];
                     $authoravatar_src = 'upload/avatar/' . image::get_dir($threadinfo['uid']) . '/' . $threadinfo['uid'] . '_avatar_middle.jpg';
                     $feed['authoravatar'] = file_exists($authoravatar_src) ? $authoravatar_src : './Tpl/image/user_icon50.jpg';
                     $img1 = 'upload/attach/' . $threadinfo['coversrc1'];
                     $feed['coversrc1'] = file_exists($img1) && !empty($threadinfo['coversrc1']) ? $app_url . 'upload/attach/' . $threadinfo['coversrc1'] : '';
                     $feed['coversrc2'] = $threadinfo['coversrc2'];
                     $feed['coversrc3'] = $threadinfo['coversrc3'];
                     $feed['summary'] = utf8::substr($threadinfo['summary'], 0, 100);
                     $feed['views'] = $threadinfo['views'];
                     $feed['posts'] = $threadinfo['posts'];
                     $feed['astars'] = $threadinfo['astars'];
                 }
                 break;
             case 'stopic':
                 $feed['typestr'] = '专题';
                 //$feed['dateline'] = date("Y-m-d", $feed['dateline']);
                 $icon_src = 'upload/stopic_banner/' . image::get_dir($feed['feedid']) . '/' . $feed['feedid'] . '_icon.jpg';
                 $icon = file_exists($icon_src) ? $icon_src : 'Tpl/image/350_235.jpg';
                 $stopic = $this->stopic->where("stopicid = '" . $feed['feedid'] . "'")->find();
                 if (!empty($stopic)) {
                     $feed['stopicid'] = $stopic['stopicid'];
                     $feed['replys'] = $stopic['replys'];
                     $feed['stopic_name'] = utf8::substr($stopic['name'], 0, 17);
                     $feed['stopic_description'] = utf8::substr($stopic['description'], 0, 100);
                 }
                 break;
             case 'addforum':
                 break;
             case 'upgrade':
                 break;
             default:
         }
         return $feed;
     } else {
         return array();
     }
 }