Exemple #1
1
 /**
  * Get file extension by file header signature.
  *
  * @param string $stream
  *
  * @return string
  */
 public static function getExtBySignature($stream)
 {
     $prefix = strval(bin2hex(mb_strcut($stream, 0, 10)));
     foreach (self::$signatures as $signature => $extension) {
         if (0 === strpos($prefix, strval($signature))) {
             return $extension;
         }
     }
     return '';
 }
 /**
  * Generate list of X-Cache-Tag header values which are less than 255 bytes each
  *
  * @param $cacheTagList
  * @return array
  */
 public function get255ByteCacheTagHeaderStringValues($cacheTagList)
 {
     $cacheTagHeaderList = array();
     $cacheTagHeader = "";
     foreach ($cacheTagList as $cacheTag) {
         $cacheTagHeaderEncoding = mb_detect_encoding($cacheTagHeader);
         $cacheTagEncoding = mb_detect_encoding($cacheTag);
         //Is this cache tag larger than 255 bytes?
         if (mb_strlen($cacheTag, $cacheTagEncoding) >= 255) {
             array_push($cacheTagHeaderList, mb_strcut($cacheTag, 1, 255));
         } else {
             if (mb_strlen($cacheTagHeader, $cacheTagHeaderEncoding) + mb_strlen("," . $cacheTag, $cacheTagEncoding) > 255) {
                 //Start new header
                 array_push($cacheTagHeaderList, $cacheTagHeader);
                 $cacheTagHeader = $cacheTag;
             } else {
                 //Append cache tag to cache tag header
                 if ($cacheTagHeader !== "") {
                     //avoid creating headers that start with a comma.
                     $cacheTagHeader = $cacheTagHeader . ",";
                 }
                 $cacheTagHeader = $cacheTagHeader . $cacheTag;
             }
         }
     }
     array_push($cacheTagHeaderList, $cacheTagHeader);
     return $cacheTagHeaderList;
 }
 public function add()
 {
     $data['title'] = I('title', '未命名');
     $data['text'] = stripslashes($_POST['content']);
     $data['tid'] = I('tid', 1);
     $data['cid'] = I('cid', 1);
     $data['ispage'] = I('ispage', 1);
     $data['iscomment'] = I('iscomment', 1);
     $data['status'] = I('status', 1);
     $data['uid'] = session('ey_id');
     if ($_POST['abscontent']) {
         $data['abscontent'] = $_POST['abscontent'];
     } else {
         $data['abscontent'] = mb_strcut(strip_tags($_POST['content']), 0, 200, 'utf-8');
         //提取前200个字符
     }
     if ($_POST['id']) {
         $rs = M('contents')->where('id=' . $_POST['id'])->save($data);
     } else {
         $data['time'] = time();
         $rs = M('contents')->add($data);
     }
     if ($rs) {
         die(json_encode(array('status' => 1, 'msg' => '操作成功!')));
     } else {
         die(json_encode(array('status' => 0, 'msg' => '操作失败')));
     }
 }
