public function get_item_url($params, $com) { static $items; $params = urldecode($params); parse_str($params); if (!isset($item) || $item <= 0) { return ''; } if (isset($items[$item])) { $ret = $items[$item]->permalink(); return $ret; } include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtsoftware.class.php'; $item = new DTSoftware($item); if ($item->isNew()) { return ''; } $items[$item->id()] = $item; return $item->permalink(); }
function dt_block_items($options) { global $db, $xoopsModule; include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtsoftware.class.php'; include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php'; $tpl = RMTemplate::get(); $tpl->add_xoops_style('blocks.css', 'dtransport'); $dtfunc = new DTFunctions(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbls = $db->prefix("dtrans_software"); $tblc = $db->prefix("dtrans_catsoft"); if ($options[1] > 0) { $sql = "SELECT s.* FROM {$tbls} as s, {$tblc} as c WHERE c.cat='" . $options[1] . "' AND s.id_soft=c.soft AND s.approved=1 AND s.`delete`=0"; } else { $sql = "SELECT s.* FROM {$tbls} as s WHERE s.`approved`=1 AND s.`delete`=0 "; } if (trim($options[10]) > 0) { $user = new RMUser(trim($options[10])); if ($user->isNew()) { return; } $sql .= " AND s.uid='" . $user->id() . "' "; } if ($options[11] > 0) { $sql .= "AND id_cat='{$options['11']}'"; } switch ($options[0]) { case 'all': $sql .= ' ORDER BY RAND() '; break; case 'recent': $sql .= " ORDER BY s.modified DESC, created DESC "; break; case 'popular': $sql .= " ORDER BY s.hits DESC "; break; case 'rated': $sql .= " ORDER BY s.`rating`/s.`votes` DESC "; break; case 'featured': $sql .= " AND featured=1 ORDER BY RAND() "; break; case 'daily': $sql = " AND daily=1 ORDER BY RAND() "; break; } $options[2] = $options[2] > 0 ? $options[2] : 5; $sql .= " LIMIT 0, {$options['2']}"; $result = $db->query($sql); $block = array(); while ($row = $db->fetchArray($result)) { $item = new DTSoftware(); $item->assignVars($row); $rtn = array(); $rtn['name'] = $item->getVar('name'); $rtn['version'] = $item->getVar('version'); if ($options[3]) { $img = new RMImage(); $img->load_from_params($item->getVar('image')); $rtn['image'] = $img->get_version($options[11]); } if ($options[4]) { $rtn['description'] = $item->getVar('shortdesc'); } if ($options[5]) { $rtn['hits'] = sprintf(__('Downloaded %s times.', 'dtransport'), '<strong>' . $item->getVar('hits') . '</strong>'); } if ($options[6]) { $rtn['urate'] = @number_format($item->getVar('rate') / $item->getVar('votes'), 1); } if ($options[7]) { $rtn['siterate'] = DTFunctions::ratingStars($item->getVar('siterate')); } $rtn['link'] = $item->permalink(); $rtn['metas'] = $dtfunc->get_metas('down', $item->id()); if ($options[9]) { $rtn['author'] = array('name' => $item->getVar('author_name'), 'url' => $item->getVar('author_url')); } $block['downs'][] = $rtn; } $block['showbutton'] = $options[8]; $block['downlang'] = __('Download', 'dtransport'); $block['lang_urate'] = __('User rating: %s', 'dtransport'); $block['lang_author'] = __('Author: %s', 'dtransport'); $block['langhits'] = _BK_DT_HITSTEXT; $block['langurate'] = _BK_DT_URATETEXT; $block['languser'] = _BK_DT_USERBY; return $block; }
$file = new DTFile($id); if ($file->isNew() && $mc['permalinks']) { $dtfunc->error_404(); } elseif ($file->isNew()) { redirect_header(DT_URL, 1, __('File not found!', 'dtransport')); } $item = new DTSoftware($file->software()); if ($item->isNew() || !$item->getVar('approved')) { if ($mc['permalinks']) { $dtfunc->error_404(); } else { redirect_header(DT_URL, 1, __('Software does not exists!', 'dtransport')); } } if (!$item->canDownload($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS)) { redirect_header($item->permalink(), 1, __('Sorry, you don\'t have permission to download this file!', 'dtransport')); } // Comprobamos los límites if ($item->getVar('limits') > 0) { if ($item->downloadsCount() >= $item->getVar('limits')) { redirect_header($item->permalink(), 1, __('You have reached your download limit for this file!', 'dtransport')); } } // Verificamos si la descarga se debe realizar $token = isset($_SESSION['dttoken']) ? $_SESSION['dttoken'] : ''; if ($token == '' || !$xoopsSecurity->validateToken($token)) { $_SESSION['dttoken'] = $xoopsSecurity->createToken(); $xoopsOption['template_main'] = 'dtrans_getfile.html'; $xoopsOption['module_subpage'] = 'getfile'; include 'header.php'; $img = new RMImage();
/** * Change secure status for items */ function dt_change_data($type, $value = 0) { global $xoopsSecurity; if (!$xoopsSecurity->check()) { dt_send_message(__('Session token not valid!', 'dtransport'), 1, 0); } $id = rmc_server_var($_POST, 'id', 0); if ($id <= 0) { dt_send_message(__('No item ID has been provided!', 'dtransport'), 1, 1); } $sw = new DTSoftware($id); if ($sw->isNew()) { dt_send_message(__('Provided item ID is not valid!', 'dtransport'), 1, 1); } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "UPDATE " . $db->prefix("dtrans_software") . " SET {$type}={$value} WHERE id_soft={$id}"; if (!$db->queryF($sql)) { dt_send_message(__('Data could not be changed!', 'dtransport') . '<br />' . $db->error(), 1, 1); } dt_send_message(array('message' => __('Data changed successfully!', 'dtransport'), 'value' => $value, 'name' => $sw->getVar('name'), 'id' => $sw->id(), 'link' => $sw->permalink()), 0, 1); }
/** * @desc Muestra todos lo elementos registrados **/ function dt_show_items() { define('RMCSUBLOCATION', 'downitems'); global $xoopsModule, $xoopsSecurity; $search = rmc_server_var($_REQUEST, 'search', ''); $sort = rmc_server_var($_REQUEST, 'sort', 'id_soft'); $mode = rmc_server_var($_REQUEST, 'mode', 1); $sort = $sort == '' ? 'id_soft' : $sort; $catid = rmc_server_var($_REQUEST, 'cat', 0); $type = rmc_server_var($_REQUEST, 'type', ''); //Barra de Navegación $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . ($type == 'edit' ? $db->prefix('dtrans_software_edited') : $db->prefix('dtrans_software')); $sql .= $catid ? " WHERE id_cat='{$catid}'" : ''; $sql .= $type == 'wait' ? $catid ? " AND approved=0" : " WHERE approved=0" : ""; $sql1 = ''; if ($search) { $words = explode(" ", $search); foreach ($words as $k) { //Verificamos si la palabra proporcionada es mayor a 2 caracteres if (strlen($k) <= 2) { continue; } $sql1 .= ($sql1 == '' ? $catid || $type == 'wait' ? " AND " : " WHERE " : " OR ") . " (name LIKE '%{$k}%' OR uname LIKE '%{$k}%') "; } } $sql2 = " ORDER BY {$sort} " . ($mode ? "DESC" : "ASC"); list($num) = $db->fetchRow($db->queryF($sql . $sql1 . $sql2)); $page = rmc_server_var($_REQUEST, 'page', 1); $limit = 15; $nav = new RMPageNav($num, $limit, $page); $nav->target_url("items.php?search={$search}&sort={$sort}&mode={$mode}&cat={$catid}&type={$type}&page={PAGE_NUM}"); $navpage = $nav->render(false, true); $start = $nav->start(); //Fin de barra de navegación $catego = new DTCategory($catid); $sql = "SELECT * FROM " . ($type == 'edit' ? $db->prefix('dtrans_software_edited') : $db->prefix('dtrans_software')); $sql .= $catid ? " WHERE id_cat={$catid}" : ''; $sql .= $type == 'wait' ? $catid ? " AND approved=0" : " WHERE approved=0" : ""; $sql2 .= " LIMIT {$start},{$limit}"; $result = $db->queryF($sql . $sql1 . $sql2); $items = array(); $timeFormat = new RMTimeFormatter(0, '%m%-%d%-%Y%'); while ($rows = $db->fetchArray($result)) { if ($type == 'edit') { $sw = new DTSoftwareEdited(); } else { $sw = new DTSoftware(); } $sw->assignVars($rows); $img = new RMImage($sw->getVar('image')); $user = new XoopsUser($sw->getVar('uid')); $items[] = array('id' => $type == 'edit' ? $sw->software() : $sw->id(), 'name' => $sw->getVar('name'), 'screens' => $sw->getVar('screens'), 'image' => $img->get_smallest(), 'secure' => $sw->getVar('secure'), 'approved' => $sw->getVar('approved'), 'uname' => $user->getVar('uname'), 'created' => $timeFormat->format($sw->getVar('created')), 'modified' => $timeFormat->format($sw->getVar('modified')), 'link' => $sw->permalink(), 'featured' => $sw->getVar('featured'), 'daily' => $sw->getVar('daily'), 'password' => $sw->getVar('password') != '', 'deletion' => $sw->getVar('delete')); } //Lista de categorías $categories = array(); DTFunctions::getCategos($categos, 0, 0, array(), true); foreach ($categos as $k) { $cat = $k['object']; $categories[] = array('id' => $cat->id(), 'name' => str_repeat('--', $k['jumps']) . ' ' . $cat->name()); } switch ($type) { case 'wait': $loc = __('Pending Downloads', 'dtransport'); break; case 'edit': $loc = __('Edited Downloads', 'dtransport'); break; default: $loc = __('Downloads Management', 'dtransport'); break; } DTFunctions::toolbar(); $tpl = RMTemplate::get(); $tpl->add_style('admin.css', 'dtransport'); $tpl->add_local_script('admin.js', 'dtransport'); $tpl->add_local_script('items.js', 'dtransport'); $tpl->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); include DT_PATH . '/include/js_strings.php'; xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . $loc); xoops_cp_header(); include RMTemplate::get()->get_template('admin/dtrans_items.php', 'module', 'dtransport'); xoops_cp_footer(); }
if ($tpages < $page && $tpages > 0) { header('location: ' . DT_URL . ($mc['permalinks'] ? '/cp/' : '/?p=cpanel')); die; } $p = $page > 0 ? $page - 1 : $page; $start = $num <= 0 ? 0 : $p * $limit; $nav = new RMPageNav($num, $limit, $page); $nav->target_url(DT_URL . ($mc['permalinks'] ? '/cp/page/{PAGE_NUM}/' : '/?p=cpanel&page={PAGE_NUM}')); $xoopsTpl->assign('pagenav', $nav->render(true)); $sql = str_replace("COUNT(*)", '*', $sql) . " LIMIT {$start}, {$limit}"; $result = $db->query($sql); $tf = new RMTimeFormatter('', "%M%-%d%-%Y%"); while ($row = $db->fetchArray($result)) { $item = new DTSoftware(); $item->assignVars($row); $xoopsTpl->append('items', array('id' => $item->id(), 'name' => $item->getVar('name'), 'links' => array('permalink' => $item->permalink(), 'edit' => $mc['permalinks'] ? DT_URL . '/submit/edit/' . $item->id() : '/?p=submit&action=edit&id=' . $item->id(), 'delete' => $mc['permalinks'] ? DT_URL . '/cp/delete/' . $item->id() : '/?p=cpanel&action=delete&id=' . $item->id(), 'files' => $mc['permalinks'] ? DT_URL . '/cp/files/' . $item->id() : '/?p=cpanel&action=files&id=' . $item->id(), 'features' => $mc['permalinks'] ? DT_URL . '/cp/features/' . $item->id() : '/?p=cpanel&action=features&id=' . $item->id(), 'logs' => $mc['permalinks'] ? DT_URL . '/cp/logs/' . $item->id() : '/?p=cpanel&action=logs&id=' . $item->id(), 'screens' => $mc['permalinks'] ? DT_URL . '/cp/screens/' . $item->id() : '/?p=cpanel&action=screens&id=' . $item->id(), 'canceldel' => $mc['permalinks'] ? DT_URL . '/cp/canceldel/' . $item->id() : '/?p=cpanel&action=canceldel&id=' . $item->id()), 'secure' => $item->getVar('secure'), 'approved' => $item->getVar('approved'), 'created' => array('time' => $item->getVar('created'), 'formated' => $tf->format($item->getVar('created'))), 'modified' => array('time' => $item->getVar('modified'), 'formated' => $tf->format($item->getVar('modified'))), 'hits' => $item->getVar('hits'), 'deletion' => $item->getVar('delete'))); } // Idioma $xoopsTpl->assign('lang_id', __('ID', 'dtransport')); $xoopsTpl->assign('lang_name', __('Name', 'dtransport')); $xoopsTpl->assign('lang_protected', __('Protected', 'dtransport')); $xoopsTpl->assign('lang_approved', __('Approved', 'dtransport')); $xoopsTpl->assign('lang_created', __('Created', 'dtransport')); $xoopsTpl->assign('lang_modified', __('Modified', 'dtransport')); $xoopsTpl->assign('lang_hits', __('Hits', 'dtransport')); $xoopsTpl->assign('lang_edit', __('Edit', 'dtransport')); $xoopsTpl->assign('lang_delete', __('Delete', 'dtransport')); $xoopsTpl->assign('lang_todelete', __('Waiting Deletion', 'dtransport')); $xoopsTpl->assign('lang_files', __('Files', 'dtransport')); $xoopsTpl->assign('lang_features', __('Features', 'dtransport')); $xoopsTpl->assign('lang_logs', __('Logs', 'dtransport'));
/** * @desc Genera un array con los datos de un elemento específico * @param object {@link DTSoftware()} * @return array */ public function createItemData(DTSoftware &$item) { global $mc, $xoopsUser; if (!$mc) { $mc = RMUtilities::module_config('dtransport'); } $rmfunc = RMFunctions::get(); $data = array(); $data['link'] = $item->permalink(); // Vinculo para detalles $data['dlink'] = $item->permalink(0, 'download'); // Vinculo de descarga $data['id'] = $item->id(); $data['name'] = $item->getVar('name'); $data['description'] = $item->getVar('shortdesc'); $data['votes'] = $item->getVar('votes'); $data['comments'] = $item->getVar('comments'); $data['siterate'] = DTFunctions::ratingStars($item->getVar('siterate')); $data['rating'] = @number_format($item->getVar('rating') / $item->getVar('votes'), 1); $data['language'] = $item->getVar('langs'); // Image $img = new RMImage(); $img->load_from_params($item->getVar('image')); $data['image'] = $img->get_smallest(); $data['created'] = formatTimestamp($item->getVar('created'), 's'); if ($item->getVar('created') < $item->getVar('modified')) { $data['modified'] = formatTimestamp($item->getVar('modified'), 's'); } $data['is_new'] = $item->getVar('created') > time() - $mc['new'] * 86400; $data['is_updated'] = $data['is_new'] ? false : $item->getVar('modified') > time() - $mc['update'] * 86400; $data['approved'] = $item->getVar('approved'); $data['downs'] = $item->getVar('hits'); $data['screens'] = $item->getVar('screens'); $data['featured'] = $item->getVar('featured'); $data['nameid'] = $item->getVar('nameid'); $data['candownload'] = $item->canDownload($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS); // Licencias $data['lics'] = ''; foreach ($item->licences(true) as $lic) { $data['lics'] .= $data['lics'] == '' ? '<a href="' . $lic->link() . '" target="_blank">' . $lic->name() . '</a>' : ', <a href="' . $lic->link() . '" target="_blank">' . $lic->name() . '</a>'; } // Plataformas $data['os'] = ''; foreach ($item->platforms(true) as $os) { $data['os'] .= $data['os'] == '' ? $os->name() : ', ' . $os->name(); } $data['metas'] = $this->get_metas('down', $item->id()); return $data; }
$canview = true; } else { $canview = $xoopsUser->isAdmin() || $xoopsUser->uid() == $item->getVar('uid'); } if ($item->isNew() || !$canview) { redirect_header(DT_URL, 2, __('Specified item does not exists!', 'dtransport')); die; } if ($item->getVar('delete')) { redirect_header(DT_URL, 2, __('This item is not available for download at this moment!', 'dtransport')); } // Download default file if ($action == 'download') { $file = $item->file(); if (!$file) { redirect_header($item->permalink(), 0, __('Internal Error! Please try again later', 'dtransport')); } header("location: " . $file->permalink()); die; } $xoopsOption['template_main'] = 'dtrans_item.html'; $xoopsOption['module_subpage'] = 'item'; include 'header.php'; $xoopsTpl->assign('dtrans_option', 'details'); $dtfunc->makeHeader(); $candownload = $item->canDownload($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS); // Enlaces del elemento $data = array(); $data['link'] = $item->permalink(); $data['screens'] = $item->permalink(0, 'screens'); $data['download'] = $candownload ? $item->permalink(0, 'download') : '';