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; }
// Si no se aprueba almacenaremos los datos en // la tabla para elementos editados $item = new DTSoftwareEdited($id); $item->setSoftware($id); } if ($item->getVar('uid') != $xoopsUser->uid()) { redirect_header(DT_URL, 1, __('You can not edit this download item!', 'dtransport')); } } else { $item = new DTSoftware(); } $db = XoopsDatabaseFactory::getDatabaseConnection(); // Check if exists another download with same name $sql = "SELECT COUNT(*) FROM " . $db->prefix("dtrans_software") . " WHERE name='{$name}'"; if ($edit) { $sql .= " AND id_soft!=" . $item->id(); } list($num) = $db->fetchRow($db->query($sql)); if ($num > 0) { redirect_header(DT_URL . ($mc['permalinks'] ? '/submit/' . ($edit ? 'edit/' . $item->id() . '/' : '') : '/p=submit' . ($edit ? '?action=edit&id=' . $id : '')), 1, __('Another item with same name already exists!', 'dtransport')); } //Genera $nameid Nombre identificador $found = false; $i = 0; $tc = TextCleaner::getInstance(); // Manejo de texto if ($name != $item->getVar('name')) { do { $nameid = $tc->sweetstring($name) . ($found ? $i : ''); $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_software') . " WHERE nameid = '{$nameid}'" . ($edit ? ' AND id_soft!=' . $id : ''); list($num) = $db->fetchRow($db->queryF($sql));
$tpl->add_local_script('main.js', 'dtransport'); $tpl->add_head_script('var down_message = "' . sprintf(__('Your %s download will start in {x} seconds...', 'dtransport'), '<a href=\'' . $item->permalink() . '\'>' . $item->getVar('name') . '</a>') . '";'); $tpl->add_head_script('var timeCounter = ' . $mc['pause'] . ";\nvar dlink = '" . $file->permalink() . "';"); $dtfunc->makeHeader(); include 'footer.php'; die; } // Comprobamos si el archivo es seguro o no if (!$item->getVar('secure')) { // Comprobamos si es un archivo remoto o uno local if ($file->remote()) { // Almacenamos las estadísticas $st = new DTStatistics(); $st->setDate(time()); $st->setFile($file->id()); $st->setSoftware($item->id()); $st->setUid($xoopsUser ? $xoopsUser->uid() : 0); $st->setIp($_SERVER['REMOTE_ADDR']); $st->save(); $item->addHit(); $file->addHit(); unset($_SESSION['dttoken']); header('location: ' . $file->file()); die; } else { $dir = str_replace(XOOPS_ROOT_PATH, XOOPS_URL, $mc['directory_insecure']); $dir = str_replace("\\", "/", $dir); $dir = rtrim($dir, '/'); $path = $mc['directory_insecure']; $path = str_replace("\\", "/", $path); $path = rtrim($path, '/');
// MA 02111-1307 USA // -------------------------------------------------------------- // @copyright: 2007 - 2008 Red México define('DT_LOCATION', 'rate'); include '../../mainfile.php'; $id = isset($_POST['id']) ? $_POST['id'] : 0; $rate = isset($_POST['rate']) ? $_POST['rate'] : 0; $ret = isset($_POST['ret']) ? $_POST['ret'] : ''; $mc =& $xoopsModuleConfig; //Verificamos si el software existe $item = new DTSoftware($id); if ($item->isNew()) { redirect_header(XOOPS_URL . "modules/dtransport/", 2, _MS_DT_ERRIDEXIST); die; } $retlink = $ret != '' ? XOOPS_URL . '/modules/dtransport/' . ($mc['urlmode'] ? 'item/' . $item->nameid() . '/' : 'item.php?id=' . $item->id()) : $ret; if ($rate <= 0 || $rate > 10) { redirect_header($retlink, 2, _MS_DT_NORATE); die; } $db->queryF("DELETE FROM " . $db->prefix("dtrans_votedata") . " WHERE date<'" . (time() - 86400) . "'"); $ip = $_SERVER['REMOTE_ADDR']; $sql = "SELECT COUNT(*) FROM " . $db->prefix("dtrans_votedata") . " WHERE "; if ($xoopsUser) { $sql .= "uid='" . $xoopsUser->uid() . "' AND date>'" . (time() - 86400) . "' AND id_soft='" . $item->id() . "'"; } else { $sql .= "ip='{$ip}' AND date>'" . (time() - 86400) . "' AND id_soft='" . $item->id() . "'"; } list($num) = $db->fetchRow($db->query($sql)); if ($num > 0) { redirect_header($retlink, 2, _MS_DT_NODAY);
/** * 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(); }
/** * @desc Formulario de archivos **/ function formFiles($edit = 0) { global $tpl, $xoopsModule, $xoopsModuleConfig, $xoopsUser, $xoopsSecurity; define("RMCSUBLOCATION", 'newfile'); $id = rmc_server_var($_GET, 'id', 0); $item = rmc_server_var($_GET, 'item', 0); //Verificamos si el software es válido if ($item <= 0) { redirectMsg('files.php', __('No download item ID has been provided!', 'dtransport'), RMMSG_WARN); } //Verificamos si existe el software $sw = new DTSoftware($item); if ($sw->isNew()) { redirectMsg('files.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_ERROR); } $file_exists = true; if ($edit) { //Verificamos si archivo es válido if ($id <= 0) { redirectMsg('./files.php?item=' . $item, __('No file ID has been specified!', 'dtransport'), RMMSG_WARN); } //Verificamos si existe archivo $fl = new DTFile($id); if ($fl->isNew()) { redirectMsg('files.php?item=' . $item, __('Specified file does not exists!', 'dtransport'), RMMSG_ERROR); } if ($sw->getVar('secure')) { $dir = $xoopsModuleConfig['directory_secure']; } else { $dir = $xoopsModuleConfig['directory_insecure']; } if (!$fl->remote()) { if (!is_file($dir . '/' . $fl->file())) { $file_exists = false; showMessage(sprintf(__('File %s does not exists! You need to upload this file again.', 'dtransport'), $dir . '/' . $fl->file()), RMMSG_WARN); } } } xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='items.php'>" . $sw->getVar('name') . "</a> » <a href='files.php?item=" . $sw->id() . "'>" . __('Files', 'dtransport') . "</a> » " . ($edit ? __('Edit file', 'dtransport') : __('New file', 'dtransport'))); $tpl->assign('xoops_pagetitle', $xoopsModule->name() . " » " . $sw->getVar('name') . " » " . __('Files', 'dtransport') . " » " . ($edit ? __('Edit file', 'dtransport') : __('New file', 'dtransport'))); $db = XoopsDatabaseFactory::getDatabaseConnection(); $func = new DTFunctions(); $func->toolbar(); $rmf = RMFunctions::get(); $rmu = RMUtilities::get(); // Uploader $tc = TextCleaner::getInstance(); $uploader = new RMFlashUploader('dtfiles-uploader', DT_URL . '/ajax/upload.php'); $token = $xoopsSecurity->createToken(); $uploader->add_setting('onUploadStart', 'function(file){ $("#dtfiles-uploader").uploadify("settings", "formData", { action: "upload", item: $("#item").val(), XOOPS_TOKEN_REQUEST: $("#XOOPS_TOKEN_REQUEST").val(), data: "' . $tc->encrypt($_SERVER['HTTP_USER_AGENT'] . '|' . session_id() . '|' . $xoopsUser->uid() . '|' . $rmf->current_url()) . '" }); }'); $uploader->add_setting('multi', false); $uploader->add_setting('fileExt', '*.' . implode(";*.", $xoopsModuleConfig['type_file'])); $uploader->add_setting('fileDesc', sprintf(__('Allowed files (%s)', 'dtransport'), implode(";*.", $xoopsModuleConfig['type_file']) . ')')); $uploader->add_setting('sizeLimit', $xoopsModuleConfig['size_file'] * 1024 * 1024); $uploader->add_setting('buttonText', __('Select File...', 'rmcommon')); $uploader->add_setting('queueSizeLimit', 1); $uploader->add_setting('auto', true); $uploader->add_setting('onUploadSuccess', "function(file, resp, data){\n eval('ret = '+resp);\n if (ret.error==1){\n \$('.dt-errors').html(ret.message).slideDown('fast');\n upload_error = 1;\n } else {\n upload_error = 0;\n getFilesToken();\n \$('#dtfiles-preview .name').html(ret.file);\n \$('#dtfiles-preview .size').html(ret.size);\n \$('#size').val(ret.fullsize);\n \$('#dtfiles-preview .type').html(ret.type);\n \$('#dtfiles-preview .secure').html(ret.secure);\n }\n return true;\n }"); $uploader->add_setting('onQueueComplete', "function(event, data){\n if(upload_error==1) return;\n \$('.dt-errors').slideUp('fast');\n \$('#dtfiles-uploader').fadeOut('fast');\n \$('#dtfiles-preview').fadeIn('fast');\n }"); $uploader->add_setting('onSelectOnce', "function(event, data){\n \$('#upload-errors').html('');\n }"); if ($edit && $file_exists) { $uploader->add_setting('onInit', 'function(instance){ $("#dtfiles-uploader").hide(); }'); } $groups = array(); //Lista de grupos $sql = "SELECT * FROM " . $db->prefix('dtrans_groups') . " WHERE id_soft={$item}"; $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $group = new DTFileGroup(); $group->assignVars($rows); $groups[] = array('id' => $group->id(), 'name' => $group->name()); } $tpl->add_head($uploader->render()); $tpl->add_style('admin.css', 'dtransport'); $tpl->add_style('files.css', 'dtransport'); $tpl->add_local_script('admin.js', 'dtransport'); $tpl->add_local_script('files.js', 'dtransport'); $tpl->add_head_script('var upload_error = 0;'); include DT_PATH . '/include/js_strings.php'; xoops_cp_header(); include $tpl->get_template("admin/dtrans_filesform.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 Determina el tiempo transcurrido del envio de una alerta al tiempo actual **/ function checkAlert() { global $xoopsModuleConfig, $db, $xoopsConfig; $db = XoopsDatabaseFactory::getDatabaseConnection(); $file = XOOPS_ROOT_PATH . "/cache/alerts.php"; $datelast = file_get_contents($file); if ($datelast <= time() - $xoopsModuleConfig['hrs_alerts'] * 86400) { //Ejecutamos verificación de alertas $sql = "SELECT * FROM " . $db->prefix('dtrans_alerts'); $result = $db->query($sql); while ($rows = $db->fetchArray($result)) { $alert = new DTAlert(); $alert->assignVars($rows); //Obtenemos los datos de la descarga $sw = new DTSoftware($alert->software()); if (!$sw->getVar('approved')) { continue; } if (!$alert->lastActivity()) { if ($sw->getVar('created') >= time() - $alert->limit() * 86400) { continue; } } //Verificamos la fecha de la última descarga del modulo if ($alert->lastActivity() <= time() - $alert->limit() * 86400) { if ($alert->alerted() && $alert->alerted() < $alert->lastActivity() + $alert->limit() * 86400) { continue; } $errors = ''; //Enviamos alerta al autor de la descarga $xoopsMailer =& getMailer(); $alert->mode() ? $xoopsMailer->useMail() : $xoopsMailer->usePM(); $xoopsMailer->setTemplate('alert.tpl'); $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); $xoopsMailer->assign('SITEURL', XOOPS_URL . "/"); $xoopsMailer->assign('DOWNLOAD', $sw->name()); if ($xoopsModuleConfig['urlmode']) { $url = DT_URL . "/item/" . $sw->nameId(); } else { $url = DT_URL . "/item.php?id=" . $sw->id(); } $xoopsMailer->assign('LINK_RESOURCE', $url); $xoopsMailer->assign('DAYS', $alert->limit()); $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . "/modules/dtransport/language/" . $xoopsConfig['language'] . "/mail_template/"); $xu = new XoopsUser($sw->uid()); $xoopsMailer->setToUsers($xu); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']); $xoopsMailer->setSubject(sprintf(_MS_DT_SUBJECTALERT, $sw->name())); $xoopsMailer->send(true); } } //Almacenamos la fecha de la última verificación de alertas file_put_contents($file, time()); } else { return false; } }
/** * Save a new or edited file to database */ function dt_save_file($edit = 0) { global $xoopsSecurity, $functions, $db; foreach ($_POST as $k => $v) { ${$k} = $v; } if (!$xoopsSecurity->check()) { $functions->dt_send_message(__('Session token not valid!', 'dtransport'), 1, 0); } //Verificamos si el software es válido if ($item <= 0) { $functions->dt_send_message(__('Item download ID not provided!', 'dtransport'), 1, 1); } //Verificamos si existe el software $sw = new DTSoftware($item); if ($sw->isNew()) { $functions->dt_send_message(__('Specified item download does nto exists!', 'dtransport'), 1, 1); } if ($edit) { //Verificamos si archivo es válido if ($id <= 0) { $functions->dt_send_message(__('File ID has not been provided!', 'dtransport'), 1, 1); } //Verificamos si existe archivo $fl = new DTFile($id); if ($fl->isNew()) { $functions->dt_send_message(__('Specified file does not exists!', 'dtransport'), 1, 1); } // Si es un archivo remoto eliminamos el archivo actual if (!$fl->remote() && $remote) { $rmu = RMUtilities::get(); $mc = $rmu->module_config('dtransport'); $dir = $sw->getVar('secure') ? $mc['directory_secure'] : $mc['directory_insecure']; if (file_exists($dir . '/' . $fl->file())) { unlink($dir . '/' . $fl->file()); } unset($dir, $mc, $rmu); } } else { $fl = new DTFile(); } $fl->setSoftware($item); $fl->setRemote($remote); $fl->setFile($file); $fl->setDefault($default); $fl->setGroup($group); $fl->setDate(time()); $fl->setTitle(trim($title)); $fl->setMime($mime); $fl->setSize($size); if (!$fl->save()) { $functions->dt_send_message(__('File could not be saved!', 'dtransport') . '<br />' . $fl->errors(), 1, 1); } else { if ($fl->isDefault()) { $db->queryF("UPDATE " . $db->prefix("dtrans_files") . " SET `default`=0 WHERE id_soft=" . $sw->id() . " AND id_file !=" . $fl->id()); } $ret = array('message' => __('File saved successfully!', 'dtransport')); showMessage(sprintf(__('File %s saved successfully!', 'dtransport'), $fl->title()), RMMSG_SAVED); $functions->dt_send_message($ret, 0, 1); } }
$chars = $item->features(true); $data['features'] = array(); foreach ($chars as $feature) { $updated = $feature->modified() > $feature->created() && $feature->modified() > time() - $mc['update'] * 86400; $new = !$updated && $feature->created() > time() - $mc['new'] * 86400; $data['features'][] = array('id' => $feature->id(), 'title' => $feature->title(), 'updated' => $updated, 'nameid' => $feature->nameid(), 'content' => $feature->content(), 'link' => $feature->permalink(), 'metas' => $dtfunc->get_metas('feat', $feature->id())); } unset($chars, $feature); // Logs $logs = $item->logs(true); $data['logs'] = array(); foreach ($logs as $log) { $data['logs'][] = array('id' => $log->id(), 'title' => $log->title(), 'content' => $log->log(), 'date' => formatTimestamp($log->date(), 's')); } unset($logs, $log); $data['metas'] = $dtfunc->get_metas('down', $item->id()); $data['approved'] = $item->getVar('approved'); $xoopsTpl->assign('item', $data); // Usuario $dtUser = new XoopsUser($item->getVar('uid')); $xoopsTpl->assign('dtUser', array('id' => $dtUser->uid(), 'uname' => $dtUser->uname(), 'avatar' => $dtUser->getVar('user_avatar'))); if ($mc['daydownload']) { $xoopsTpl->assign('daily_items', $dtfunc->get_items(0, 'daily', $mc['limit_daydownload'])); $xoopsTpl->assign('daily_width', floor(100 / $mc['limit_daydownload'])); $xoopsTpl->assign('lang_daydown', __('<strong>Day</strong> Downloads', 'dtransport')); } // Desargas relacionadas if ($mc['active_relatsoft']) { $xoopsTpl->assign('lang_related', __('<strong>Related</strong> Downloads', 'dtransport')); $xoopsTpl->assign('related_items', $dtfunc->items_by($relatedTags, 'tags', $item->id(), 'RAND()', 0, $mc['limit_relatsoft'])); }
/** * @desc Genera la información para mostrar la Sindicación * @param int Limite de resultados * @return Array */ function &dtrans_rssshow($limit) { global $util, $mc; $db =& XoopsDatabaseFactory::getDatabaseConnection(); include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtsoftware.class.php'; foreach ($_GET as $k => $v) { ${$k} = $v; } $feed = array(); // Información General $ret = array(); $mc =& $util->moduleConfig('dtransport'); $sql = "SELECT * FROM " . $db->prefix("dtrans_software") . " WHERE approved='1'"; switch ($show) { case 'pops': $feed['title'] = htmlspecialchars(_MI_DT_RSSPOP); $feed['link'] = XOOPS_URL . '/modules/dtransport'; $feed['description'] = htmlspecialchars(_MI_DT_RSSPOPDESC); $sql .= " ORDER BY hits DESC"; break; case 'rate': $feed['title'] = htmlspecialchars(_MI_DT_RSSRATE); $feed['link'] = XOOPS_URL . '/modules/dtransport'; $feed['description'] = htmlspecialchars(_MI_DT_RSSRATEDESC); $sql .= " ORDER BY `rating`/`votes` DESC"; break; default: $feed['title'] = htmlspecialchars(_MI_DT_RSSRECENT); $feed['link'] = XOOPS_URL . '/modules/dtransport'; $feed['description'] = htmlspecialchars(_MI_DT_RSSRECENTDESC); $sql .= " ORDER BY created DESC, modified DESC"; break; } $sql .= " LIMIT 0, 15"; // Generamos los elementos $result = $db->query($sql); $items = array(); $link = XOOPS_URL . '/modules/dtransport/'; while ($row = $db->fetchArray($result)) { $item = new DTSoftware(); $item->assignVars($row); $rtn = array(); $rtn['title'] = htmlspecialchars($item->name()); $ilink = $link . ($mc['urlmode'] ? "item/" . $item->nameId() . "/" : "item.php?id=" . $item->id()); $rtn['link'] = htmlspecialchars($ilink, ENT_QUOTES); $rtn['description'] = $item->shortdesc(); $rtn['date'] = formatTimestamp($item->created()); $items[] = $rtn; } $ret = array('feed' => $feed, 'items' => $items); return $ret; }