Exemple #4
0
function ignoreHtml($html, $maxLength = 100)
{
    mb_internal_encoding("UTF-8");
    $printedLength = 0;
    $position = 0;
    $tags = array();
    $newContent = '';
    $html = $content = preg_replace("/<img[^>]+\\>/i", "", $html);
    while ($printedLength < $maxLength && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position)) {
        list($tag, $tagPosition) = $match[0];
        // Print text leading up to the tag.
        $str = mb_strcut($html, $position, $tagPosition - $position);
        if ($printedLength + mb_strlen($str) > $maxLength) {
            $newstr = mb_strcut($str, 0, $maxLength - $printedLength);
            $newstr = preg_replace('~\\s+\\S+$~', '', $newstr);
            $newContent .= $newstr;
            $printedLength = $maxLength;
            break;
        }
        $newContent .= $str;
        $printedLength += mb_strlen($str);
        if ($tag[0] == '&') {
            // Handle the entity.
            $newContent .= $tag;
            $printedLength++;
        } else {
            // Handle the tag.
            $tagName = $match[1][0];
            if ($tag[1] == '/') {
                // This is a closing tag.
                $openingTag = array_pop($tags);
                assert($openingTag == $tagName);
                // check that tags are properly nested.
                $newContent .= $tag;
            } else {
                if ($tag[mb_strlen($tag) - 2] == '/') {
                    // Self-closing tag.
                    $newContent .= $tag;
                } else {
                    // Opening tag.
                    $newContent .= $tag;
                    $tags[] = $tagName;
                }
            }
        }
        // Continue after the tag.
        $position = $tagPosition + mb_strlen($tag);
    }
    // Print any remaining text.
    if ($printedLength < $maxLength && $position < mb_strlen($html)) {
        $newstr = mb_strcut($html, $position, $maxLength - $printedLength);
        $newstr = preg_replace('~\\s+\\S+$~', '', $newstr);
        $newContent .= $newstr;
    }
    // Close any open tags.
    while (!empty($tags)) {
        $newContent .= sprintf('</%s>', array_pop($tags));
    }
    return $newContent . "...";
}
Exemple #5
0
 private function parseArgList()
 {
     $currentKey = "";
     foreach ($this->rawArgs as $arg) {
         if ($arg[0] == "-") {
             if ($currentKey) {
                 $this->namedArgs[$currentKey] = "";
             }
             if ($arg[1] == "-") {
                 if (strpos($arg, "=")) {
                     list($currentKey, $value) = explode("=", $arg);
                     $this->namedArgs[$currentKey] = $value;
                     $currentKey = "";
                 } else {
                     $currentKey = $arg;
                 }
             } else {
                 $currentKey = mb_strcut($arg, 0, 2);
                 $value = mb_strcut($arg, 2);
                 $this->namedArgs[$currentKey] = $value;
                 $currentKey = "";
             }
         } else {
             if ($currentKey) {
                 $this->namedArgs[$currentKey] = $arg;
                 $currentKey = "";
             } else {
                 $this->listArgs[] = $arg;
             }
         }
     }
     if ($currentKey) {
         $this->namedArgs[$currentKey] = "";
     }
 }
Exemple #6
0
 public static function cutStr($str, $length, $add = '...')
 {
     if (mb_strlen($str) > $length) {
         $str = mb_strcut($str, 0, $length) . $add;
     }
     return $str;
 }
 /**
  * Turns the object back into a serialized blob.
  *
  * @return string
  */
 public function serialize()
 {
     $str = $this->name;
     if ($this->group) {
         $str = $this->group . '.' . $this->name;
     }
     $src = array(';');
     $out = array(',');
     if (is_array($this->value)) {
         $this->value = implode(',', $this->value);
     }
     $value = strtr($this->value, array('\\,' => ',', '\\;' => ';'));
     $str .= ':' . str_replace($src, $out, $value);
     $out = '';
     while (strlen($str) > 0) {
         if (strlen($str) > 75) {
             $out .= mb_strcut($str, 0, 75, 'utf-8') . "\r\n";
             $str = ' ' . mb_strcut($str, 75, strlen($str), 'utf-8');
         } else {
             $out .= $str . "\r\n";
             $str = '';
             break;
         }
     }
     return $out;
 }
