当前位置: 首页>>代码示例>>PHP>>正文


PHP Strings::stringLimit方法代码示例

本文整理汇总了PHP中Strings::stringLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP Strings::stringLimit方法的具体用法?PHP Strings::stringLimit怎么用?PHP Strings::stringLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Strings的用法示例。


在下文中一共展示了Strings::stringLimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mysql_fetch_assoc

if ($act == 'Load Text') {
    $r = mysql_fetch_assoc(mysql_query("SELECT ui.fulltext FROM usuarios_info AS ui \n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN usuarios AS u ON u.id = ui.user_id \n\t\t\t\t\t\t\t\t\t\t\tWHERE ui.user_id = '{$id}' AND u.nivel > '" . $_SESSION['usernivel'] . "' LIMIT 1"));
    $rcontent = $r['fulltext'];
    $result['content'] = $rcontent;
    $result['return'] = $rcontent ? true : '<span class="required">Conteúdo não encontrado ou ainda não cadastrado.</span>';
    echo json_encode($result);
}
//-----------------------------------------------------------------------------------------------------------------------
//	SALVA O TEXTO
//-----------------------------------------------------------------------------------------------------------------------
if ($act == 'Save Text') {
    $user = mysql_fetch_assoc(mysql_query("SELECT nivel FROM usuarios WHERE id = '{$id}' LIMIT 1"));
    if (@$user['nivel'] > $_SESSION['usernivel']) {
        $content = trim(addslashes($_POST['content']));
        // intro === 0 -> limpa o campo introtext  |  $intro >= 10 -> quebra o fulltext  |  senão não faz nada
        $introtext = is_numeric($intro) ? Strings::stringLimit(strip_tags($content), $intro, '') : 'false';
        $cVer = mysql_query("SELECT * FROM usuarios_info WHERE user_id = '{$id}' LIMIT 1");
        if (mysql_num_rows($cVer) > 0) {
            $save = mysql_query("UPDATE `usuarios_info` SET " . ($introtext != 'false' ? "`introtext` = '{$introtext}', " : '') . " `fulltext` = '{$content}' WHERE `user_id` = '{$id}' LIMIT 1 ");
        } else {
            $save = mysql_query("INSERT INTO `usuarios_info` (`user_id`, " . ($introtext != 'false' ? "`introtext`, " : '') . " `fulltext`) VALUES ('{$id}', '{$content}') ");
        }
    }
    echo @$save ? '<span class="success">Conteúdo atualizado em [ ' . date('d.m.y - H:i:s') . ' ]</span>' : '<span class="error">Houve um erro ao salvar. Tente novamente.</span>';
}
//---------------------------------------------------------------------------------------------------------
// CARREGA O TEXTO  DE INTRODUÇÃO
//---------------------------------------------------------------------------------------------------------
if ($act == 'Load Intro Text') {
    $r = mysql_fetch_assoc(mysql_query("SELECT ui.introtext FROM usuarios_info AS ui \n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN usuarios AS u ON u.id = ui.user_id \n\t\t\t\t\t\t\t\t\t\t\tWHERE ui.user_id = '{$id}' AND u.nivel > '" . $_SESSION['usernivel'] . "' LIMIT 1"));
    $rcontent = $r['introtext'];
开发者ID:elderxavier,项目名称:SII9-CREATIVE-STUDIO,代码行数:31,代码来源:Usuarios.php

示例2: mysql_fetch_assoc

if ($act == 'Load Text') {
    $field = @$field == 'introtext' ? 'introtext' : 'fulltext';
    $content = mysql_fetch_assoc(mysql_query("SELECT `{$field}` FROM `content` WHERE `id` = '{$id}' LIMIT 1"));
    $rcontent = $content[$field];
    $result['content'] = $rcontent;
    $result['return'] = $rcontent ? true : '<span class="required">Conteúdo não encontrado ou ainda não cadastrado.</span>';
    echo json_encode($result);
}
//-----------------------------------------------------------------------------------------------------------------------
//	SALVA O TEXTO
//-----------------------------------------------------------------------------------------------------------------------
if ($act == 'Save Text') {
    $content = trim(addslashes(@$_POST['content']));
    $field = @$field == 'introtext' ? 'introtext' : 'fulltext';
    // intro === 0 -> limpa o campo introtext  |  $intro > 0 -> quebra o fulltext  |  se for string não faz nada
    $textBreaked = is_numeric(@$intro) && $field != 'introtext' ? Strings::stringLimit(strip_tags($content), $intro, '') : 'false';
    $save = mysql_query("UPDATE `content` SET " . ($textBreaked != 'false' ? "`introtext` = '{$textBreaked}', " : '') . " `{$field}` = '{$content}' \n\t\t\t\t\t\t\t\t\t WHERE `id` = '{$id}' LIMIT 1 ");
    if (@$save) {
        die(true);
    } else {
        die('<span class="error">Houve um erro ao salvar os dados.</span>');
    }
}
//-----------------------------------------------------------------------------------------------------------------------
//	CARREGA A IMAGEM DE INTRODUÇÃO
//-----------------------------------------------------------------------------------------------------------------------
if ($act == 'Load Image Intro') {
    $item = mysql_fetch_assoc(mysql_query("SELECT imagem, img_in_article FROM content WHERE id = '{$id}' LIMIT 1"));
    $thumburl = 'images/content/thumbs/' . $item['imagem'];
    $thumb = is_file('../../../' . $thumburl) ? $path . '/' . $thumburl : '';
    $result['thumb'] = $thumb;
开发者ID:elderxavier,项目名称:SII9-CREATIVE-STUDIO,代码行数:31,代码来源:Content.php


注:本文中的Strings::stringLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。