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();
 }
 public function delete()
 {
     @unlink($this->path());
     @unlink($this->path('ths'));
     $sw = new DTSoftware($this->software());
     $sw->decrementScreens();
     return $this->deleteFromTable();
 }
Example #3
0
// Manage files for download in XOOPS
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
if ($id <= 0) {
    header('location: ' . DT_URL);
    die;
}
$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'));
    }
Example #4
0
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
// 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 {
Example #5
0
/**
* Author information
*/
function dt_widget_credits($edit = 0)
{
    global $xoopsUser;
    //$widget['title'] = __('Author Information','dtransport');
    //$widget['icon'] = '../images/author.png';
    if ($edit) {
        $sw = new DTSoftware(rmc_server_var($_GET, 'id', 0));
    } else {
        $sw = new DTSoftware();
    }
    $field = new RMFormUser('', 'user', 0, $edit ? array($sw->getVar('uid')) : $xoopsUser->uid(), 50);
    $user = $field->render();
    unset($field);
    ob_start();
    ?>
    <form name="frmCredits" id="frm-credits" method="post">
    <div id="tab-credits" class="widgets_forms">
        <div class="item">
            <label><?php 
    _e('Published by', 'dtransport');
    ?>
</label>
            <?php 
    echo $user;
    ?>
        </div>
        <div class="item">
            <label for="author"><?php 
    _e('Author name', 'dtransport');
    ?>
</label>
            <input type="text" name="author" id="author" value="<?php 
    echo $edit ? $sw->getVar('author_name') : '';
    ?>
" class="fullwidth" />
        </div>
        <div class="item">
            <label for="url"><?php 
    _e('Author URL', 'dtransport');
    ?>
</label>
            <input type="text" name="url" id="url" value="<?php 
    echo $edit ? $sw->getVar('author_url') : '';
    ?>
" class="fullwidth" />
        </div>
        <div class="item">
            <label for="email"><?php 
    _e('Author Email', 'dtransport');
    ?>
</label>
            <input type="text" name="email" id="email" value="<?php 
    echo $edit ? $sw->getVar('author_email') : $xoopsUser->email();
    ?>
" class="fullwidth" />
            <span class="description"><?php 
    _e('This email will not be visible for users', 'dtransport');
    ?>
</span>
        </div>
        <div class="item">
            <input type="checkbox" name="contact" id="contact" value="1"<?php 
    echo $sw->getVar('author_contact') ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('Author can be contacted', 'dtransport');
    ?>
        </div>
    </div>
    </form>
    <?php 
    $content = ob_get_clean();
    return $content;
}
Example #6
0
/**
* @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;
}
Example #7
0
if ($tpages < $page && $tpages > 0) {
    header('location: ' . DT_URL . ($mc['permalinks'] ? '/license/' . $lic->nameId() : '/?p=license&lic=' . $lic->id()));
    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'] ? '/license/' . $lic->nameId() . '/page/{PAGE_NUM}/' : '/?p=license&amp;lic=' . $lic->id() . '&amp;page={PAGE_NUM}'));
$xoopsTpl->assign('pagenav', $nav->render(true));
// Seleccionamos los registros
$sql = str_replace('COUNT(*)', 'b.*', $sql);
$sql .= " ORDER BY created DESC";
$sql .= " LIMIT {$start}, {$limit}";
$result = $db->query($sql);
while ($row = $db->fetchArray($result)) {
    $item = new DTSoftware();
    $item->assignVars($row);
    $xoopsTpl->append('download_items', $dtfunc->createItemData($item));
}
// Datos de la etiqueta
$xoopsTpl->assign('license', array('id' => $lic->id(), 'name' => $lic->name(), 'link' => $lic->permalink()));
$tpl->add_xoops_style('main.css', 'dtransport');
$dtfunc->makeHeader();
$xoopsTpl->assign('xoops_pagetitle', sprintf(__('Downloads licensed as %s', 'dtransport'), $lic->name()));
if ($mc['inner_dest_download']) {
    $xoopsTpl->assign('featured_items', $dtfunc->items_by(array($lic->id()), 'licenses', 0, 'featured', 0, $mc['limit_destdown']));
    $xoopsTpl->assign('lang_incatego', __('In <a href="%s">%s</a>', 'dtransport'));
    $xoopsTpl->assign('lang_featured', __('<strong>Featured</strong> Downloads', 'dtransport'));
}
// Descargas el día
if ($mc['inner_daydownload']) {
Example #8
0
         redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/' : '/?p=cp'), 2, $edit ? __('Changes saved successfully!', 'dtransport') : __('Download item created successfully'));
     }
     break;
 case 'edit':
 default:
     $edit = $action == 'edit' && $id > 0 ? 1 : 0;
     // MOSTRAR FORMULARIO
     $xoopsOption['template_main'] = 'dtrans_submit.html';
     $xoopsOption['module_subpage'] = 'submit';
     if ($edit) {
         //Verificamos si el elemento es válido
         if ($id <= 0) {
             redirect_header(DT_URL, 2, __('Item not found. Please try again!', 'dtransport'));
         }
         //Verificamos si el elemento existe
         $item = new DTSoftware($id);
         if ($item->isNew()) {
             redirect_header(DT_URL, 2, __('Item not found. Please try again!', 'dtransport'));
         }
         //Verificamos si se aprueba la edicion
         if (!$mc['aprove_edit'] && $item->getVar('approved')) {
             // 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'));
         }
     }
     include 'header.php';
function dt_upload_screenshots()
{
    global $xoopsSecurity;
    $item = rmc_server_var($_REQUEST, 'item', 0);
    $data = rmc_server_var($_REQUEST, 'data', '');
    $rmu = RMUtilities::get();
    $mc = $rmu->module_config('dtransport');
    $tc = TextCleaner::getInstance();
    $data = explode("|", $tc->decrypt($data));
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $ses = new XoopsSessionHandler($db);
    session_decode($ses->read($data[1]));
    $_SERVER['HTTP_USER_AGENT'] = trim($data[0]);
    if (!$xoopsSecurity->check(false)) {
        error(__('Session token not valid!', 'dtransport'));
    }
    if ($item <= 0) {
        error(__('Download item ID not provided!', 'dtransport'));
    }
    require_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtsoftware.class.php';
    $sw = new DTSoftware($item);
    if ($sw->isNew()) {
        error(__('Specified download item does not exists!', 'dtransport'));
    }
    if ($sw->getVar('screens') >= $mc['limit_screen']) {
        error(__('You have reached the limit screens number for this download item!', 'dtransport'));
    }
    // Directorio de almacenamiento
    $dir = XOOPS_UPLOAD_PATH . '/screenshots';
    if (!is_dir($dir)) {
        mkdir($dir, 511);
    }
    $dir .= '/' . date('Y', time());
    if (!is_dir($dir)) {
        mkdir($dir, 511);
    }
    $dir .= '/' . date('m', time());
    if (!is_dir($dir)) {
        mkdir($dir, 511);
    }
    if (!is_dir($dir . '/ths')) {
        mkdir($dir . '/ths', 511);
    }
    if (!is_dir($dir)) {
        error(__('Directory for store screenshots does not exists!', 'dtransport'));
    }
    include RMCPATH . '/class/uploader.php';
    $uploader = new RMFileUploader($dir, $mc['image'] * 1024, array('jpg', 'gif', 'png'));
    $err = array();
    if (!$uploader->fetchMedia('Filedata')) {
        error($uploader->getErrors());
    }
    if (!$uploader->upload()) {
        error($uploader->getErrors());
    }
    // Saving image
    require_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtscreenshot.class.php';
    $img = new DTScreenshot();
    $img->setDesc('');
    $img->setTitle($uploader->getSavedFileName());
    $img->setImage($uploader->getSavedFileName());
    $img->setDate(time());
    $img->setSoftware($item);
    if (!$img->save()) {
        unlink($dir . '/' . $img->image());
        error(__('Screenshot could not be saved!', 'dtransport'));
    }
    // Resize image
    $thumb = explode(":", $mc['size_ths']);
    $big = explode(":", $mc['size_image']);
    $sizer = new RMImageResizer($dir . '/' . $img->getVar('image'), $dir . '/ths/' . $img->getVar('image'));
    // Thumbnail
    if (!isset($thumb[2]) || $thumb[2] == 'crop') {
        $sizer->resizeAndCrop($thumb[0], $thumb[1]);
    } else {
        $sizer->resizeWidthOrHeight($thumb[0], $thumb[1]);
    }
    // Full size image
    $sizer->setTargetFile($dir . '/' . $img->image());
    if (!isset($big[2]) || $big[2] == 'crop') {
        $sizer->resizeAndCrop($big[0], $big[1]);
    } else {
        $sizer->resizeWidthOrHeight($big[0], $big[1]);
    }
    $ret = array('image' => $uploader->getSavedFileName(), 'dir' => str_replace(XOOPS_UPLOAD_PATH, XOOPS_UPLOAD_URL, $dir), 'token' => $xoopsSecurity->createToken(), 'type' => $uploader->getMediaType(), 'error' => 0, 'id' => $img->id());
    echo json_encode($ret);
    die;
}
Example #10
0
$rmu = RMUtilities::get();
$mc = $rmu->module_config('dtransport');
$tc = TextCleaner::getInstance();
$data = explode("|", $tc->decrypt($data));
$db = XoopsDatabaseFactory::getDatabaseConnection();
$ses = new XoopsSessionHandler($db);
session_decode($ses->read($data[1]));
$_SERVER['HTTP_USER_AGENT'] = trim($data[0]);
if (!$xoopsSecurity->check()) {
    error(__('Session token not valid!', 'dtransport'));
}
if ($item <= 0) {
    error(__('Download item ID not provided!', 'dtransport'));
}
require_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtsoftware.class.php';
$sw = new DTSoftware($item);
if ($sw->isNew()) {
    error(__('Specified download item does not exists!', 'dtransport'));
}
if ($sw->getVar('secure')) {
    $dir = $mc['directory_secure'];
    if (!is_dir($dir)) {
        if (!mkdir($dir, 511)) {
            error(__('Directory for protected downloads does not exists!', 'dtransport'));
        }
    }
} else {
    $dir = $mc['directory_insecure'];
    if (!is_dir($dir)) {
        if (!mkdir($dir, 511)) {
            error(__('Directory for downloads does not exists!', 'dtransport'));
Example #11
0
 $limit = 15;
 $tpages = ceil($num / $limit);
 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&amp;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&amp;action=edit&amp;id=' . $item->id(), 'delete' => $mc['permalinks'] ? DT_URL . '/cp/delete/' . $item->id() : '/?p=cpanel&amp;action=delete&amp;id=' . $item->id(), 'files' => $mc['permalinks'] ? DT_URL . '/cp/files/' . $item->id() : '/?p=cpanel&amp;action=files&amp;id=' . $item->id(), 'features' => $mc['permalinks'] ? DT_URL . '/cp/features/' . $item->id() : '/?p=cpanel&amp;action=features&amp;id=' . $item->id(), 'logs' => $mc['permalinks'] ? DT_URL . '/cp/logs/' . $item->id() : '/?p=cpanel&amp;action=logs&amp;id=' . $item->id(), 'screens' => $mc['permalinks'] ? DT_URL . '/cp/screens/' . $item->id() : '/?p=cpanel&amp;action=screens&amp;id=' . $item->id(), 'canceldel' => $mc['permalinks'] ? DT_URL . '/cp/canceldel/' . $item->id() : '/?p=cpanel&amp;action=canceldel&amp;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'));
 /**
  * Get items by tag(s)
  */
 public function items_by($elements, $by, $exclude = 0, $type = 'all', $start = 0, $limit = 10)
 {
     if (!is_array($elements) and $elements <= 0) {
         return;
     }
     if (!is_array($elements)) {
         $elements = array($elements);
     }
     switch ($type) {
         case 'featured':
             $filter = "s.approved=1 AND s.featured=1 AND s.delete=0";
             $order = "ORDER BY RAND()";
             break;
         case 'recent':
             $filter = "s.approved=1 AND s.delete=0";
             $order = "ORDER BY s.created DESC";
             break;
         case 'daily':
             $filter = "s.approved=1 AND s.daily=1 AND s.delete=0";
             $order = "ORDER BY RAND()";
             break;
         case 'rated':
             $filter = "s.approved=1 AND s.delete=0";
             $order = "ORDER BY s.rating DESC";
             break;
         case 'updated':
             $filter = "s.approved=1 AND s.delete=0";
             $order = "ORDER BY s.modified DESC";
             break;
         default:
             $filter = 's.approved=1 AND s.delete=0';
             $order = "ORDER BY created DESC";
             break;
     }
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $softt = $db->prefix('dtrans_software');
     switch ($by) {
         case 'tags':
             $byt = $db->prefix('dtrans_softtag');
             $sql = "SELECT s.* FROM {$softt} AS s, {$byt} AS t WHERE t.id_tag IN (" . implode(",", $elements) . ") AND t.id_soft!={$exclude} AND s.id_soft=t.id_soft AND {$filter} GROUP BY t.id_soft {$order} LIMIT {$start}, {$limit}";
             break;
         case 'platforms':
             $byt = $db->prefix('dtrans_platsoft');
             $sql = "SELECT s.* FROM {$softt} AS s, {$byt} AS t WHERE t.id_platform IN (" . implode(",", $elements) . ") AND t.id_soft!={$exclude} AND s.id_soft=t.id_soft AND {$filter} GROUP BY t.id_soft {$order} LIMIT {$start}, {$limit}";
             break;
         case 'licenses':
             $byt = $db->prefix('dtrans_licsoft');
             $sql = "SELECT s.* FROM {$softt} AS s, {$byt} AS t WHERE t.id_lic IN (" . implode(",", $elements) . ") AND t.id_soft!={$exclude} AND s.id_soft=t.id_soft AND {$filter} GROUP BY t.id_soft {$order} LIMIT {$start}, {$limit}";
             break;
     }
     $result = $db->query($sql);
     $items = array();
     while ($row = $db->fetchArray($result)) {
         $item = new DTSoftware();
         $item->assignVars($row);
         $cats = $item->categories(true);
         $cat = $cats[array_rand($cats, 1)];
         $items[] = array_merge($this->createItemData($item), array('category' => $cat->name(), 'categoryid' => $cat->id(), 'categorylink' => $cat->permalink()));
     }
     return $items;
 }