Exemple #8
0
 public function __call($attrName, $arguments)
 {
     if (preg_match('/^_render/', $attrName)) {
         $attrName = mb_strtolower(mb_strcut($attrName, 7));
         if (!empty($this->_options)) {
             $attrName = array_merge(array($attrName), $this->_options);
             $attrName = implode('_', $attrName);
         }
         $attrName = preg_replace('/[^\\w\\d-_]/ui', '', $attrName);
         // check if we have a getter for this property
         $getter = 'get' . ucfirst($attrName);
         if (method_exists($this->_user, $getter)) {
             $value = $this->_user->{$getter}();
         } else {
             // or try to get attribute value
             $value = $this->_user->getAttribute($attrName);
         }
         if ($this->_editableMode) {
             $this->_view->attribute = $attrName;
             $this->_view->value = $value;
             $this->_view->userId = $this->_user->getId();
             return $this->_view->render('user-attribute.phtml');
         }
         return $value;
     }
 }
 public function randomName()
 {
     $nameLib = ' 邦福歌国和康澜民宁平然顺翔晏宜怡易志昂然昂雄宾白宾鸿宾实彬彬彬炳彬郁斌斌斌蔚滨海波光波鸿波峻波涛博瀚博超博达博厚博简博明博容博赡博涉博实博涛博文博学博雅博延博艺博易博裕博远才捷才才艺才英才哲才俊成和成弘成化成济成礼成龙成仁成双成天成文成业成益成荫成周承承弼承德承恩承福承基承教承平承嗣承天承望承宣承颜承业承悦承允承运承载承泽承志德本德海德厚德华德辉德惠德容德润德寿德水德馨德曜德业德义德庸德佑德宇德元德运德泽德明昂白飙掣尘沉驰光翰航翮鸿虎捷龙鸾鸣鹏扬文翔星翼';
     $nameLibNum = (int) strlen($nameLib) / 3;
     $m = M('People');
     $havePeople = $m->count(1);
     while ($havePeople >= 0) {
         $havePeople--;
         if ($havePeople < 0) {
             break;
         }
         $namePos[0] = mb_strcut($nameLib, rand(0, $nameLibNum), 3, 'utf-8');
         $namePos[1] = mb_strcut($nameLib, rand(0, $nameLibNum), 3, 'utf-8');
         $namePos[2] = mb_strcut($nameLib, rand(0, $nameLibNum), 3, 'utf-8');
         $newName = $namePos[0] . $namePos[1] . $namePos[2];
         $origin = $m->limit($havePeople, 1)->field('name,pid')->select();
         dump($origin);
         $originName = $origin[0]['name'];
         $where['pid'] = $origin[0]['pid'];
         $result = $m->where($where)->setField('name', $newName);
         // dump($result);
         echo "{$originName} -> {$newName} ";
         if ($result === 1) {
             echo "OK <br> \n";
         } else {
             echo "X <br> \n";
         }
     }
 }
 /**
  * Turns the object back into a serialized blob.
  *
  * @return string
  */
 public function serialize()
 {
     $str = $this->name;
     if ($this->group) {
         $str = $this->group . '.' . $this->name;
     }
     foreach ($this->parameters as $param) {
         $str .= ';' . $param->serialize();
     }
     $src = array("\n");
     $out = array('\\n');
     $str .= ':' . str_replace($src, $out, $this->value);
     $out = '';
     while (strlen($str) > 0) {
         if (strlen($str) > 75) {
             $out .= mb_strcut($str, 0, 75, 'utf-8') . "\r\n";
             $str = ' ' . mb_strcut($str, 75, strlen($str), 'utf-8');
         } else {
             $out .= $str . "\r\n";
             $str = '';
             break;
         }
     }
     return $out;
 }
Exemple #11
0
 /**
  * splits item into new lines if necessary
  * @param string $item
  * @return CalendarStream
  */
 public function addItem($item)
 {
     $lines = array();
     $parts = explode(PHP_EOL, trim($item));
     $top = array_shift($parts);
     $lines[] = $top;
     if (empty($parts) === false) {
         $lines[0] .= "\\n";
         foreach ($parts as $line) {
             $block = ' ';
             //get number of bytes
             $length = strlen($line);
             if ($length > 75) {
                 $start = 0;
                 while ($start < $length) {
                     $block .= mb_strcut($line, $start, self::LINE_LENGTH, 'UTF-8');
                     $start = $start + self::LINE_LENGTH;
                     //add space if not last line
                     if ($start < $length) {
                         $block .= Constants::CRLF . ' ';
                     }
                 }
             } else {
                 $block = ' ' . $line;
             }
             $lines[] = $block . "\\n";
         }
     }
     $item = trim(implode(Constants::CRLF, $lines));
     $this->stream .= $item . Constants::CRLF;
     return $this;
 }
