Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 function onParseMeta($page)
 {
     if (substru($page->get("template"), 0, 4) == "wiki" && $this->yellow->config->get("wikiWithSidebar")) {
         if (!$page->isExisting("sidebar")) {
             $page->set("sidebar", "sidebar");
         }
     }
 }
Esempio n. 3
0
 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");
             }
         }
     }
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 function checkStaticFilesystem()
 {
     return strtoupperu(substru(PHP_OS, 0, 3)) != "WIN";
 }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
 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");
     }
 }
<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());
Esempio n. 10
0
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']) . "&#8230;";
        // 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']) {
Esempio n. 11
0
 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);
 }
Esempio n. 12
0
					<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) . "&#8230;";
        // 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
Esempio n. 13
0
 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);
 }
Esempio n. 14
0
					<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']) . "&#8230;";
    // 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']) {
Esempio n. 15
0
 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";
                 }
             }
         }
     }
 }
Esempio n. 16
0
 function getSystemLocations()
 {
     $locations = array();
     $regex = "/\\.(css|ico|js|jpg|png|svg|txt|woff)/";
     $fileNames = $this->yellow->toolbox->getDirectoryEntries($this->yellow->config->get("pluginDir"), $regex, false, false);
     foreach ($fileNames as $fileName) {
         array_push($locations, $this->yellow->config->get("pluginLocation") . basename($fileName));
     }
     $fileNames = $this->yellow->toolbox->getDirectoryEntries($this->yellow->config->get("themeDir"), $regex, false, false);
     foreach ($fileNames as $fileName) {
         array_push($locations, $this->yellow->config->get("themeLocation") . basename($fileName));
     }
     $assetDirLength = strlenu($this->yellow->config->get("assetDir"));
     $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->config->get("assetDir"), $regex, false, false);
     foreach ($fileNames as $fileName) {
         array_push($locations, $this->yellow->config->get("assetLocation") . substru($fileName, $assetDirLength));
     }
     array_push($locations, "/" . $this->yellow->config->get("robotsFile"));
     return $locations;
 }
Esempio n. 17
0
 function checkRequest($location)
 {
     if ($this->yellow->toolbox->getServerScheme() == $this->yellow->config->get("webinterfaceServerScheme") && $this->yellow->toolbox->getServerName() == $this->yellow->config->get("webinterfaceServerName")) {
         $locationLength = strlenu($this->yellow->config->get("webinterfaceLocation"));
         $this->active = substru($location, 0, $locationLength) == $this->yellow->config->get("webinterfaceLocation");
     }
     return $this->isActive();
 }
Esempio n. 18
0
function breakLongWords($str, $maxLength, $char)
{
    $wordEndChars = array(' ', "\n", "\r", "\t");
    $count = 0;
    $newStr = '';
    $tmp = substru($str, 0, 1);
    $i = 0;
    while (isset($tmp[0])) {
        $newStr .= $tmp;
        if (!in_array($tmp, $wordEndChars)) {
            $count++;
            if ($count == $maxLength) {
                $newStr .= $char;
                $count = 0;
            }
        } else {
            $count = 0;
        }
        $i++;
        $tmp = substru($str, $i, 1);
    }
    return $newStr;
}
 function onUserPermission($location, $fileName, $users)
 {
     return substru($location, 0, strlenu($users->getHome())) == $users->getHome();
 }
Esempio n. 20
0
 function isContentFile($fileName)
 {
     $contentDirLength = strlenu($this->yellow->config->get("contentDir"));
     return substru($fileName, 0, $contentDirLength) == $this->yellow->config->get("contentDir");
 }
Esempio n. 21
0
 function getUserPermission($location, $fileName)
 {
     $userPermission = NULL;
     foreach ($this->yellow->plugins->plugins as $key => $value) {
         if (method_exists($value["obj"], "onUserPermission")) {
             $userPermission = $value["obj"]->onUserPermission($location, $fileName, $this->users);
             if (!is_null($userPermission)) {
                 break;
             }
         }
     }
     if (is_null($userPermission)) {
         $userPermission = is_dir(dirname($fileName)) && strlenu(basename($fileName)) < 128;
         $userPermission &= substru($location, 0, strlenu($this->users->getHome())) == $this->users->getHome();
     }
     return $userPermission;
 }
Esempio n. 22
0
 function isLoginRestrictions()
 {
     return substru($this->yellow->config->get("email"), 0, 7) == "noreply";
 }