plugins/mydownloads.php
<?php declare(strict_types=1);
/**
* ****************************************************************************
* marquee - MODULE FOR XOOPS
* Copyright (c) Hervé Thouzard (https://www.herve-thouzard.com)
*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright Hervé Thouzard (https://www.herve-thouzard.com)
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Hervé Thouzard (https://www.herve-thouzard.com)
* ****************************************************************************
*
* @param $limit
* @param $dateFormat
* @param $itemsSize
*
* @return array
*/
// Script to list the recent links from the mydownloads module version 1.10
function b_marquee_mydownloads($limit, $dateFormat, $itemsSize)
{
// require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php';
require XOOPS_ROOT_PATH . '/include/comment_constants.php';
$block = [];
$myts = \MyTextSanitizer::getInstance();
$db = \XoopsDatabaseFactory::getDatabaseConnection();
$sql = 'SELECT m.lid, m.cid, m.title, m.date, m.hits, m.submitter, c.title AS catitle, u.name, u.uname FROM '
. $db->prefix('mydownloads_downloads')
. ' m, '
. $db->prefix('mydownloads_cat')
. ' c, '
. $db->prefix('users')
. ' u WHERE (c.cid=m.cid) AND (m.submitter=u.uid) AND (m.status>0) ORDER BY m.date DESC';
$result = $db->query($sql, $limit, 0);
if (!$db->isResultSet($result)) {
throw new \RuntimeException(
\sprintf(_DB_QUERY_ERROR, $sql) . $db->error(), E_USER_ERROR);
}
while (false !== ($myrow = $db->fetchArray($result))) {
$title = htmlspecialchars($myrow['title'], ENT_QUOTES | ENT_HTML5);
if ($itemsSize > 0) {
$title = xoops_substr($title, 0, $itemsSize + 3);
}
$author = htmlspecialchars($myrow['uname'], ENT_QUOTES | ENT_HTML5);
if ('' !== xoops_trim($myrow['catitle'])) {
$author = htmlspecialchars($myrow['name'], ENT_QUOTES | ENT_HTML5);
}
$category = htmlspecialchars($myrow['catitle'], ENT_QUOTES | ENT_HTML5);
$block[] = [
'date' => formatTimestamp($myrow['date'], $dateFormat),
'category' => $category,
'author' => $author,
'title' => $title,
'link' => "<a href='" . XOOPS_URL . '/modules/mydownloads/singlefile.php?cid=' . $myrow['cid'] . '&lid=' . $myrow['lid'] . "'>" . $title . '</a>',
];
}
return $block;
}