Exemple #12
0
 /**
  * грузим новости
  *
  * @param array $params
  * @param bool $user
  * @return array
  */
 public static function getList($params = [], $user = false)
 {
     if (empty($user)) {
         $user = Auth::instance()->get_user();
     }
     $db = Oracle::init();
     $agentIds = [$user['AGENT_ID']];
     if (!in_array($user['role'], array_keys(Access::$clientRoles))) {
         $agentIds[] = 0;
     }
     $sql = "select * from " . Oracle::$prefix . "V_WEB_NEWS where agent_id in (" . implode(',', $agentIds) . ")";
     $sql .= ' order by DATE_CREATE desc';
     if (!empty($params['pagination'])) {
         list($news, $more) = $db->pagination($sql, $params);
         foreach ($news as &$newsDetail) {
             $newsDetail['announce'] = strip_tags($newsDetail['CONTENT']);
             if (strlen($newsDetail['announce']) > 500) {
                 $newsDetail['announce'] = mb_strcut($newsDetail['announce'], 0, 500);
             }
         }
         return [$news, $more];
     }
     $news = $db->tree($sql, 'NEWS_ID', true);
     foreach ($news as &$newsDetail) {
         $newsDetail['announce'] = strip_tags($newsDetail['CONTENT']);
         if (strlen($newsDetail['announce']) > 500) {
             $newsDetail['announce'] = mb_strcut($newsDetail['announce'], 0, 500);
         }
     }
     return $news;
 }
Exemple #13
0
function sidebar_item_content_news($haswell = true)
{
    global $config, $db;
    $value = sidebar_item_top($haswell) . "            <h3>Latest News <span style='font-size:12px'><a href='news.php'>[more...]</a></span></h3>\n";
    $sql = "select * from news order by time_added desc limit 0," . $config["limits"]["news_on_index"];
    $none = true;
    foreach ($db->get_results($sql, ARRAY_A) as $row) {
        $none = false;
        $row['title'] = strip_tags($row['title']);
        if (strlen($row['title']) > $config["limits"]["news_on_index_title_len"]) {
            $row['title'] = mb_strcut($row['title'], 0, $config["limits"]["news_on_index_title_len"], 'UTF-8') . "<a name='" . $row['newsid'] . "' class='newslink' href='#'>[...]</a>";
        }
        $row['content'] = strip_tags($row['content']);
        if (strlen($row['content']) > $config["limits"]["news_on_index_content_len"]) {
            $row['content'] = mb_strcut($row['content'], 0, $config["limits"]["news_on_index_content_len"], 'UTF-8');
        }
        $row['content'] .= "<a name='" . $row['newsid'] . "' class='newslink' href='#'>[...]</a>";
        $value .= "            <h4>" . $row['title'] . "</h4>\n            <p>" . $row['content'] . "</p>\n";
    }
    if ($none) {
        $value .= "            No News.\n";
    }
    $value .= sidebar_item_bottom();
    return $value;
}
function mysubstr($s, $f, $l = 99999)
{
    if (XOOPS_USE_MULTIBYTES && function_exists("mb_strcut")) {
        return mb_strcut($s, $f, $l, _CHARSET);
    } else {
        return substr($s, $f, $l);
    }
}
Exemple #15
0
 protected function bulkSMSRequest(MessageVO $message)
 {
     //GOIP message max length is 3000 bytes
     $cutmessage = mb_strcut($message->getMessage(), 0, 3000);
     $msg = "MSG " . $message->getId() . " " . strlen($cutmessage) . " " . $cutmessage . "\n";
     socket_sendto($this->socket, $msg, strlen($msg), 0, $this->address, $this->port);
     return $this->listenToReply($message, "BulkSMSConfirm", "PASSWORD");
 }
 private function filterInput($msg)
 {
     $text = strip_tags(htmlentities($msg));
     if (mb_strlen($text) > 255) {
         $text = mb_strcut($text, 0, 255);
     }
     return $text;
 }
 public function _failed(TestInterface $test, $fail)
 {
     if (!$this->client || !$this->client->getInternalResponse()) {
         return;
     }
     $filename = preg_replace('~\\W~', '.', Descriptor::getTestSignature($test));
     $filename = mb_strcut($filename, 0, 244, 'utf-8') . '.fail.html';
     $this->_savePageSource(codecept_output_dir() . $filename);
 }
