當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。