本文整理汇总了PHP中substru函数的典型用法代码示例。如果您正苦于以下问题:PHP substru函数的具体用法?PHP substru怎么用?PHP substru使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了substru函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emojifyHTML
function emojifyHTML($text)
{
$elementsOpen = array();
$elementsDepth = 0;
while (true) {
$elementFound = preg_match("/<\\s*?([\\/!]?\\w*)(.*?)\\s*?\\>/s", $text, $matches, PREG_OFFSET_CAPTURE, $offsetBytes);
$element = $matches[0][0];
$elementName = $matches[1][0];
$elementText = $matches[2][0];
$elementOffsetBytes = $elementFound ? $matches[0][1] : strlenb($text);
$string = substrb($text, $offsetBytes, $elementOffsetBytes - $offsetBytes);
if ($elementsDepth == 0) {
$string = $this->emojifyText($string);
}
$output .= $string;
if (!$elementFound) {
break;
}
if (!empty($elementName) && substru($elementText, -1) != '/' && !preg_match("/^(area|br|col|hr|img|input|col|param|!)/i", $elementName)) {
if ($elementName[0] != '/') {
$elementsDepth += $this->isFixedElement($elementName);
array_push($elementsOpen, $elementName);
} else {
$elementsDepth -= $this->isFixedElement($elementsOpen[count($elementsOpen) - 1]);
array_pop($elementsOpen);
}
}
$output .= $element;
$offsetBytes = $elementOffsetBytes + strlenb($element);
}
return $output;
}
示例2: onParseMeta
function onParseMeta($page)
{
if (substru($page->get("template"), 0, 4) == "wiki" && $this->yellow->config->get("wikiWithSidebar")) {
if (!$page->isExisting("sidebar")) {
$page->set("sidebar", "sidebar");
}
}
}
示例3: onParseMeta
function onParseMeta($page)
{
if (!$page->isError()) {
$location = $this->yellow->config->get("blogLocation");
if (!empty($location) && substru($page->location, 0, strlenu($location)) == $location) {
if ($page->get("template") == $this->yellow->config->get("template")) {
$page->set("template", "blog");
}
}
}
}
示例4: onParseContentBlock
function onParseContentBlock($page, $name, $text, $shortcut)
{
$output = null;
if ($name == "gallery" && $shortcut) {
list($pattern, $style, $size) = $this->yellow->toolbox->getTextArgs($text);
if (empty($style)) {
$style = $this->yellow->config->get("galleryStyle");
}
if (empty($size)) {
$size = "100%";
}
if (empty($pattern)) {
$files = $page->getFiles(true);
} else {
$images = $this->yellow->config->get("imageDir");
$files = $this->yellow->files->index(true, true)->match("#{$images}{$pattern}#");
}
if ($this->yellow->plugins->isExisting("image")) {
if (count($files)) {
$page->setLastModified($files->getModified());
$output = "<div class=\"" . htmlspecialchars($style) . "\" data-fullscreenel=\"false\" data-shareel=\"false\"";
if (substru($size, -1, 1) != "%") {
$output .= " data-thumbsquare=\"true\"";
}
$output .= ">\n";
foreach ($files as $file) {
list($widthInput, $heightInput) = $this->yellow->toolbox->detectImageInfo($file->fileName);
list($src, $width, $height) = $this->yellow->plugins->get("image")->getImageInfo($file->fileName, $size, $size);
$output .= "<a href=\"" . $file->getLocation(true) . "\" data-size=\"{$widthInput}x{$heightInput}\">";
$output .= "<img src=\"" . htmlspecialchars($src) . "\" width=\"" . htmlspecialchars($width) . "\" height=\"" . htmlspecialchars($height) . "\" alt=\"" . basename($file->getLocation(true)) . "\" title=\"" . basename($file->getLocation(true)) . "\" />";
$output .= "</a> \n";
}
$output .= "</div>";
} else {
$page->error(500, "Gallery '{$pattern}' does not exist!");
}
} else {
$page->error(500, "Gallery requires 'image' plugin!");
}
}
return $output;
}
示例5: getHighlightInfo
function getHighlightInfo($name)
{
$class = $this->yellow->config->get("highlightClass");
foreach (explode(' ', $name) as $token) {
if (empty($language) && preg_match("/^[\\w\\:]+\$/", $token)) {
list($language, $lineNumber) = explode(':', $token);
if (is_null($lineNumber)) {
$lineNumber = $this->yellow->config->get("highlightLineNumber");
}
continue;
}
if ($token[0] == '.') {
$class = $class . " " . substru($token, 1);
}
if ($token[0] == '#') {
$id = substru($token, 1);
}
}
return array($language, $lineNumber, $class, $id);
}
示例6: checkStaticFilesystem
function checkStaticFilesystem()
{
return strtoupperu(substru(PHP_OS, 0, 3)) != "WIN";
}
示例7: getFileLinePrevious
function getFileLinePrevious($fileHandle, &$filePos, &$fileTop, &$dataBuffer)
{
if ($filePos >= 0) {
$line = "";
$lineEndingSearch = false;
$endPos = $this->getFileLineBuffer($fileHandle, $filePos, $fileTop, $dataBuffer);
for (; $filePos >= 0; --$filePos) {
$currentPos = $filePos - $fileTop;
if ($dataBuffer[$currentPos] == "\n" && $lineEndingSearch) {
$line = substru($dataBuffer, $currentPos + 1, $endPos - $currentPos) . $line;
break;
}
if ($currentPos == 0) {
$line = substru($dataBuffer, $currentPos, $endPos - $currentPos + 1) . $line;
$endPos = $this->getFileLineBuffer($fileHandle, $filePos - 1, $fileTop, $dataBuffer);
}
$lineEndingSearch = true;
}
} else {
$line = false;
}
return $line;
}
示例8: getCommentFileName
function getCommentFileName($page)
{
if ($this->yellow->config->get("commentsDir") == "") {
$file = $page->fileName;
$extension = $this->yellow->config->get("contentExtension");
if (substru($file, strlenu($file) - strlenu($extension)) == $extension) {
$file = substru($file, 0, strlenu($file) - strlenu($extension));
}
$file .= $this->yellow->config->get("commentsExtension") . $extension;
return $file;
} else {
return $this->yellow->config->get("commentsDir") . $page->get("pageFile");
}
}
示例9: foreach
<div class="content">
<?php
$yellow->snippet("sidebar");
?>
<div class="main">
<h1><?php
echo $yellow->page->getHtml("title");
?>
</h1>
<ul>
<?php
foreach ($yellow->page->getPages() as $page) {
$sectionNew = htmlspecialchars(strtoupperu(substru($page->get("title"), 0, 1)));
if ($section != $sectionNew) {
$section = $sectionNew;
echo "</ul><h2>{$section}</h2><ul>\n";
}
?>
<li><a href="<?php
echo $page->getLocation(true);
?>
"><?php
echo $page->getHtml("title");
?>
</a></li>
<?php
}
?>
</ul>
<?php
$yellow->snippet("pagination", $yellow->page->getPages());
示例10: lang
echo lang('actions');
?>
</td>
<td colspan="2" class="item key"><?php
echo lang('category');
?>
</td>
</tr>
<?php
if (is_array($topics)) {
foreach ($topics as $row) {
// reset
$status = "";
$list = "";
// Trim subject
$subject = substru(trim(htmlspecialchars($row['subject'], ENT_QUOTES, 'UTF-8')), 0, $config['max_length']) . "…";
// Build topic url
$topic_url = "{$config['url_path']}/read.php?id={$row['id']}";
// Topic starter data
$topic_author = user_data($row['starter_id']);
// Topic status
if ($row['closed']) {
$status = 'closed, ';
}
if ($row['sticky']) {
$status .= 'sticky';
}
$categories = category();
// Create the delete list
foreach ($categories as $acat) {
if ($acat['id'] == $row['category']) {
示例11: detectImageInfo
function detectImageInfo($fileName)
{
$width = $height = 0;
$type = "";
$fileHandle = @fopen($fileName, "rb");
if ($fileHandle) {
if (substru(strtoloweru($fileName), -3) == "png") {
$dataSignature = fread($fileHandle, 8);
$dataHeader = fread($fileHandle, 16);
if (!feof($fileHandle) && $dataSignature == "‰PNG\r\n\n") {
$width = (ord($dataHeader[10]) << 8) + ord($dataHeader[11]);
$height = (ord($dataHeader[14]) << 8) + ord($dataHeader[15]);
$type = "png";
}
} else {
if (substru(strtoloweru($fileName), -3) == "jpg") {
$dataBufferSizeMax = filesize($fileName);
$dataBufferSize = min($dataBufferSizeMax, 4096);
$dataBuffer = fread($fileHandle, $dataBufferSize);
$dataSignature = substrb($dataBuffer, 0, 4);
if (!feof($fileHandle) && ($dataSignature == "ÿØÿà" || $dataSignature == "ÿØÿá")) {
for ($pos = 2; $pos + 8 < $dataBufferSize; $pos += $length) {
if ($dataBuffer[$pos] != "ÿ") {
break;
}
if ($dataBuffer[$pos + 1] == "À" || $dataBuffer[$pos + 1] == "Â") {
$width = (ord($dataBuffer[$pos + 7]) << 8) + ord($dataBuffer[$pos + 8]);
$height = (ord($dataBuffer[$pos + 5]) << 8) + ord($dataBuffer[$pos + 6]);
$type = "jpg";
break;
}
$length = (ord($dataBuffer[$pos + 2]) << 8) + ord($dataBuffer[$pos + 3]) + 2;
while ($pos + $length + 8 >= $dataBufferSize) {
if ($dataBufferSize == $dataBufferSizeMax) {
break;
}
$dataBufferDiff = min($dataBufferSizeMax, $dataBufferSize * 2) - $dataBufferSize;
$dataBufferSize += $dataBufferDiff;
$dataBuffer .= fread($fileHandle, $dataBufferDiff);
if (feof($fileHandle)) {
$dataBufferSize = 0;
break;
}
}
}
}
}
}
fclose($fileHandle);
}
return array($width, $height, $type);
}
示例12: lang
<td align="center" class="item key"><?php
echo lang('starter_c');
?>
</td>
<td colspan="2" class="item key"><?php
echo lang('actions');
?>
</td>
</tr>
<?php
if (is_array($posts)) {
foreach ($posts as $row) {
// reset
$status = "";
// Trim subject
$content = substru(trim(stripslashes($row['message'])), 0, 25) . "…";
// How many replies?
$replies = intval(get_replies($row['reply']));
// Lets update it
$replies = $replies + 1;
// Woooo~ Last id for redirecting~
$page_numbers = $replies / 20 - 1;
$n = ceil($page_numbers);
if ($n == -1) {
$n = 0;
} else {
$n = abs($n);
}
// Build topic url
$post_url = "{$config['url_path']}/read.php?id={$row['reply']}&page={$n}";
// Topic starter data
示例13: getImageInfo
function getImageInfo($fileName, $widthOutput, $heightOutput)
{
$fileNameShort = substru($fileName, strlenu($this->yellow->config->get("imageDir")));
list($widthInput, $heightInput, $type) = $this->yellow->toolbox->detectImageInfo($fileName);
$widthOutput = $this->convertValueAndUnit($widthOutput, $widthInput);
$heightOutput = $this->convertValueAndUnit($heightOutput, $heightInput);
if ($widthInput == $widthOutput && $heightInput == $heightOutput || $type == "svg") {
$src = $this->yellow->config->get("serverBase") . $this->yellow->config->get("imageLocation") . $fileNameShort;
$width = $widthOutput;
$height = $heightOutput;
} else {
$fileNameThumb = ltrim(str_replace(array("/", "\\", "."), "-", dirname($fileNameShort) . "/" . pathinfo($fileName, PATHINFO_FILENAME)), "-");
$fileNameThumb .= "-" . $widthOutput . "x" . $heightOutput;
$fileNameThumb .= "." . pathinfo($fileName, PATHINFO_EXTENSION);
$fileNameOutput = $this->yellow->config->get("imageThumbnailDir") . $fileNameThumb;
if ($this->isFileNotUpdated($fileName, $fileNameOutput)) {
$image = $this->loadImage($fileName, $type);
$image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
if (!$this->saveImage($image, $fileNameOutput, $type) || !$this->yellow->toolbox->modifyFile($fileNameOutput, $this->yellow->toolbox->getFileModified($fileName))) {
$this->yellow->page->error(500, "Image '{$fileNameOutput}' can't be saved!");
}
}
$src = $this->yellow->config->get("serverBase") . $this->yellow->config->get("imageThumbnailLocation") . $fileNameThumb;
list($width, $height) = $this->yellow->toolbox->detectImageInfo($fileNameOutput);
}
return array($src, $width, $height);
}
示例14: lang
<td colspan="2" class="item key"><?php
echo lang('actions');
?>
</td>
<td colspan="2" class="item key"><?php
echo lang('category');
?>
</td>
</tr>
<?php
foreach ($topics as $row) {
// reset
$status = "";
$list = "";
// Trim subject
$subject = substru(trim(stripslashes($row['subject'])), 0, $config['max_length']) . "…";
// Build topic url
$topic_url = "{$config['url_path']}/read.php?id={$row['id']}";
// Topic starter data
$topic_author = user_data($row['starter_id']);
// Topic status
if ($row['closed']) {
$status = 'closed, ';
}
if ($row['sticky']) {
$status .= 'sticky';
}
$categories = category();
// Create the delete list
foreach ($categories as $acat) {
if ($acat['id'] == $row['category']) {
示例15: analyseStaticPage
function analyseStaticPage($text)
{
$serverName = $this->yellow->config->get("serverName");
$serverBase = $this->yellow->config->get("serverBase");
$pagination = $this->yellow->config->get("contentPagination");
preg_match_all("/<a(.*?)href=\"([^\"]+)\"(.*?)>/i", $text, $matches);
foreach ($matches[2] as $match) {
if (preg_match("/^\\w+:\\/+(.*?)(\\/.*)\$/", $match, $tokens)) {
if ($tokens[1] != $serverName) {
continue;
}
$match = $tokens[2];
}
if (!$this->yellow->toolbox->isLocationArgs($match)) {
continue;
}
if (substru($match, 0, strlenu($serverBase)) != $serverBase) {
continue;
}
$location = rawurldecode(substru($match, strlenu($serverBase)));
if (!$this->yellow->toolbox->isLocationArgsPagination($location, $pagination)) {
$location = rtrim($location, '/') . '/';
if (is_null($this->locationsArgs[$location])) {
$this->locationsArgs[$location] = $location;
if (defined("DEBUG") && DEBUG >= 2) {
echo "YellowCommandline::analyseStaticPage detected location:{$location}\n";
}
}
} else {
$location = rtrim($location, "0..9");
if (is_null($this->locationsArgsPagination[$location])) {
$this->locationsArgsPagination[$location] = $location;
if (defined("DEBUG") && DEBUG >= 2) {
echo "YellowCommandline::analyseStaticPage detected location:{$location}\n";
}
}
}
}
}