Exemple #18
0
 /**
  * Prepare the text fields and save them
  *
  * @param int $id
  * @return bool|int
  */
 public function save($data = '')
 {
     if (!empty($data[$this->pkey])) {
         $this->delete($data[$this->pkey]);
     }
     $data['full'] = prepare_text($data['original']);
     $data['short'] = mb_strcut($data['full'], 0, 250);
     // @todo: 250 should be in CONFIG
     return parent::insert($data);
 }
Exemple #19
0
 /**
  * создаем структуру папок под картинки
  *
  * @param $filename
  * @return string
  */
 public static function generateImageDirectory($filename)
 {
     $root = $_SERVER["DOCUMENT_ROOT"];
     $ds = DIRECTORY_SEPARATOR;
     $directory = $ds . 'upload' . $ds . mb_strcut($filename, 0, 2) . $ds . mb_strcut($filename, 2, 2) . $ds;
     if (!is_dir($root . $directory)) {
         mkdir($root . $directory, 0777, true);
     }
     return $directory;
 }
 /**
  * {@inheritDoc}
  */
 protected function write(array $record)
 {
     try {
         $this->sns->publish(['TopicArn' => $this->topicArn, 'Message' => mb_strcut($this->getFormatter()->format($record), 0, 262144), 'Subject' => $this->subject]);
     } catch (SnsException $e) {
         if ($this->logger) {
             $this->logger->error("Failed to send message via AmazonSNS", ['exception' => $e]);
         }
     }
 }
Exemple #21
0
 public static function get_content_with_ellipses($content, $max_len = 100)
 {
     $txt_content = preg_replace("/<.*?>/", "", $content);
     $len = strlen($txt_content);
     $result = $txt_content;
     if ($len + 3 > $max_len) {
         $result = mb_strcut($txt_content, 0, $max_len - 3, 'UTF-8') . "...";
     }
     return $result;
 }
 /**
  * C-o-R pattern
  * @param Chain $chain input stream
  * @return false|null|true
  */
 public function handleRequest(Chain $chain)
 {
     $request = $chain->getRequest();
     $text = strip_tags(htmlentities(trim($request['msg'])));
     $msgMaxLength = DI::get()->getConfig()->msgMaxLength;
     if (mb_strlen($text) > $msgMaxLength) {
         $text = mb_strcut($text, 0, $msgMaxLength) . self::CUT;
     }
     $request['msg'] = $text;
     $chain->setRequest($request);
 }
Exemple #23
0
function limit_text($text, $limit = 25)
{
    if (str_word_count($text, 0) > $limit) {
        $words = str_word_count($text, 2);
        $pos = array_keys($words);
        $text = substr($text, 0, $pos[$limit]) . '...';
    } elseif (strlen($text) > 16 * $limit) {
        $text = mb_strcut($text, 0, 16 * $limit) . '...';
    }
    return $text;
}
function kboard_share_footer()
{
    $uid = intval($_GET['uid']);
    $content = new KBContent();
    $content->initWithUID($uid);
    echo '<script>' . "\n";
    echo 'var snsTitle = "' . $content->title . '";' . "\n";
    echo 'var snsSummary = "' . addslashes(mb_strcut(strip_tags(str_replace(array("\r", "\n"), '', $content->content)), 0, 100, 'utf8')) . '";' . "\n";
    echo 'var snsUrl = location.href;' . "\n";
    echo 'var facebookImageUrl = "' . ($content->thumbnail_file ? get_site_url() . $content->thumbnail_file : '') . '";' . "\n";
    echo '</script>' . "\n";
}
Exemple #25
0
 public function log($str)
 {
     if ($this->debug) {
         if (php_sapi_name() != "cli") {
             //echo "<pre>";
         }
         echo strlen($str) > $this->debugStringLength ? mb_strcut($str, 0, $this->debugStringLength) . "..." : $str;
         //echo "\n";
         if (php_sapi_name() != "cli") {
             //echo "</pre>";
         }
     }
 }