Example #13
0
/**
 * Elimina archivos de la base de datos y el disco duro
 */
function dt_delete_file()
{
    global $xoopsSecurity, $functions;
    if (!$xoopsSecurity->check()) {
        $functions->dt_send_message(__('Session token not valid!', 'dtransport'), 1, 0);
    }
    $id = rmc_server_var($_POST, 'id', 0);
    $item = rmc_server_var($_POST, 'item', 0);
    $file = new DTFile($id);
    if ($file->isNew()) {
        $functions->dt_send_message(__('Specified file does not exists!', 'dtransport'), 1, 1);
    }
    $sw = new DTSoftware($item);
    if ($sw->isNew()) {
        $functions->dt_send_message(__('Specified item download does nto exists!', 'dtransport'), 1, 1);
    }
    if ($file->software() != $item) {
        $functions->dt_send_message(__('This file seems not belong to specified download item!', 'dtransport'), 1, 1);
    }
    if (!$file->delete()) {
        $functions->dt_send_message(__('File could not be deleted!', 'dtransport'), 1, 1);
    }
    $rmu = RMUtilities::get();
    $mc = $rmu->module_config('dtransport');
    $dir = $sw->getVar('secure') ? $mc['directory_secure'] : $mc['directory_insecure'];
    unlink($dir . '/' . $file->file());
    $functions->dt_send_message(__('File deleted successfully!', 'dtransport'), 0, 1);
}
Example #14
0
<?php

