/** * Obtiene el enlace a la categor?a */ public function permalink() { $mc = RMUtilities::get()->module_config('mywords'); $link = MWFunctions::get_url(); $link .= $mc['permalinks'] == 1 ? '?cat=' . $this->id() : ($mc['permalinks'] == 2 ? 'category/' . $this->path() : 'category/' . $this->id()); return $link; }
public function permalink() { $mc = RMUtilities::get()->module_config('mywords'); $rtn = MWFunctions::get_url(); $rtn .= $mc['permalinks'] == 1 ? '?author=' . $this->id() : ($mc['permalinks'] == 2 ? "author/" . $this->getVar('shortname', 'n') . "/" : "author/" . RMUtilities::add_slash($this->id())); return $rtn; }
function dt_block_categories($options) { include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtcategory.class.php'; $rmu = RMUtilities::get(); $rmf = RMFunctions::get(); $mc = $rmu->module_config('dtransport'); $url = $rmf->current_url(); $rpath = parse_url($url); $xpath = parse_url(XOOPS_URL); if ($mc['permalinks']) { $params = trim(str_replace($xpath['path'] . '/' . trim($mc['htbase'], '/'), '', rtrim($rpath['path'], "/")), '/'); $search = array('category', 'publisher', 'recents', 'popular', 'rated', 'updated'); if ($params == '') { $params = array(); } else { $params = explode("/", trim($params)); } if (!empty($params) && $params[0] == 'category') { $db = XoopsDatabaseFactory::getDatabaseConnection(); $params = explode("page", implode("/", array_slice($params, 1))); $path = explode("/", $params[0]); foreach ($path as $k) { if ($k == '') { continue; } $category = new DTCategory(); $sql = "SELECT * FROM " . $db->prefix("dtrans_categos") . " WHERE nameid='{$k}' AND parent='{$idp}'"; $result = $db->query($sql); if ($db->getRowsNum($result) > 0) { $row = $db->fetchArray($result); $idp = $row['id_cat']; $category->assignVars($row); } else { $dtfunc->error_404(); } } } else { $category = new DTCategory(); } } $tpl = RMTemplate::get(); $tpl->add_xoops_style('blocks.css', 'dtransport'); include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php'; $categories = array(); $dtfunc = new DTFunctions(); $dtfunc->getCategos($categories, 0, $category->id(), array(), false, 1); $block = array(); foreach ($categories as $cat) { if ($cat['jumps'] > $options[0] - 1 && $options[0] > 0) { continue; } $block['categories'][] = $cat; } if (!$category->isNew()) { $block['parent'] = array('name' => $category->name(), 'link' => $category->permalink()); } return $block; }
public function permalink() { $rmu = RMUtilities::get(); $mc = $rmu->module_config('dtransport'); if ($mc['permalinks']) { return XOOPS_URL . '/' . trim($mc['htbase'], '/') . '/platform/' . $this->nameId() . '/'; } else { return XOOPS_URL . '/modules/dtransport/index.php?p=platform&id=' . $this->id(); } }
function bxpress_recents_show($options) { $util = RMUtilities::get(); $tc = TextCleaner::getInstance(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $xoopsModuleConfig = $util->module_config('exmbb'); $mc = RMUtilities::module_config('bxpress'); $tbl1 = $db->prefix('bxpress_posts'); $tbl2 = $db->prefix('bxpress_topics'); $tbl3 = $db->prefix('bxpress_posts_text'); $tbl4 = $db->prefix('bxpress_forums'); $sql = "SELECT MAX(id_post) AS id FROM {$tbl1} WHERE approved=1 GROUP BY id_topic ORDER BY MAX(id_post) DESC LIMIT 0,{$options['0']}"; $result = $db->queryF($sql); $topics = array(); $block = array(); include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxforum.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxpost.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxtopic.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxfunctions.class.php'; $post = new bXPost(); $forum = new bXForum(); $tf = new RMTimeFormatter(0, '%T%-%d%-%Y% at %h%:%i%'); while ($row = $db->fetchArray($result)) { $post = new bXPost($row['id']); $topic = new bXTopic($post->topic()); $forum = new bXForum($post->forum()); $ret = array(); $ret['id'] = $topic->id(); $ret['post'] = $post->id(); $ret['link'] = $post->permalink(); if ($options[2]) { $ret['date'] = $tf->format($post->date()); } if ($options[3]) { $ret['poster'] = sprintf(__('Posted by: %s', 'bxpress'), "<a href='" . $post->permalink() . "'>" . $post->uname() . "</a>"); } $ret['title'] = $topic->title(); if ($options[4]) { $ret['text'] = $tc->clean_disabled_tags($post->text()); } $ret['forum'] = array('id' => $forum->id(), 'name' => $forum->name(), 'link' => $forum->permalink()); $topics[] = $ret; } // Opciones $block['showdates'] = $options[2]; $block['showuname'] = $options[3]; $block['showtext'] = $options[4]; $block['topics'] = $topics; $block['lang_topic'] = __('Topic', 'bxpress'); $block['lang_date'] = __('Date', 'bxpress'); $block['lang_poster'] = __('Poster', 'bxpress'); return $block; }
/** * Get correct base url for links */ function get_url() { global $xoopsModule, $xoopsModuleConfig; if (!$xoopsModule || $xoopsModule->dirname() != 'shop') { $mc = RMUtilities::get()->module_config('shop'); } else { $mc = $xoopsModuleConfig; } if ($mc['urlmode']) { $ret = XOOPS_URL . '/' . trim($mc['htbase'], "/") . '/'; } else { $ret = XOOPS_URL . '/modules/shop/'; } return $ret; }
/** * Constructor * @param <string> $caption * @param <string> $name Nombre identificador del campo * @param <string> $date Fecha en formato 'yyyy-mm-14' */ function __construct($caption, $name, $date = '', $showtime = 0) { $this->setCaption($caption); $this->setName($name); $this->_date = $date; $this->_showtime = $showtime; if (!defined('RM_FRAME_DATETIME_CREATED')) { define('RM_FRAME_DATETIME_CREATED', 1); } // Necesario para incluir el script de fechas if (!defined('SCRIPT_PROTOTYPE_INCLUDED')) { $util =& RMUtilities::get(); } if (defined('EXM_IS_CP') && EXM_IS_CP == true) { // This class must be instantiated before that the method ExmGUI::cp_head(); RMTemplate::get()->add_script(RMCURL . '/include/js/dates.js'); } }
/** * @desc Crea la cabecera del módulo */ public function makeHeader($title = '') { global $xoopsTpl, $xoopsUser; $func = RMUtilities::get(); $mc = $func->module_config('dtransport'); $xoopsTpl->assign('dt_header_title', $title); $header = array('cansubmit' => $this->canSubmit(), 'searchlink' => $mc['permalinks'] ? DT_URL . '/' . trim($mc['htbase'], '/') . '/search/' : DT_URL . '/?p=search'); $header['links'][] = array('title' => __('Downloads', 'dtransport'), 'link' => DT_URL); $header['links'][] = array('title' => __('My Downloads', 'dtransport'), 'link' => $mc['permalinks'] ? DT_URL . '/cp/' : DT_URL . '/?p=cpanel'); if ($this->canSubmit()) { $header['links'][] = array('title' => __('Submit Download', 'dtransport'), 'link' => $mc['permalinks'] ? DT_URL . '/submit/' : DT_URL . '/?p=explore&f=submit'); } $header['links'][] = array('title' => __('Recent Downloads', 'dtransport'), 'link' => $mc['permalinks'] ? DT_URL . '/recent/' : DT_URL . '/?p=explore&f=recent'); $header['links'][] = array('title' => __('Popular Downloads', 'dtransport'), 'link' => $mc['permalinks'] ? DT_URL . '/popular/' : DT_URL . '/?p=explore&f=popular'); $header['links'][] = array('title' => __('Best Rated', 'dtransport'), 'link' => $mc['permalinks'] ? DT_URL . '/rated/' : DT_URL . '/?p=explore&f=rated'); $ev = RMEvents::get(); $header = $ev->run_event("dtransport.make.header", $header); $xoopsTpl->assign('header', $header); $tpl = RMTemplate::get(); $tpl->add_xoops_style('main.css', 'dtransport'); return true; }
/** * @desc Realiza una búsqueda en el módulo desde EXM */ function gsSearch($queryarray, $andor, $limit, $offset, $userid) { global $db, $myts; include_once XOOPS_ROOT_PATH . "/modules/galleries/class/gsimage.class.php"; include_once XOOPS_ROOT_PATH . "/modules/galleries/class/gsuser.class.php"; $mc = RMUtilities::get()->module_config('galleries'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT DISTINCT c.* FROM " . $db->prefix('gs_tags') . " a INNER JOIN " . $db->prefix('gs_tagsimages') . " b INNER JOIN "; $sql .= $db->prefix('gs_images') . " c ON ("; $sql .= "a.id_tag=b.id_tag AND b.id_image=c.id_image AND c.public=2 AND ("; $sql1 = ''; foreach ($queryarray as $k) { $sql1 .= ($sql1 == '' ? "" : "{$andor}") . " (a.tag LIKE '%{$k}%' OR c.title LIKE '%{$k}%') "; } $sql1 .= "))"; $sql1 .= " ORDER BY c.created DESC LIMIT {$offset}, {$limit}"; $result = $db->queryF($sql . $sql1); $ret = array(); $users = array(); while ($row = $db->fetchArray($result)) { $img = new GSImage(); $img->assignVars($row); if (!isset($users[$img->owner()])) { $users[$img->owner()] = new GSUser($img->owner(), 1); } $rtn = array(); $rtn['image'] = 'images/images.png'; $link = $mc['urlmode'] ? "usr/" . $users[$img->owner()]->uname() . "/img/" . $img->id() : "user.php?id=" . "usr/" . $users[$img->owner()]->uname() . "/img/" . $img->id(); $rtn['title'] = $img->title(); $rtn['time'] = $img->created(); $rtn['uid'] = $img->owner(); $rtn['desc'] = $img->desc(); $rtn['link'] = $link; $ret[] = $rtn; } return $ret; }
/** * Función para realizar búsquedas */ function mywords_search($qa, $andor, $limit, $offset, $userid) { global $xoopsUser; $db = XoopsDatabaseFactory::getDatabaseConnection(); include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwpost.class.php'; $util =& RMUtilities::get(); $mc =& $util->module_config('mywords'); $sql = "SELECT * FROM " . $db->prefix("mw_posts"); $adds = ''; if (is_array($qa) && ($count = count($qa))) { $adds = ''; for ($i = 0; $i < $count; $i++) { $adds .= $adds == '' ? "(title LIKE '%{$qa[$i]}%' OR content LIKE '%{$qa[$i]}%')" : " {$andor} (title LIKE '%{$qa[$i]}%' OR content LIKE '%{$qa[$i]}%')"; } } $sql .= $adds != '' ? " WHERE " . $adds : ''; if ($userid > 0) { $sql .= ($adds != '' ? " AND " : " WHERE ") . "author='{$userid}'"; } $sql .= " ORDER BY pubdate DESC"; $i = 0; $result = $db->query($sql, $limit, $offset); $ret = array(); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); $ret[$i]['image'] = "images/post.png"; $ret[$i]['link'] = $post->permalink(); $ret[$i]['title'] = $post->getVar('title'); $ret[$i]['time'] = $post->getVar('pubdate'); $ret[$i]['uid'] = $post->getVar('author'); $ret[$i]['desc'] = substr(strip_tags($post->content()), 0, 150); $i++; } return $ret; }
function mywordsBlockCats($options) { global $xoopsModuleConfig, $xoopsModule; $categos = array(); MWFunctions::categos_list($categos, 0, 0, $options[0]); $block = array(); $mc = $xoopsModule && $xoopsModule->getVar('dirname') == 'mywords' ? $xoopsModuleConfig : RMUtilities::get()->module_config('mywords'); foreach ($categos as $k) { $ret = array(); $cat = new MWCategory(); $cat->assignVars($k); $cat->loadPosts(); $ret['id'] = $cat->id(); $ret['name'] = $cat->getVar('name'); if (isset($options[1]) && $options[1]) { $ret['posts'] = $cat->getVar('posts'); } $ret['indent'] = $k['indent'] * 2; $ret['link'] = $cat->permalink(); $block['categos'][] = $ret; } RMTemplate::get()->add_xoops_style('mwblocks.css', 'mywords'); return $block; }
/** * Obtiene el enlace permanente al artículo */ public function permalink() { $mc = RMUtilities::get()->module_config('mywords'); $day = date('d', $this->getVar('pubdate')); $month = date('m', $this->getVar('pubdate')); $year = date('Y', $this->getVar('pubdate')); $rtn = MWFunctions::get_url(); $rtn .= $mc['permalinks'] == 1 ? '?post=' . $this->id() : ($mc['permalinks'] == 2 ? "{$day}/{$month}/{$year}/" . $this->getVar('shortname', 'n') . "/" : "post/" . $this->id()); return $rtn; }
/** * Muestra las características existentes de una descarga */ function dt_show_files($edit = 0) { global $xoopsOption, $db, $tpl, $xoopsTpl, $xoopsUser, $mc, $dtfunc, $page, $item, $xoopsConfig, $xoopsModuleConfig, $file; include 'header.php'; $dtfunc->cpHeader($item, sprintf(__('%s files', 'dtransport'), $item->getVar('name'))); if ($file > 0 && $edit) { $file = new DTFile($file); if ($file->isNew() || $file->software() != $item->id()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/' : '/?p=cpanel&action=files&id=' . $item->id()), 1, __('Specified feature does not exists!', 'dtransport')); } } $tc = TextCleaner::getInstance(); $tf = new RMTimeFormatter('', "%m%/%d%/%Y% %h%:%i%"); $rmu = RMUtilities::get(); $tfiles = $db->prefix('dtrans_files'); $tgroup = $db->prefix('dtrans_groups'); $sql = "SELECT * FROM {$tfiles} WHERE id_soft=" . $item->id(); $gcache = array(); $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $fl = new DTFile(); $fl->assignVars($rows); if (!isset($gcache[$fl->group()])) { $gcache[$fl->group()] = new DTFileGroup($fl->group()); } $group = $gcache[$fl->group()]; $xoopsTpl->append('files', array('id' => $fl->id(), 'title' => $fl->title(), 'date' => $tf->format($fl->date()), 'software' => $item->getVar('name'), 'remote' => $fl->remote(), 'size' => $rmu->formatBytesSize($fl->size()), 'hits' => $fl->hits(), 'date' => $tf->format($fl->date()), 'group' => $group->isNew() ? '' : $group->name(), 'links' => array('edit' => DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->getVar('nameid') . '/edit/' . $fl->id() . '/' : '/?p=cpanel&id=' . $item->id() . '&action=files&feature=' . $fl->id()), 'delete' => DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->getVar('nameid') . '/delete/' . $fl->id() . '/' : '/?p=cpanel&id=' . $item->id() . '&action=delete&feature=' . $fl->id())))); } $formurl = DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/save/' . ($edit ? $file->id() : '0') . '/' : '/p=cpanel'); // files Form $form = new RMForm($edit ? sprintf(__('Editing file of "%s"', 'dtransport'), $item->getVar('name')) : sprintf(__('New file for "%s"', 'dtransport'), $item->getVar('name')), 'frmFile', $formurl); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new RMFormLabel(__('Download item', 'dtransport'), $item->getVar('name'))); $form->addElement(new RMFormText(__('File title', 'dtransport'), 'title', 50, 200, $edit ? $file->title() : ''), true); //Lista de grupos $sql = "SELECT * FROM " . $db->prefix('dtrans_groups') . " WHERE id_soft=" . $item->id(); $result = $db->query($sql); $groups = array(); while ($rows = $db->fetchArray($result)) { $group = new DTFileGroup(); $group->assignVars($rows); $groups[] = array('id' => $group->id(), 'name' => $group->name()); } $ele = new RMFormSelect(__('Group', 'dtransport'), 'group', 0, $edit ? $file->group() : ''); $ele->addOption('', __('Select group...', 'dtransport')); foreach ($groups as $group) { $ele->addOption($group['id'], $group['name']); } $form->addElement($ele); $form->addElement(new RMFormYesNo(__('Default file', 'dtransport'), 'default', $edit ? $file->isDefault() : 0)); $form->addElement(new RMFormYesNo(__('Remote file', 'dtransport'), 'remote', $edit ? $file->remote() : 0)); $form->addElement(new RMFormFile(__('File', 'dtransport'), 'thefile', 50, $xoopsModuleConfig['size_file'] * 1024 * 1024)); if ($edit) { $form->addElement(new RMFormLabel(__('Current file', 'dtransport'), $file->file())); } $form->addElement(new RMFormText(__('File URL', 'dtransport'), 'url', 50, 200, $edit ? $file->title() : ''))->setDescription(__('Used only when remote file is activated.', 'dtransport')); $form->addElement(new RMFormHidden('action', 'save')); $form->addElement(new RMFormHidden('id', $item->id())); $form->addElement(new RMFormHidden('file', $edit ? $file->id() : 0)); $form->addElement(new RMFormHidden('op', 'save')); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', $edit ? __('Save Changes', 'dtransport') : __('Save File', 'dtransport'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'dtransport'), 'button', 'onclick="window.location=\'' . (DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/' : '/?p=cpanel&action=files&id=' . $item->id())) . '\';"'); $form->addElement($buttons); $xoopsTpl->assign('file_form', $form->render()); $tpl->add_xoops_style('cpanel.css', 'dtransport'); $tpl->add_head_script('$(document).ready(function(){ $("a.delete").click(function(){ if(!confirm("' . __('Do you really want to delete selected file?', 'dtransport') . '")) return false; }); });'); $xoopsTpl->assign('lang_id', __('ID', 'dtransport')); $xoopsTpl->assign('lang_title', __('Title', 'dtransport')); $xoopsTpl->assign('lang_group', __('Group', 'dtransport')); $xoopsTpl->assign('lang_remote', __('Remote', 'dtransport')); $xoopsTpl->assign('lang_size', __('Size', 'dtransport')); $xoopsTpl->assign('lang_hits', __('Hits', 'dtransport')); $xoopsTpl->assign('lang_date', __('Date', 'dtransport')); $xoopsTpl->assign('lang_edit', __('Edit', 'dtransport')); $xoopsTpl->assign('lang_delete', __('Delete', 'dtransport')); $xoopsTpl->assign('lang_addfile', __('Add File', 'dtransport')); $xoopsTpl->assign('edit', $edit); include 'footer.php'; }
/** * 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); }
public function render() { $util = RMUtilities::get(); return $util->image_manager($this->getName(), $this->default); }
<?php } ?> </div> </div> </div> <!--// The content --> </div> <!-- Footer --> <div id="des-footer"> <?php echo sprintf(__('Powered by %s.', 'designia'), '<a href="http://xoops.org">' . XOOPS_VERSION . '</a>'); ?> <?php echo sprintf(__('Reloaded by %s.', 'designia'), '<a href="http://www.redmexico.com.mx/w/common-utilities/">' . RMUtilities::get()->getVersion(true, 'rmcommon') . '</a>'); ?> <br /> <?php echo sprintf(__('Using %s.', 'designia'), '<strong>Designia Theme</strong>'); ?> <!--{xo-logger-output}--> </div> <!--// Footer --> <span id="xtoken"><?php echo $xoopsSecurity->createToken(); ?> </span>
/** * @desc Obtiene la URL al usuario * @return string */ public function userURL() { global $xoopsModule, $xoopsModuleConfig; if ($this->_url != '') { return $this->_url; } if (isset($xoopsModule) && $xoopsModule->dirname() == 'galleries') { $mc =& $xoopsModuleConfig; } else { $mc =& RMUtilities::get()->module_config('galleries'); } $url = GSFunctions::get_url(); $url .= $mc['urlmode'] ? 'usr/' . $this->uname() . "/" : "?usr=" . $this->uname(); $this->_url = $url; return $url; }
// D-Transport // Manage files for download in XOOPS // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- require '../../mainfile.php'; //include 'header.php'; $mc = $xoopsModuleConfig; // Constantes del Módulo define('DT_PATH', XOOPS_ROOT_PATH . '/modules/dtransport'); define('DT_URL', $mc['permalinks'] ? XOOPS_URL . '/' . trim($mc['htbase'], "/") : XOOPS_URL . '/modules/dtransport'); // Xoops Module Header $dtfunc = new DTFunctions(); $rmf = RMFunctions::get(); $rmu = RMUtilities::get(); $url = $rmf->current_url(); $rpath = parse_url($url); $xpath = parse_url(XOOPS_URL); // Comprobar si el host es correcto if ($rpath['host'] != $xpath['host']) { /** * @todo Agregar header 303 */ header("location: " . DT_URL); die; } if (substr($rpath['path'], 0, strlen($xpath['path'])) != $xpath['path']) { $dtfunc->error_404(); } if ($mc['permalinks']) {
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; }
public function on_uninstall() { $rmu = RMUtilities::get(); $rmu->delete_directory(XOOPS_CACHE_PATH . '/minifier'); return true; }
<?php // $Id$ // -------------------------------------------------------------- // Equipo Club Gallos // Un modulo sencillo para el manejo de equipos // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- include '../../header.php'; $mc =& $xoopsModuleConfig; $util =& RMUtilities::get(); $myts =& MyTextSanitizer::getInstance(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tpl = $xoopsTpl; // Constantes define('TC_PATH', XOOPS_ROOT_PATH . '/modules/team'); define('TC_URL', XOOPS_URL . '/modules/team'); $tpl->assign('tc_url', TC_URL); $xmh = "\n<link href='" . TC_URL . "/styles/main.css' rel='stylesheet' type='text/css' media='all' />\n";
function download_file() { global $xoopsLogger, $rmTpl, $runFiles, $xoopsSecurity; $xoopsLogger->activated = false; $url = RMHttpRequest::post('url', 'string', ''); $cred = RMHttpRequest::post('credentials', 'string', ''); $type = RMHttpRequest::post('type', 'string', ''); $dir = RMHttpRequest::post('dir', 'string', ''); $ftpdata = RMHttpRequest::post('ftp', 'string', ''); if ($url == '') { jsonReturn(__('Invalid parameters!', 'rmcommon')); } // Request access $query = explode("?", $url); $query[1] = ($query[1] != '' ? $query[1] . '&' : '') . 'action=identity' . ($cred != '' ? '&l=' . $cred : ''); $response = json_decode(RMHttpRequest::load_url($query[0], $query[1], true), true); //$response = json_decode(file_get_contents($url.'&), true); if ($response['error'] == 1) { jsonReturn($response['message']); } //jsonReturn($response['data']['url']); if (!is_dir(XOOPS_CACHE_PATH . '/updates/')) { mkdir(XOOPS_CACHE_PATH . '/updates/', 511); } if (!file_put_contents(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip', file_get_contents($response['data']['url']))) { jsonReturn(__('Unable to download update file!', 'rmcommon')); } // Get files list $details = json_decode(RMHttpRequest::load_url($url . '&action=update-details', '', true), true); if ($details['error'] == 1) { jsonReturn($details['message']); } $hash = $details['data']['hash']; $file_hash = md5_file(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip'); if ($hash != $file_hash) { @unlink(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip'); jsonReturn(__('The package file could be corrupted. Aborting!', 'rmcommon')); } // Extract files $zip = new ZipArchive(); $res = $zip->open(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip'); if ($res !== TRUE) { jsonReturn(__('ERROR: unable to open downloaded zip file!', 'rmcommon')); } $rmUtil = RMUtilities::get(); $source = XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir; if (is_dir($source)) { $rmUtil->delete_directory($source); } $zip->extractTo($source); $zip->close(); // Delete downloaded zip unlink(XOOPS_CACHE_PATH . '/updates/' . $type . '-' . $dir . '.zip'); // Prepare to copy files $target = XOOPS_ROOT_PATH . '/modules/'; if ($type == 'plugin') { $target .= 'rmcommon/plugins/' . $dir; } else { $target .= $dir; } if (!is_dir($target)) { jsonReturn(sprintf(__('Target path "%s" does not exists!', 'rmcommon'), $target)); } /** * When rmcommon is the module to be updated then we need * to make a backup before to delete files */ $excluded = array(); if ($dir == 'rmcommon') { $excluded = array($target . '/plugins'); } if (is_writable($target) && !empty($target)) { $target = str_replace('\\', '/', $target); // Deletes dir content to replace with new files RMUtilities::delete_directory($target, false, $excluded); // Copy new files $source = rtrim(str_replace('\\', '/', $source), '/'); $odir = opendir($source); while (($file = readdir($odir)) !== false) { if ($file == '.' || $file == '..') { continue; } @rename($source . '/' . $file, $target . '/' . $file); } closedir($odir); RMUtilities::delete_directory($source); } else { if ($ftpdata == '') { jsonReturn(__('FTP configuration not specified!', 'rmcommon')); } parse_str($ftpdata); if ($ftp_server == '' || $ftp_user == '' || $ftp_pass == '') { jsonReturn(__('FTP configuration not valid!', 'rmcommon')); } $target = str_replace('\\', '/', $target); global $ftpConfig; $ftpConfig->server = $ftp_server; $ftpConfig->user = $ftp_user; $ftpConfig->pass = $ftp_pass; $ftpConfig->dir = $ftp_dir; $ftpConfig->port = $ftp_port > 0 ? $ftp_port : 21; $ftp = new RMFtpClient($ftp_server, $ftp_port > 0 ? $ftp_port : 21, $ftp_user, $ftp_pass); if (!$ftp->connect()) { jsonReturn(sprintf(__('Unable to connect FTP server %s', 'rmcommon'), '<strong>' . $ftp_server . '</strong>')); } $ftpConfig->base = $ftpConfig->dir . '/modules/' . ($type == 'plugin' ? 'rmcommon/plugins/' : '') . $dir; $ftpConfig->source = $source; $ftpConfig->target = $target; // Clean current element directory deleteFTPDir($ftpConfig->base, $ftp, false); // Copy new files } // Update uploads file $updates = unserialize(base64_decode(file_get_contents(XOOPS_CACHE_PATH . '/updates.chk'))); $new = array(); foreach ($updates['updates'] as $upd) { if ($upd['data']['type'] == $type && $upd['data']['dir'] == $dir) { continue; } $new[] = $upd; } file_put_contents(XOOPS_CACHE_PATH . '/updates.chk', base64_encode(serialize(array('date' => $updates['date'], 'total' => intval($updates['total']) - 1, 'updates' => $new)))); if (!empty($runFiles)) { jsonReturn(__('Executing files...', 'rmcommon'), 0, array('run' => json_encode($runFiles))); } else { jsonReturn(sprintf(__('%s has been updated', 'rmcommon'), '<strong>' . $dir . '</strong>'), 0); } }
/** * Get the permalink for item * @param int Determines if returned link will be formated to edition * @param string Indicate the type of permalink that will be returned (empty, download, screens, features, logs) * @return string */ public function permalink($edit = 0, $type = '') { $util = RMUtilities::get(); $mc = $util->module_config('dtransport'); $allowed = array('download', 'screens', 'features', 'logs'); if ($mc['permalinks']) { if ($edit) { $link = XOOPS_URL . '/' . trim($mc['htbase'], '/') . '/<span><em>' . $this->getVar('nameid') . '</em></span>/'; } elseif ($type == '' || in_array($type, $allowed)) { $link = XOOPS_URL . '/' . trim($mc['htbase'], '/') . '/' . $this->getVar('nameid') . '/' . ($type != '' ? $type . '/' : ''); } else { $link = XOOPS_URL . '/' . trim($mc['htbase'], '/') . '/' . $this->getVar('nameid') . '/'; } } else { if ($type == '' || in_array($type, $allowed)) { $link = XOOPS_URL . '/modules/dtransport/item.php?id=' . $this->id() . ($type != '' ? '&action=' . $type : ''); } else { $link = XOOPS_URL . '/modules/dtransport/getfile.php?id=' . $this->id(); } } return $link; }
/** * @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(); }
/** * Get correct base url for links */ function get_url($track = false) { global $xoopsModule, $xoopsModuleConfig; if (!$xoopsModule || $xoopsModule->dirname() != 'mywords') { $mc = RMUtilities::get()->module_config('mywords'); } else { $mc = $xoopsModuleConfig; } if ($mc['permalinks'] > 1) { $ret = XOOPS_URL . rtrim($mc['basepath'], "/") . '/'; if ($track) { $ret .= 'trackback/'; } } else { $ret = XOOPS_URL . '/modules/mywords/'; if ($track) { $ret .= 'trackbacks.php?trackback='; } } return $ret; }
public function permalink() { $util = RMUtilities::get(); $mc = $util->module_config('dtransport'); if (!$mc['permalinks']) { return XOOPS_URL . '/modules/dtransport/category.php?id=' . $this->id(); } if ($this->parent() <= 0) { return XOOPS_URL . '/' . trim($mc['htbase'], '/') . '/category/' . $this->nameId() . '/'; } $func = new DTFunctions(); $path[] = $this->nameId(); $path = array_merge($path, $func->category_path($this->parent())); $path = array_reverse($path, true); return XOOPS_URL . '/' . trim($mc['htbase'], '/') . '/category/' . implode("/", $path) . '/'; }
/** * Obtiene el enlace directo a la característica */ public function permalink() { $util = RMUtilities::get(); $mc = $util->module_config('dtransport'); if ($mc['permalinks']) { return DT_URL . '/feature/' . $this->id() . '/'; } else { return DT_URL . '/?p=feature&id=' . $this->id(); } }
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(); }