Exemple #26
0
 /**
  * 网址列表
  */
 public static final function browse()
 {
     // 数据消毒
     $get = array('name' => isset($_GET['name']) ? $_GET['name'] : '', 'typeid' => isset($_GET['typeid']) ? $_GET['typeid'] : '', 'email' => isset($_GET['email']) ? $_GET['email'] : '', 'qq' => isset($_GET['qq']) ? $_GET['qq'] : '', 'msn' => isset($_GET['msn']) ? $_GET['msn'] : '', 'mobile' => isset($_GET['mobile']) ? $_GET['mobile'] : '', 'office_phone' => isset($_GET['office_phone']) ? $_GET['office_phone'] : '', 'home_phone' => isset($_GET['home_phone']) ? $_GET['home_phone'] : '', 'remarks' => isset($_GET['remarks']) ? $_GET['remarks'] : '', 'order' => isset($_GET['order']) ? $_GET['order'] : '', 'page' => isset($_GET['page']) ? $_GET['page'] : '', 'keyword' => isset($_GET['keyword']) ? $_GET['keyword'] : '', 'limit' => isset($_GET['limit']) ? $_GET['limit'] : '20');
     if (IN_WAP) {
         $get['limit'] = 10;
     }
     if (get_magic_quotes_gpc()) {
         $get = array_map('stripslashes', $get);
     }
     // 获取数据
     $where = array();
     $online = front::online();
     $where['user_id'] = $online->user_id;
     if (strlen($get['keyword']) > 0) {
         $where[] = array('name LIKE ?' => '%' . $get['keyword'] . '%', 'email LIKE ?' => '%' . $get['keyword'] . '%', 'qq LIKE ?' => '%' . $get['keyword'] . '%', 'msn LIKE ?' => '%' . $get['keyword'] . '%', 'mobile LIKE ?' => '%' . $get['keyword'] . '%', 'office_phone LIKE ?' => '%' . $get['keyword'] . '%', 'home_phone LIKE ?' => '%' . $get['keyword'] . '%', 'remarks LIKE ?' => '%' . $get['keyword'] . '%');
     }
     if ($get['typeid']) {
         $where['typeid'] = (int) $get['typeid'];
     }
     switch ($get['order']) {
         case 'address_id':
             $other = array('ORDER BY address_id');
             break;
         case 'name':
             $other = array('ORDER BY name');
             break;
         case 'name2':
             $other = array('ORDER BY name DESC');
             break;
         default:
             $other = array('ORDER BY address_id DESC');
             break;
     }
     $page = array('page' => $get['page'], 'size' => $get['limit']);
     $other['page'] =& $page;
     $addresss = self::selects(null, null, $where, $other, __CLASS__);
     foreach ($addresss as &$v) {
         foreach ($v as &$vv) {
             $vv = mb_strcut($vv, 0, 15, 'UTF-8');
         }
     }
     // 页面显示
     foreach (array('name') as $value) {
         $get[$value] = htmlspecialchars($get[$value]);
     }
     $query = $_SERVER['QUERY_STRING'];
     front::view2(__CLASS__ . '.list.tpl', compact('addresss', 'get', 'page', 'query'));
 }
Exemple #27
0
 /**
  * Summary:   解决去除标签时出现“?”的问题
  * @return unknown
  */
 public static function msubstr2($str, $start = 0, $length, $suffix = "...", $charset = "utf-8")
 {
     $str = str_replace(" ", "", $str);
     //过滤数据库中特殊空字符
     $str = trim(strip_tags(html_entity_decode($str, ENT_COMPAT, $charset)));
     $str = str_replace("\n", "", $str);
     $str = str_replace("\r\n", "", $str);
     $str = str_replace("\t", "", $str);
     $str = str_replace("\r", "", $str);
     $str = str_replace(" ", "", $str);
     $str = str_replace("&nbsp;", "", $str);
     $strlen = mb_strlen($str, $charset);
     $str = mb_strcut($str, $start, $length, $charset);
     return $length >= $strlen ? $str : $str . $suffix;
 }