// $Id$
// --------------------------------------------------------------
// D-Transport
// Manage files for download in XOOPS
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
if ($id == '') {
    header('location: ' . DT_URL);
    die;
}
$item = new DTSoftware($id);
if ($item->getVar('approved')) {
    $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) {
Example #15
0
/**
* @desc Elimina el Log especificado
**/
function dt_delete_log()
{
    global $xoopsModule, $xoopsSecurity;
    $ids = rmc_server_var($_POST, 'ids', array());
    $item = rmc_server_var($_POST, 'item', 0);
    //Verificamos si el software es válido
    if ($item <= 0) {
        redirectMsg('items.php', __('Download item ID not provided!', 'dtransport'), RMMSG_WARN);
    }
    //Verificamos si existe el software
    $sw = new DTSoftware($item);
    if ($sw->isNew()) {
        redirectMsg('items.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_WARN);
    }
    //Verificamos si nos proporcionaron algun log
    if (empty($ids)) {
        redirectMsg('logs.php?item=' . $item, __('You must select at least one log!', 'dtransport'), RMMSG_ERROR);
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('logs.php?item=' . $item, __('Session token not valid!', 'dtransport'), RMMSG_ERROR);
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "DELETE FROM " . $db->prefix("dtrans_logs") . " WHERE id_log IN(" . implode(",", $ids) . ");";
    if ($db->queryF($sql)) {
        redirectMsg('logs.php?item=' . $item, __('Item logs deleted successfully!', 'dtransport'), RMMSG_SUCCESS);
    } else {
        redirectMsg('logs.php?item=' . $item, __('Logs could not be deleted!', 'dtransport') . '<br />' . $db->error(), RMMSG_ERROR);
    }
}
Example #16
0
/**
* @desc Elimina el grupo especificado
**/
function deleteGroups()
{
    global $xoopsModule, $util, $xoopsSecurity;
    $id = rmc_server_var($_REQUEST, 'id', array());
    $item = rmc_server_var($_REQUEST, 'item', 0);
    if (!$xoopsSecurity->check()) {
        redirectMsg('files.php?item=' . $item, __('Session token not valid!', 'dtransport'), RMMSG_WARN);
        die;
    }
    //Verificamos si el software es válido
    if ($item <= 0) {
        redirectMsg('files.php', __('Download item ID not provided!', 'dtransport'), RMMSG_WARN);
        die;
    }
    //Verificamos si existe el software
    $sw = new DTSoftware($item);
    if ($sw->isNew()) {
        redirectMsg('files.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_WARN);
        die;
    }
    //Verificamos si grupo es válido
    if ($id <= 0) {
        redirectMsg('files.php?item=' . $item, __('Group id not provided!', 'dtransport'), RMMSG_ERROR);
        die;
    }
    //Verificamos si el grupo existe
    $group = new DTFileGroup($id);
    if ($group->isNew()) {
        redirectMsg('files.php?item=' . $item, __('Specified group does not exists!', 'dtransport'), RMMSG_ERROR);
        die;
    }
    if (!$group->delete()) {
        redirectMsg('files.php?item=' . $item, sprintf(__('Group %s could not be deleted!', 'dtransport'), '<strong>' . $group->name() . '</strong>') . '<br />' . $group->errors(), 1);
        die;
    } else {
        redirectMsg('files.php?item=' . $item, sprintf(__('Group %s deleted successfully!', 'dtransport'), '<strong>' . $group->name() . '</strong>'), 0);
        die;
    }
}
Example #17
0
if ($tpages < $page && $tpages > 0) {
    header('location: ' . $category->permalink());
    die;
}
$p = $page > 0 ? $page - 1 : $page;
$start = $num <= 0 ? 0 : $p * $limit;
$nav = new RMPageNav($num, $limit, $page);
$nav->target_url($category->permalink() . ($mc['permalinks'] ? 'page/{PAGE_NUM}/' : '?page={PAGE_NUM}'));
$xoopsTpl->assign('pagenav', $nav->render(true));
// Seleccionamos los registros
$sql = str_replace('COUNT(*)', 's.*', $sql);
$sql .= " ORDER BY s.modified DESC";
$sql .= " LIMIT {$start}, {$limit}";
$result = $db->queryF($sql);
while ($row = $db->fetchArray($result)) {
    $item = new DTSoftware();
    $item->assignVars($row);
    $xoopsTpl->append('download_items', array_merge($dtfunc->createItemData($item), array('category' => $category->name())));
}
if ($mc['inner_dest_download']) {
    $xoopsTpl->assign('featured_items', $dtfunc->get_items($category->id(), 'featured', $mc['limit_destdown']));
    $xoopsTpl->assign('lang_incatego', __('In <a href="%s">%s</a>', 'dtransport'));
}
// Descargas el día
if ($mc['inner_daydownload']) {
    $xoopsTpl->assign('daily_items', $dtfunc->get_items($category->id(), 'daily', $mc['limit_daydownload']));
    $xoopsTpl->assign('daily_width', floor(100 / $mc['limit_daydownload']));
    $xoopsTpl->assign('lang_daydown', __('<strong>Day</strong> Downloads', 'dtransport'));
}
$xoopsTpl->assign('xoops_pagetitle', $category->name() . " &raquo; " . $xoopsModule->name());
$xoopsTpl->assign('lang_in', sprintf(__('<strong>Downloads in</strong> %s', 'dtransport'), $category->name()));
Example #18
0
/**
* desc Elimina de la base de datos los elementos
**/
function dt_delete_items()
{
    global $xoopsModuleConfig, $xoopsConfig, $xoopsModule, $xoopsSecurity, $rmc_config, $xoopsUser;
    $ids = rmc_server_var($_POST, 'ids', array());
    $page = rmc_server_var($_POST, 'page', 1);
    $search = rmc_server_var($_POST, 'search', '');
    $sort = rmc_server_var($_POST, 'sort', 'id_soft');
    $mode = rmc_server_var($_POST, 'mode', 1);
    $cat = rmc_server_var($_POST, 'cat', 0);
    $type = rmc_server_var($_POST, 'type', '');
    $params = '?pag=' . $page . '&search=' . $search . '&sort=' . $sort . '&mode=' . $mode . '&cat=' . $cat . '&type=' . $type;
    //Verificamos que el software sea válido
    if (!is_array($ids) && $ids <= 0) {
        redirectMsg('items.php' . $params, __('You must select at least one download item to delete!', 'dtransport'), RMMSG_WARN);
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('items.php' . $params, __('Session token expired!', 'dtransport'), RMMSG_ERROR);
    }
    $errors = '';
    $mailer = new RMMailer('text/html');
    $etpl = DT_PATH . '/lang/deletion_' . $rmc_config['lang'] . '.php';
    if (!file_exists($etpl)) {
        $etpl = DT_PATH . '/lang/deletion_en.php';
    }
    $mailer->template($etpl);
    $mailer->assign('siteurl', XOOPS_URL);
    $mailer->assign('dturl', $xoopsModuleConfig['permalinks'] ? XOOPS_URL . '/' . trim($xoopsModuleConfig['htbase'], '/') : DT_URL);
    $mailer->assign('downcp', $xoopsModuleConfig['permalinks'] ? XOOPS_URL . '/' . trim($xoopsModuleConfig['htbase'], '/') . '/cp/' : DT_URL . '/?p=cpanel');
    $mailer->assign('dtname', $xoopsModule->name());
    $mailer->assign('sitename', $xoopsConfig['sitename']);
    foreach ($ids as $id) {
        $sw = new DTSoftware($id);
        if ($sw->isNew()) {
            continue;
        }
        if (!$sw->delete()) {
            $errors .= $sw->errors();
            continue;
        }
        $xu = new XoopsUser($sw->getVar('uid'));
        $mailer->add_users(array($xu));
        $mailer->assign('uname', $xu->name() != '' ? $xu->name() : $xu->uname());
        $mailer->assign('download', $sw->getVar('name'));
        $mailer->assign('email', $xu->getVar('email'));
        $mailer->assign('method', $xu->getVar('notify_method'));
        $mailer->set_subject(sprintf(__('Your download %s has been deleted!', 'dtransport'), $sw->getVar('name')));
        if ($xu->getVar('notify_method') == 1) {
            $mailer->set_from_xuser($xoopsUser);
            $mailer->send_pm();
        } else {
            $mailer->send();
        }
    }
    if ($errors != '') {
        redirectMsg('items.php' . $params, __('Errors ocurred while trying to delete selected downloads!', 'dtransport') . '<br />' . $errors, RMMSG_ERROR);
    }
    redirectMsg('items.php' . $params, __('Downloads deleted successfully!', 'dtransport'), RMMSG_SUCCESS);
}
Example #19
0
/**
* @desc Elimina pantallas de la base de datos
**/
function deleteScreens()
{
    global $xoopsModule, $util;
    $ids = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
    $item = isset($_REQUEST['item']) ? intval($_REQUEST['item']) : 0;
    $ok = isset($_POST['ok']) ? intval($_POST['ok']) : 0;
    //Verificamos que el software sea válido
    if ($item <= 0) {
        redirectMsg('./screens.php', _AS_DT_ERR_ITEMVALID, 1);
        die;
    }
    //Verificamos que el software exista
    $sw = new DTSoftware($item);
    if ($sw->isNew()) {
        redirectMsg('./screens.php', _AS_DT_ERR_ITEMEXIST, 1);
        die;
    }
    //Verificamos si nos proporcionaron alguna pantalla
    if (!is_array($ids) && $ids <= 0) {
        redirectMsg('./screens.php?item=' . $item, _AS_DT_NOTSCREEN, 1);
        die;
    }
    $num = 0;
    if (!is_array($ids)) {
        $scr = new DTScreenshot($ids);
        $ids = array($ids);
        $num = 1;
    }
    if ($ok) {
        if (!$util->validateToken()) {
            redirectMsg('./screens.php?item=' . $item, _AS_DT_SESSINVALID, 1);
            die;
        }
        $errors = '';
        foreach ($ids as $k) {
            //Verificamos si pantalla es válida
            if ($k <= 0) {
                $errors .= sprintf(_AS_DT_ERRSCVAL, $k);
                continue;
            }
            //Verificamos que la pantalla exista
            $sc = new DTScreenshot($k);
            if ($sc->isNew()) {
                $errors .= sprintf(_AS_DT_ERRSCEX, $k);
                continue;
            }
            if (!$sc->delete()) {
                $errors .= sprintf(_AS_DT_ERRSCDEL, $k);
            }
        }
        if ($errors != '') {
            redirectMsg('./screens.php?item=' . $item, _AS_DT_ERRORS . $errors, 1);
            die;
        } else {
            redirectMsg('./screens.php?item=' . $item, _AS_DT_DBOK, 0);
            die;
        }
    } else {
        optionsBar($sw);
        xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./items.php'>" . _AS_DT_SW . "</a> &raquo; " . _AS_DT_DELETESCREEN);
        xoops_cp_header();
        $hiddens['ok'] = 1;
        $hiddens['id[]'] = $ids;
        $hiddens['item'] = $item;
        $hiddens['op'] = 'delete';
        $buttons['sbt']['type'] = 'submit';
        $buttons['sbt']['value'] = _DELETE;
        $buttons['cancel']['type'] = 'button';
        $buttons['cancel']['value'] = _CANCEL;
        $buttons['cancel']['extra'] = 'onclick="window.location=\'screens.php?item=' . $item . '\';"';
        $util->msgBox($hiddens, 'screens.php', ($num ? sprintf(_AS_DT_DELETECONF, $scr->title()) : _AS_DT_DELCONF) . '<br /><br />' . _AS_DT_ALLPERM, XOOPS_ALERT_ICON, $buttons, true, '400px');
        xoops_cp_footer();
    }
}
Example #20
0
/**
 * 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);
}
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;
}
Example #22
0
 public function delete(DTSoftware $sw = null)
 {
     global $xoopsModuleConfig;
     if ($this->remote()) {
         return $this->deleteFromTable();
     }
     if (!is_a($sw, 'DTSoftware')) {
         $sw = new DTSoftware($this->software());
     }
     $rmu = RMUtilities::get();
     $mc = $rmu->module_config('dtransport');
     if ($sw->getVar('secure')) {
         unlink(rtrim($mc['directory_secure'], '/') . '/' . $this->file());
     } else {
         unlink(rtrim($mc['directory_insecure'], '/') . '/' . $this->file());
     }
     return $this->deleteFromTable();
 }