} $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';
/** * @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; }