Exemple #28
0
 /**
  * Create a new bounce event, update the email address if necessary
  *
  * @param $params
  *
  * @return bool|null
  */
 public static function &create(&$params)
 {
     $q =& CRM_Mailing_Event_BAO_Queue::verify($params['job_id'], $params['event_queue_id'], $params['hash']);
     $success = NULL;
     if (!$q) {
         return $success;
     }
     $transaction = new CRM_Core_Transaction();
     $bounce = new CRM_Mailing_Event_BAO_Bounce();
     $bounce->time_stamp = date('YmdHis');
     // if we dont have a valid bounce type, we should set it
     // to bounce_type_id 11 which is Syntax error. this allows such email
     // addresses to be bounce a few more time before being put on hold
     // CRM-4814
     // we changed this behavior since this bounce type might be due to some issue
     // with the connection or smtp server etc
     if (empty($params['bounce_type_id'])) {
         $params['bounce_type_id'] = 11;
         if (empty($params['bounce_reason'])) {
             $params['bounce_reason'] = ts('Unknown bounce type: Could not parse bounce email');
         }
     }
     // CRM-11989
     $params['bounce_reason'] = mb_strcut($params['bounce_reason'], 0, 254);
     $bounce->copyValues($params);
     $bounce->save();
     $success = TRUE;
     $bounceTable = CRM_Mailing_Event_BAO_Bounce::getTableName();
     $bounceType = CRM_Mailing_DAO_BounceType::getTableName();
     $emailTable = CRM_Core_BAO_Email::getTableName();
     $queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
     $bounce->reset();
     // might want to put distinct inside the count
     $query = "SELECT     count({$bounceTable}.id) as bounces,\n                            {$bounceType}.hold_threshold as threshold\n                FROM        {$bounceTable}\n                INNER JOIN  {$bounceType}\n                        ON  {$bounceTable}.bounce_type_id = {$bounceType}.id\n                INNER JOIN  {$queueTable}\n                        ON  {$bounceTable}.event_queue_id = {$queueTable}.id\n                INNER JOIN  {$emailTable}\n                        ON  {$queueTable}.email_id = {$emailTable}.id\n                WHERE       {$emailTable}.id = {$q->email_id}\n                    AND     ({$emailTable}.reset_date IS NULL\n                        OR  {$bounceTable}.time_stamp >= {$emailTable}.reset_date)\n                GROUP BY    {$bounceTable}.bounce_type_id\n                ORDER BY    threshold, bounces desc";
     $bounce->query($query);
     while ($bounce->fetch()) {
         if ($bounce->bounces >= $bounce->threshold) {
             $email = new CRM_Core_BAO_Email();
             $email->id = $q->email_id;
             $email->on_hold = TRUE;
             $email->hold_date = date('YmdHis');
             $email->save();
             break;
         }
     }
     $transaction->commit();
     return $success;
 }
function wrapString($str, $length = 20)
{
    // Wrap string to given character length (content rendered from ajax doesn't render correctly in ie)
    $len = mb_strlen($str);
    $out = '';
    $pos = 0;
    while ($len > $length && $pos !== false) {
        $pos = mb_strpos($str, ' ', $length);
        $line = mb_strcut($str, 0, $pos + 1);
        $str = mb_strcut($str, $pos + 1);
        $len = mb_strlen($str);
        $out .= $line . '<br>';
    }
    $out .= $str;
    return $out;
}
Exemple #30
-1
 function &substr($str, $start, $length, $trimmarker = '...')
 {
     if (!XOOPS_USE_MULTIBYTES) {
         return strlen($str) - $start <= $length ? substr($str, $start, $length) : substr($str, $start, $length - strlen($trimmarker)) . $trimmarker;
     }
     if (function_exists('mb_internal_encoding') && @mb_internal_encoding(_CHARSET)) {
         $str2 = mb_strcut($str, $start, $length - strlen($trimmarker));
         return $str2 . (mb_strlen($str) != mb_strlen($str2) ? $trimmarker : '');
     }
 }