/** * @desc Visualiza todos los logs existentes para un determinado software **/ function showLogs() { global $tpl, $xoopsConfig, $xoopsModule, $functions, $xoopsSecurity; define('RMCSUBLOCATION', 'itemlogs'); $item = isset($_REQUEST['item']) ? intval($_REQUEST['item']) : 0; $sw = new DTSoftware($item); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tc = TextCleaner::getInstance(); $tf = new RMTimeFormatter(0, __('%m%-%d%-%Y%', 'dtransport')); $sql = "SELECT * FROM " . $db->prefix('dtrans_logs') . " WHERE id_soft={$item}"; $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $log = new DTLog(); $log->assignVars($rows); $logs[] = array('id' => $log->id(), 'title' => $log->title(), 'log' => $tc->truncate($tc->clean_disabled_tags($log->log()), 80), 'date' => $tf->format($log->date())); } xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./items.php'>" . sprintf(_AS_DT_SW, $sw->getVar('name')) . "</a> » " . _AS_DT_LOGS); $functions->toolbar(); $tpl->add_style('admin.css', 'dtransport'); $tpl->add_local_script('admin.js', 'dtransport'); $tpl->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); include DT_PATH . '/include/js_strings.php'; xoops_cp_header(); include $tpl->get_template('admin/dtrans_logs.php', 'module', 'dtransport'); xoops_cp_footer(); }
/** * To prevent errors when upload images with closed site */ public function eventCoreIncludeCommonLanguage() { global $xoopsConfig; if ($xoopsConfig['cpanel'] != 'redmexico') { $db = XoopsDatabaseFactory::getDatabaseConnection(); $db->queryF("UPDATE " . $db->prefix("config") . " SET conf_value='redmexico' WHERE conf_modid=0 AND conf_catid=1 AND conf_name='cpanel'"); } /** * Check before to a rmcommon native module be installed */ $fct = RMHttpRequest::get('fct', 'string', ''); $op = RMHttpRequest::get('op', 'string', ''); if ('modulesadmin' == $fct && 'install' == $op) { $dirname = RMHttpRequest::get('module', 'string', ''); if ('' != $dirname) { $module = new XoopsModule(); $module->loadInfoAsVar($dirname); if ($module->getInfo('rmnative')) { RMUris::redirect_with_message(__('Please install %s using the modules manager from Common Utilities to prevent errors during install.', 'rmcommon'), RMCURL . '/modules.php?action=install&dir=' . $dirname, RMMSG_WARN); } } } if (RMUris::current_url() == RMCURL . '/include/upload.php' && $xoopsConfig['closesite']) { $security = rmc_server_var($_POST, 'rmsecurity', 0); $data = TextCleaner::getInstance()->decrypt($security, true); $data = explode("|", $data); // [0] = referer, [1] = session_id(), [2] = user, [3] = token $xoopsUser = new XoopsUser($data[0]); if ($xoopsUser->isAdmin()) { $xoopsConfig['closesite'] = 0; } } RMEvents::get()->run_event('rmcommon.include.common.language'); }
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; }
/** * @desc Almacena la información de las plataformas **/ function savePlatforms($edit = 0) { global $xoopsSecurity; foreach ($_POST as $k => $v) { ${$k} = $v; } if (!$xoopsSecurity->check()) { redirectMsg('Session token expired!', 'dtransport'); } $db = XoopsDatabaseFactory::getDatabaseConnection(); $tc = TextCleaner::getInstance(); $nameid = $tc->sweetstring($name); if ($edit) { //Verificamos si plataforma es válida if ($id <= 0) { redirectMsg('platforms.php', __('You must specify a valid platform ID!', 'dtrasnport'), 1); die; } //Verificamos si plataforma existe $plat = new DTPlatform($id); if ($plat->isNew()) { redirectMsg('platforms.php', __('Specified platform does not exists!', 'dtransport'), 1); die; } //Comprueba que la plataforma no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_platforms') . " WHERE (name='{$name}' OR nameid='{$nameid}') AND id_platform<>" . $plat->id(); list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirectMsg('platforms.php', __('Another platform with same name already exists!', 'dtransport'), 1); die; } } else { //Comprueba que la plataforma no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_platforms') . " WHERE name='{$name}' OR nameid='{$nameid}'"; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirectMsg('platforms.php', __('Another platform with same name already exists!', 'dtransport'), 1); die; } $plat = new DTPlatform(); } $plat->setName($name); $plat->setNameId($nameid); if (!$plat->save()) { redirectMsg('platforms.php', __('Database could not be updated!', 'dtransport') . '<br />' . $plat->errors(), 1); die; } else { redirectMsg('./platforms.php', __('Platform saved successfully!', 'dtransport'), 0); die; } }
/** * @param string $caption Texto del campo * @param string $name Nombre de este campo * @param string $width Ancho del campo. Puede ser el valor en formato pixels (300px) o en porcentaje (100%) * @param string $height Alto de campo. El valor debe ser pasado en formato pixels (300px). * @param string $default Texto incial al cargar el campo. POr defecto se muestra vaco. * @param string $type Tipo de Editor. Posibles valores: FCKeditor, DHTML */ function __construct($caption, $name, $width = '100%', $height = '300px', $default = '', $type = '', $change = 1, $ele = array('op')) { $rmc_config = RMFunctions::get()->configs(); $tcleaner = TextCleaner::getInstance(); $this->setCaption($caption); $this->setName($name); $this->_width = $width; $this->_height = $height; $this->_default = isset($_REQUEST[$name]) ? $tcleaner->stripslashes($_REQUEST[$name]) : $tcleaner->stripslashes($default); $this->_type = $type == '' ? $rmc_config['editor_type'] : $type; $this->_type = strtolower($this->_type); $this->_change = $change; $this->_eles = $ele; }
/** * To prevent errors when upload images with closed site */ public function eventCoreIncludeCommonLanguage() { global $xoopsConfig; if (RMFunctions::current_url() == RMCURL . '/include/upload.php' && $xoopsConfig['closesite']) { $security = rmc_server_var($_POST, 'rmsecurity', 0); $data = TextCleaner::getInstance()->decrypt($security, true); $data = explode("|", $data); // [0] = referer, [1] = session_id(), [2] = user, [3] = token $xoopsUser = new XoopsUser($data[0]); if ($xoopsUser->isAdmin()) { $xoopsConfig['closesite'] = 0; } } }
function rd_show_page() { RMTemplate::get()->assign('xoops_pagetitle', __('Home Page', 'docs')); xoops_cp_header(); include_once RMCPATH . '/class/form.class.php'; $content = @file_get_contents(XOOPS_CACHE_PATH . '/rd_homepage.html'); $content = TextCleaner::getInstance()->to_display($content); $editor = new RMFormEditor('', 'homepage', '100%', '450px', $content); $rmc_config = RMFunctions::configs(); if ($rmc_config['editor_type'] == 'tiny') { $tiny = TinyEditor::getInstance(); $tiny->add_config('theme_advanced_buttons1', 'res_index'); } include RMEvents::get()->run_event('docs.get.homepage.template', RMTemplate::get()->get_template('admin/rd_homepage.php', 'module', 'docs')); xoops_cp_footer(); }
function mywordsBlockRecent($options) { global $xoopsModuleConfig, $xoopsModule, $xoopsUser; $mc = RMSettings::module_settings('mywords'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $by = ''; switch ($options[1]) { case 'recent': $by = 'pubdate'; break; case 'popular': $by = "`reads`"; break; case 'comm': $by = "`comments`"; break; } $posts = MWFunctions::get_posts_by_cat($options[5], 0, $options[0], $by, 'DESC'); $block = array(); foreach ($posts as $post) { $ret = array(); $ret['id'] = $post->id(); $ret['title'] = $post->getVar('title'); $ret['link'] = $post->permalink(); // Content if ($options[2]) { $ret['content'] = TextCleaner::getInstance()->truncate($post->content(true), $options[3]); } // Pubdate if ($options[4]) { $ret['date'] = formatTimestamp($post->getVar('pubdate'), 'c'); } // Show reads if ($options[1] == 'popular') { $ret['hits'] = sprintf(__('%u Reads', 'mywords'), $post->getVar('reads')); } elseif ($options[1] == 'comm') { $ret['comments'] = sprintf(__('%u Comments', 'mywords'), $post->getVar('comments')); } $ret['time'] = $post->getVar('pubdate'); $ret['image'] = RMIMage::get()->load_from_params($post->image); $block['posts'][] = $ret; } RMTemplate::get()->add_style('mwblocks.css', 'mywords'); return $block; }
/** * @desc Realiza una búsqueda en el módulo desde EXM */ function bxpressSearch($queryarray, $andor, $limit, $offset, $userid = 0) { global $myts, $module; $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbl1 = $db->prefix("mod_bxpress_topics"); $tbl2 = $db->prefix("mod_bxpress_posts_text"); $tbl3 = $db->prefix("mod_bxpress_posts"); if ($userid <= 0) { $sql = "SELECT a.*,b.*,c.* FROM {$tbl1} a, {$tbl2} b, {$tbl3} c "; $sql1 = ''; foreach ($queryarray as $k) { $sql1 .= ($sql1 == '' ? '' : " {$andor} ") . " (\n \t (a.title LIKE '%{$k}%' AND a.id_topic=c.id_topic) OR \n \t (b.post_text LIKE '%{$k}%' AND b.post_id=c.id_post))"; } $sql .= $sql1 != '' ? "WHERE {$sql1}" : ''; $sql .= $userid > 0 ? "GROUP BY c.id_topic" : " GROUP BY c.id_topic"; $sql .= " ORDER BY c.post_time DESC LIMIT {$offset}, {$limit}"; $result = $db->queryF($sql); } else { $sql = "SELECT a.*, b.*, c.post_text FROM {$tbl3} a, {$tbl1} b, {$tbl2} c WHERE a.uid='{$userid}' AND b.id_topic=a.id_topic \n AND c.post_id=a.id_post "; $sql1 = ''; foreach ($queryarray as $k) { $sql1 .= ($sql1 == '' ? 'AND ' : " {$andor} ") . "\n b.title LIKE '%{$k}%' AND c.post_text LIKE '%{$k}%'"; } $sql .= $sql1; $sql .= "ORDER BY a.post_time DESC\n LIMIT {$offset}, {$limit}"; $result = $db->query($sql); } include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxpost.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxfunctions.class.php'; $tc = TextCleaner::getInstance(); $ret = array(); while ($row = $db->fetchArray($result)) { $post = new bXPost(); $post->assignVars($row); $rtn = array(); $rtn['image'] = 'images/forum16.png'; $rtn['link'] = $post->permalink(); $rtn['title'] = $row['title']; $rtn['time'] = $row['post_time']; $rtn['uid'] = $row['uid']; $rtn['desc'] = substr($tc->clean_disabled_tags($row['post_text']), 0, 150) . '...'; $ret[] = $rtn; } return $ret; }
function xt_show_menus() { global $xtAssembler, $xtFunctions; $tc = TextCleaner::getInstance(); $menus = $xtAssembler->rootMenus(); if (!$menus) { redirectMsg('themes.php', __('This theme does not support xThemes menus!', 'xthemes'), RMMSG_WARN); } $theme_menu = $xtAssembler->menu(); $tpl = RMTemplate::get(); $tpl->add_local_script('jquery.nestedSortable.js', 'xthemes'); $tpl->add_local_script('json_encode.js', 'xthemes'); $tpl->add_head_script("var lang_delete = '" . __('Do you really want to delete selected menu?', 'xthemes') . "';"); $tpl->add_local_script('xthemes.js', 'xthemes'); $tpl->assign('xoops_pagetitle', __('Theme menus', 'xthemes')); xoops_cp_header(); include $tpl->get_template('xt_navigation.php', 'module', 'xthemes'); xoops_cp_footer(); }
/** * @des Visualiza todas las pantallas existentes **/ function showScreens() { global $xoopsModule, $xoopsSecurity, $tpl, $functions, $xoopsModule, $xoopsModuleConfig, $xoopsUser, $xoopsConfig; define('RMCSUBLOCATION', 'screenshots'); if ($xoopsConfig['closesite']) { showMessage(__('Screenshop uploader does not work when site is closed. Before to start uploding, please change this configuration.', 'rmcommon'), RMMSG_WARN); } $db = XoopsDatabaseFactory::getDatabaseConnection(); $tc = TextCleaner::getInstance(); $item = rmc_server_var($_REQUEST, 'item', 0); if ($item <= 0) { redirectMsg('items.php', __('Download item ID not provided!', 'dtransport'), RMMSG_WARN); } $sw = new DTSoftware($item); $sql = "SELECT * FROM " . $db->prefix('dtrans_screens') . " WHERE id_soft={$item}"; $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $sc = new DTScreenshot(); $sc->assignVars($rows); $screens[] = array('id' => $sc->id(), 'title' => $sc->title(), 'desc' => substr($tc->clean_disabled_tags($sc->desc()), 0, 80) . "...", 'image' => XOOPS_UPLOAD_URL . '/screenshots/' . date('Y', $sc->date()) . '/' . date('m', $sc->date()) . '/ths/' . $sc->image()); } // CSS Styles $tpl->add_style('admin.css', 'dtransport'); $tpl->add_style('screens.css', 'dtransport'); $tpl->add_style('uploadify.css', 'rmcommon'); // Javascripts $tpl->add_local_script('swfobject.js', 'rmcommon', 'include'); $tpl->add_local_script('jquery.uploadify.js', 'rmcommon', 'include'); $tpl->add_local_script('screens.js', 'dtransport'); $tc = TextCleaner::getInstance(); $rmf = RMFunctions::get(); ob_start(); include DT_PATH . '/js/screenshots.js'; $script = ob_get_clean(); $tpl->add_head_script($script); $functions->toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='items.php'>" . __('Downloads', 'dtransport') . "</a> » " . __('Screenshots Management', 'dtransport')); $tpl->assign('xoops_pagetitle', sprintf(__("%s Screenshots", 'dtransport'), $sw->getVar('name'))); include DT_PATH . '/include/js_strings.php'; xoops_cp_header(); include $tpl->get_template('admin/dtrans_screens.php', 'module', 'dtransport'); xoops_cp_footer(); }
/** * @param string $caption Texto del campo * @param string $name Nombre de este campo * @param string $width Ancho del campo. Puede ser el valor en formato pixels (300px) o en porcentaje (100%) * @param string $height Alto de campo. El valor debe ser pasado en formato pixels (300px). * @param string $default Texto incial al cargar el campo. POr defecto se muestra vaco. * @param string $type Tipo de Editor. Posibles valores: tiny, html, xoops, simple, markdown */ function __construct($caption, $name = null, $width = '100%', $height = '300px', $default = '', $type = '', $change = 1, $ele = array('op')) { $rmc_config = RMSettings::cu_settings(); $tcleaner = TextCleaner::getInstance(); if (is_array($caption)) { parent::__construct($caption); } else { parent::__construct([]); $this->setWithDefaults('caption', $caption, ''); $this->setWithDefaults('name', $name, ''); $this->setWithDefaults('id', $tcleaner->sweetstring($name), ''); $this->setWithDefaults('width', $width, '100%'); $this->setWithDefaults('height', $height, '300px'); $this->setWithDefaults('value', isset($_REQUEST[$name]) ? $tcleaner->stripslashes($_REQUEST[$name]) : $tcleaner->stripslashes($default), ''); $this->setWithDefaults('type', $type, $rmc_config->editor_type); $this->setWithDefaults('change', $change, 1); $this->setWithDefaults('elements', $ele, array('op')); } $this->setIfNotSet('type', $type == '' ? $rmc_config->editor_type : $type); $this->setIfNotSet('value', ''); }
/** * @desc Muestra la lista de los anuncios existentes */ function showAnnounces() { global $db, $xoopsModule, $xoopsSecurity; $result = $db->query("SELECT * FROM " . $db->prefix("bxpress_announcements") . " ORDER BY date"); $announcements = array(); while ($row = $db->fetchArray($result)) { $an = new bXAnnouncement(); $an->assignVars($row); $announcements[] = array('id' => $an->id(), 'text' => TextCleaner::getInstance()->truncate($an->text(), 100), 'date' => formatTimestamp($an->date()), 'expire' => formatTimeStamp($an->expire()), 'where' => constant('BX_FWHERE' . $an->where()), 'wherelink' => $an->where() == 1 ? '../forum.php?id=' . $an->forum() : '../', 'by' => $an->byName()); } $announcements = RMEvents::get()->run_event('bxpress.announcements.list', $announcements); RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/anuncios/standalone/1/'); bXFunctions::menu_bar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('Announcements Management', 'bxpress')); xoops_cp_header(); RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); RMTemplate::get()->add_style('admin.css', 'bxpress'); RMTemplate::get()->add_local_script('admin.js', 'bxpress'); include RMTemplate::get()->get_template("admin/forums_announcements.php", 'module', 'bxpress'); xoops_cp_footer(); }
/** * @desc Muestra la lista de los anuncios existentes */ function showAnnounces() { global $db, $xoopsModule, $xoopsSecurity; $result = $db->query("SELECT * FROM " . $db->prefix("mod_bxpress_announcements") . " ORDER BY date"); $announcements = array(); while ($row = $db->fetchArray($result)) { $an = new bXAnnouncement(); $an->assignVars($row); $announcements[] = array('id' => $an->id(), 'text' => TextCleaner::getInstance()->truncate($an->text(), 100), 'date' => formatTimestamp($an->date()), 'expire' => formatTimeStamp($an->expire()), 'where' => constant('BX_FWHERE' . $an->where()), 'wherelink' => $an->where() == 1 ? '../forum.php?id=' . $an->forum() : '../', 'by' => $an->byName()); } $announcements = RMEvents::get()->run_event('bxpress.announcements.list', $announcements); RMTemplate::get()->add_help(__('Announcements Help', 'bxpress'), '#'); $bc = RMBreadCrumb::get(); $bc->add_crumb(__('Announcements Management', 'bxpress')); xoops_cp_header(); RMTemplate::get()->add_script('jquery.checkboxes.js', 'rmcommon', array('directory' => 'include')); RMTemplate::get()->add_style('admin.css', 'bxpress'); RMTemplate::get()->add_script('admin.js', 'bxpress'); include RMTemplate::get()->get_template("admin/forums-announcements.php", 'module', 'bxpress'); xoops_cp_footer(); }
/** * @desc Realiza una búsqueda en el módulo desde EXM */ function ahelpSearch($queryarray, $andor, $limit, $offset, $userid) { global $myts; include_once XOOPS_ROOT_PATH . "/modules/docs/class/rdsection.class.php"; include_once XOOPS_ROOT_PATH . "/modules/docs/class/rdresource.class.php"; $mc = RMUtilities::module_config('docs'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbl1 = $db->prefix("rd_resources"); $tbl2 = $db->prefix("rd_sections"); $sql = "SELECT a.id_res,a.title,a.description,a.created,a.modified,a.public,a.nameid,a.owner,a.owname,a.approved,b.id_sec,b.title AS stitle,b.content,b.id_res AS sid_res,\n\tb.nameid AS snameid,b.uid,b.uname,b.created AS screated FROM {$tbl1} a, {$tbl2} b "; $sql1 = ''; foreach ($queryarray as $k) { $sql1 .= ($sql1 == '' ? '' : " {$andor} ") . " (a.id_res=b.id_res) AND (\n \t (b.title LIKE '%{$k}%' AND b.id_res=a.id_res) OR \n \t (b.content LIKE '%{$k}%' AND b.id_res=a.id_res))"; } $sql .= $sql1 != '' ? "WHERE {$sql1}" : ''; $sql .= " AND approved=1 AND public=1 ORDER BY a.modified DESC LIMIT {$offset}, {$limit}"; $result = $db->queryF($sql); $ret = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $sec = new RDSection(); $sec->assignVars($row); $sec->assignVar('title', $row['stitle']); $sec->assignVar('id_res', $row['sid_res']); $sec->assignVar('nameid', $row['snameid']); $sec->assignVar('created', $row['screated']); $rtn = array(); $rtn['image'] = 'images/result.png'; $rtn['link'] = $sec->permalink(); $rtn['title'] = $sec->getVar('title'); $rtn['time'] = $sec->getVar('created'); $rtn['uid'] = $sec->getVar('uid'); $rtn['desc'] = TextCleaner::getInstance()->truncate($sec->getVar('content'), 150); $ret[] = $rtn; } return $ret; }
/** * Get all figures list according to given parameters * @param int Resource ID * @param Referenced var to return results count * @param string Search keyword * @param int Start results * @param int Results number limit * @return array */ public function figures($res = 0, &$count, $search = '', $start = 0, $limit = 15) { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_figures') . ($res > 0 ? " WHERE id_res='{$res}'" : ''); if ($search != '') { $sql .= ($res > 0 ? " AND " : " WHERE ") . " (desc LIKE '%{$k}%' OR content LIKE '%{$k}%')"; } if ($res > 0) { $res = new RDResource($res); } list($num) = $db->fetchRow($db->query($sql)); $limit = $limit <= 0 ? 15 : $limit; $count = $num; //Fin de navegador de páginas $sql = str_replace("COUNT(*)", "*", $sql); $sql .= " ORDER BY id_fig DESC LIMIT {$start},{$limit}"; $result = $db->query($sql); $figures = array(); while ($rows = $db->fetchArray($result)) { $ref = new RDFigure(); $ref->assignVars($rows); if ($res->isNew()) { $res = new RDResource($ref->resource()); } $figures[] = array('id' => $ref->id(), 'title' => $ref->getVar('title'), 'desc' => $ref->getVar('desc'), 'content' => substr(TextCleaner::getInstance()->clean_disabled_tags($ref->getVar('content')), 0, 50) . "...", 'resource' => $res->getVar('title')); } return $figures; }
/** * Esta función permite guardar y publicar un envío */ function savePage($edit = 0) { global $xoopsSecurity, $xoopsUser, $myts, $mc, $xoopsModule; $cat = 0; $url = ''; $texto = ''; foreach ($_POST as $k => $v) { ${$k} = $v; } $q = "op=" . ($edit ? 'edit&id=' . $id : 'new') . "&cat={$cat}&page={$page}"; if ($edit) { if ($id <= 0) { redirectMsg("pages.php?cat={$cat}&page={$page}", __('Page ID has not been provided', 'qpages'), 1); die; } $page = new QPPage($id); if ($page->isNew()) { redirectMsg("pages.php?cat={$cat}&page={$page}", __('Specified page does not exists!', 'qpages'), 1); die; } } else { $page = new QPPage(); } if (!$xoopsSecurity->check()) { redirectMsg("pages.php?{$q}", __('Session token expired!', 'qpages'), 1); die; } if ($titulo == '') { redirectMsg("pages.php?{$q}", __('Title is missing', 'qpages'), 1); die; } if (isset($pretitulo)) { if ($pretitulo != $titulo) { $titulo_amigo = TextCleaner::getInstance()->sweetstring($titulo); } else { $titulo_amigo = $titulo_amigo; } $texto = TextCleaner::getInstance()->specialchars_decode($texto, ENT_QUOTES); } else { $titulo_amigo = $edit ? $titulo_amigo != '' ? $titulo_amigo : TextCleaner::getInstance()->sweetstring($titulo) : TextCleaner::getInstance()->sweetstring($titulo); } if ($texto == '' && $type == 0) { redirectMsg("pages.php?op=new&cat={$cat}&page={$page}", __('Content is missing', 'qpages'), 1); die; } if ($catego <= 0) { redirectMsg("pages.php?op=new&cat={$cat}&page={$page}", __('You must select a category for this page', 'qpages'), 1); die; } if (count($grupos) <= 0) { $grupos = array(0); } /** * Comprobamos que no exista otra página con el mismo título */ $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix("qpages_pages") . " WHERE titulo_amigo='{$titulo_amigo}'"; $sql .= $edit ? " AND id_page<>" . $page->getID() : ''; list($num) = $db->fetchRow($db->query($sql)); if ($num > 0) { $form = new RMForm(__('Review Page', 'qpages'), 'frm-review', 'pages.php'); $form->addElement(new RMFormLabel('', __('A page with same friendly name already exists. Please change the freindly title to prevent errors.', 'qpages'))); foreach ($_POST as $k => $v) { if ($k == 'titulo_amigo') { continue; } if ($k == 'texto') { continue; } if ($k == 'grupos') { continue; } if ($k == 'XOOPS_TOKEN_REQUEST') { continue; } if ($k == 'titulo') { $k = 'pretitulo'; } $hiddens[$k] = $v; } $form->addElement(new RMFormText(__('Title', 'qpages'), 'titulo', 50, 255, $titulo), true); $form->addElement(new RMFormText(__('Friendly title', 'qpages'), 'titulo_amigo', 50, 255, $titulo_amigo), true); $form->addElement(new RMFormHidden('texto', TextCleaner::getInstance()->specialchars($texto, ENT_QUOTES))); foreach ($hiddens as $k => $v) { $form->addElement(new RMFormHidden($k, $v)); } foreach ($grupos as $group) { $form->addElement(new RMFormHidden('grupos[]', $group)); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', __('Save Page', 'qpages'), 'submit'); $ele->addButton('cancel', __('Cancel', 'qpages'), 'button', 'onclick="history.go(-1);"'); $form->addElement($ele); qpages_toolbar(); xoops_cp_header(); $form->display(); xoops_cp_footer(); die; } #Guardamos los datos del Post $page->setTitle($titulo); $page->setFriendTitle($titulo_amigo); $page->setDate($edit ? $page->getVar('fecha') : time()); $page->setModDate(time()); $page->setText($texto); $page->setCategory($catego); $page->setVar('desc', TextCleaner::getInstance()->clean_disabled_tags($desc)); $page->setGroups($grupos); $page->setHTML(isset($dohtml) ? 1 : 0); $page->setXCode(isset($doxcode) ? 1 : 0); $page->setImage(isset($doimage) ? 1 : 0); $page->setBR(isset($dobr) ? 1 : 0); $page->setSmiley(isset($dosmiley) ? 1 : 0); $page->setUid($xoopsUser->uid()); $page->setType($type); $page->setURL(formatURL($url)); $page->setAccess($acceso); // Add Metas foreach ($meta_name as $k => $v) { $page->add_meta($v, $meta_value[$k]); } $ret = $edit ? $page->update() : $page->save(); if ($ret) { $xoopsUser->incrementPost(); redirectMsg("pages.php?op=" . ($page->type() ? 'editlink' : 'edit') . "&id=" . $page->getID() . "&cat={$cat}&page={$page}", __('Database updated successfully!', 'qpages'), 0); } else { redirectMsg("pages.php?{$q}", __('Errors ocurred while trying to update database', 'qpages') . "<br />" . $page->errors(), 1); } }
/** * @desc Almacena los datos de una categoría */ function bxpress_save_category($edit = 0) { global $xoopsConfig, $xoopsModuleConfig, $xoopsSecurity; $db = XoopsDatabaseFactory::getDatabaseConnection(); $title = ''; $friendname = ''; $showdesc = 0; $status = 0; $id = 0; $desc = ''; $order = ''; $q = ''; //Query string foreach ($_POST as $k => $v) { ${$k} = $v; if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'action') { continue; } $q = ($q == '' ? '' : '&') . $k . '=' . urlencode($v); } if (!$xoopsSecurity->check()) { RMUris::redirect_with_message(__('Session token expired!', 'bxpress'), 'categories.php', RMMSG_ERROR); die; } if ($title == '') { RMUris::redirect_with_message(__('Please provide a name for this category!', 'bxpress'), 'categories.php?' . $q, RMMSG_ERROR); die; } if ($edit) { if ($id <= 0) { RMUris::redirect_with_message(__('The specified category ID is not valid!', 'bxpress'), 'categories.php', RMMSG_WARN); die; } $catego = new bXCategory($id); if ($catego->isNew()) { RMUris::redirect_with_message(__('Specified category does not exists!', 'bxpress'), 'categories.php', RMMSG_ERROR); die; } // Comprobamos que no exista el nombre list($num) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("mod_bxpress_categories") . " WHERE title='{$title}' AND id_cat<>'{$id}'")); if ($num > 0) { RMUris::redirect_with_message(__('Already exists a category with same name!', 'bxpress'), 'categories.php?' . $q, RMMSG_ERROR); die; } } else { $catego = new bXCategory(); } // Asignamos valores $catego->setTitle($title); $friendname = $friendname != '' ? TextCleaner::getInstance()->sweetstring($friendname) : TextCleaner::getInstance()->sweetstring($title); // Comprobamos que el nombre no este asignada a otra categoría list($num) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("mod_bxpress_categories") . " WHERE friendname='{$friendname}' AND id_cat<>'{$id}'")); if ($num > 0) { RMUris::redirect_with_message(__('Already exist a category with the same short name!', 'bxpress'), 'categories.php?op=edit&id=' . $id, RMMSG_WARN); die; } $catego->setDescription($desc); $catego->setFriendName($friendname); $catego->setGroups(!isset($groups) || is_array($groups) ? array(0) : $groups); $catego->setOrder($order <= 0 ? 0 : intval($order)); $catego->setShowDesc($showdesc); $catego->setStatus($status); if ($catego->save()) { RMUris::redirect_with_message(__('Category saved succesfully!', 'bxpress'), 'categories.php', RMMSG_SUCCESS); } else { RMUris::redirect_with_message(__('Category could not be saved!', 'bxpress') . '<br />' . $catego->errors(), 'categories.php', RMMSG_ERROR); } }
/** * Get all comments for given parameters * @param string Object id (can be a module name) * @param string Params for comment item * @param string Object type (eg. module, plugin, etc) * @param int Comment parent id, will return all comments under a given parent * @param int User that has been posted the comments * @return array */ public function get_comments($obj, $params, $type = 'module', $parent = 0, $user = null, $assign = true) { global $xoopsUser; define('COMMENTS_INCLUDED', 1); $db = Database::getInstance(); $rmc_config = RMFunctions::configs(); $params = urlencode($params); $sql = "SELECT * FROM " . $db->prefix("rmc_comments") . " WHERE status='approved' AND id_obj='{$obj}' AND params='{$params}' AND type='{$type}' AND parent='{$parent}'" . ($user == null ? '' : " AND user='******'") . " ORDER BY posted"; $result = $db->query($sql); $ucache = array(); $ecache = array(); while ($row = $db->fetchArray($result)) { $com = new RMComment(); $com->assignVars($row); // Editor data if (!isset($ecache[$com->getVar('user')])) { $ecache[$com->getVar('user')] = new RMCommentUser($com->getVar('user')); } $editor = $ecache[$com->getVar('user')]; if ($editor->getVar('xuid') > 0) { if (!isset($ucache[$editor->getVar('xuid')])) { $ucache[$editor->getVar('xuid')] = new XoopsUser($editor->getVar('xuid')); } $user = $ucache[$editor->getVar('xuid')]; $poster = array('id' => $user->getVar('uid'), 'name' => $user->getVar('uname'), 'email' => $user->getVar('email'), 'posts' => $user->getVar('posts'), 'avatar' => XOOPS_UPLOAD_URL . '/' . $user->getVar('user_avatar'), 'rank' => $user->rank(), 'url' => $user->getVar('url') != 'http://' ? $user->getVar('url') : ''); } else { $poster = array('id' => 0, 'name' => $editor->getVar('name'), 'email' => $editor->getVar('email'), 'posts' => 0, 'avatar' => '', 'rank' => '', 'url' => $editor->getVar('url') != 'http://' ? $editor->getVar('url') : ''); } if ($xoopsUser && $xoopsUser->isAdmin()) { $editlink = RMCURL . '/comments.php?action=edit&id=' . $com->id() . '&ret=' . urlencode(self::current_url()); } elseif ($rmc_config['allow_edit']) { $time_limit = time() - $com->getVar('posted'); if ($xoopsUser && $xoopsUser->getVar('uid') == $editor->getVar('xuid') && $time_limit < $rmc_config['edit_limit'] * 3600) { $editlink = RMCURL . '/post_comment.php?action=edit&id=' . $com->id() . '&ret=' . urlencode(self::current_url()); } else { $editlink = ''; } } $comms[] = array('id' => $row['id_com'], 'text' => TextCleaner::getInstance()->clean_disabled_tags(TextCleaner::getInstance()->popuplinks(TextCleaner::getInstance()->nofollow($com->getVar('content')))), 'poster' => $poster, 'posted' => sprintf(__('Posted on %s'), formatTimestamp($com->getVar('posted'), 'l')), 'ip' => $com->getVar('ip'), 'edit' => $editlink); unset($editor); } $comms = RMEvents::get()->run_event('rmcommon.loading.comments', $comms, $obj, $params, $type, $parent, $user); global $xoopsTpl; $xoopsTpl->assign('lang_edit', __('Edit', 'rmcommon')); if ($assign) { $xoopsTpl->assign('comments', $comms); return true; } else { return $comms; } }
/** * Almacena las modificaciones hechas a un registro de una tabla */ protected function updateTable() { if (empty($this->_tblcolumns)) { $this->getColumns(); } $myts =& TextCleaner::getInstance(); $sql = "UPDATE {$this->_dbtable} SET "; $fields = ''; $this->cleanVars(); foreach ($this->_tblcolumns as $k) { if ($k['Extra'] == 'auto_increment') { continue; } $fields .= $fields == '' ? "`{$k['Field']}`='" . addslashes($this->cleanVars[$k['Field']]) . "'" : ", `{$k['Field']}`='" . addslashes($this->cleanVars[$k['Field']]) . "'"; } $sql .= $fields . " WHERE `{$this->primary}`='" . $this->getVar($this->primary) . "'"; $this->db->queryF($sql); if ($this->db->error() != '') { $this->addError($this->db->error()); return false; } else { return true; } }
function rmc_bkcomments_show($options) { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("rmc_comments") . " ORDER BY id_com DESC"; $limit = $options[0] > 0 ? $options[0] : 10; $sql .= " LIMIT 0,{$limit}"; $result = $db->query($sql); $comments = array(); $ucache = array(); $ecache = array(); $mods = array(); while ($row = $db->fetchArray($result)) { $com = new RMComment(); $com->assignVars($row); if ($options[3]) { // Editor data if (!isset($ecache[$com->getVar('user')])) { $ecache[$com->getVar('user')] = new RMCommentUser($com->getVar('user')); } $editor = $ecache[$com->getVar('user')]; if ($editor->getVar('xuid') > 0) { if (!isset($ucache[$editor->getVar('xuid')])) { $ucache[$editor->getVar('xuid')] = new XoopsUser($editor->getVar('xuid')); } $user = $ucache[$editor->getVar('xuid')]; $poster = array('id' => $user->getVar('uid'), 'name' => $user->getVar('uname'), 'email' => $user->getVar('email'), 'posts' => $user->getVar('posts'), 'avatar' => $user->getVar('user_avatar') != '' && $user->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $user->getVar('user_avatar') : RMCURL . '/images/avatar.gif', 'rank' => $user->rank()); } else { $poster = array('id' => 0, 'name' => $editor->getVar('name'), 'email' => $editor->getVar('email'), 'posts' => 0, 'avatar' => RMCURL . '/images/avatar.gif', 'rank' => ''); } } // Get item $cpath = XOOPS_ROOT_PATH . '/modules/' . $row['id_obj'] . '/class/' . $row['id_obj'] . 'controller.php'; if (is_file($cpath)) { if (!class_exists(ucfirst($row['id_obj']) . 'Controller')) { include_once $cpath; } $class = ucfirst($row['id_obj']) . 'Controller'; $controller = new $class(); $item = $controller->get_item($row['params'], $com); $item_url = $controller->get_item_url($row['params'], $com); } else { $item = __('Unknow', 'rmcommon'); $item_url = ''; } if (isset($mods[$row['id_obj']])) { $mod = $mods[$row['id_obj']]; } else { $m = RMFunctions::load_module($row['id_obj']); $mod = $m->getVar('name'); $mods[$row['id_obj']] = $mod; } $comments[] = array('id' => $row['id_com'], 'text' => TextCleaner::truncate(TextCleaner::getInstance()->clean_disabled_tags(TextCleaner::getInstance()->popuplinks(TextCleaner::getInstance()->nofollow($com->getVar('content')))), 50), 'poster' => isset($poster) ? $poster : null, 'posted' => formatTimestamp($com->getVar('posted'), 'l'), 'item' => $item, 'item_url' => $item_url, 'module' => $row['id_obj'], 'status' => $com->getVar('status'), 'module' => $mod); } $comments = RMEvents::get()->run_event('rmcommon.loading.block.comments', $comments); $block['comments'] = $comments; $block['show_module'] = $options[1]; $block['show_name'] = $options[2]; $block['show_user'] = $options[3]; $block['show_date'] = $options[4]; $num = $options[2] + $options[3] + $options[4]; $block['data_width'] = floor(100 / $num); RMTemplate::get()->add_xoops_style('bk_comments.css', 'rmcommon'); return $block; }
/** * Save feature */ function dt_save_log($edit) { global $item, $log, $tpl, $xoopsTpl, $mc, $dtfunc; $query = ''; foreach ($_POST as $k => $v) { ${$k} = $v; } $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($edit) { //Verificamos que la característica exista $lg = new DTLog($log); if ($lg->isNew()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Specified log does not exists!', 'dtransport')); } } else { $lg = new DTLog(); } $tc = TextCleaner::getInstance(); //Comprueba que el título de la característica no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_logs') . " WHERE title='{$title}' AND id_log!=" . $lg->id() . " AND id_soft=" . $item->id(); list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/edit/' . $lg->id() : '/?p=cpanel&action=logs&id=' . $item->id() . '/&op=edit&log=' . $lg->id()), 1, __('Another log with same title already exists!', 'dtransport')); } $lg->setSoftware($item->id()); $lg->setTitle($title); $lg->setLog($content); $lg->setDate(time()); if (!$lg->save()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Log could not be saved! Please try again.', 'dtransport')); } redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Log saved successfully!', 'dtransport')); }
/** * Save the current positions */ function save_position($edit = 0) { global $xoopsSecurity; if (!$xoopsSecurity->check()) { redirectMsg('blocks.php', __('You are not allowed to do this action!', 'rmcommon'), 1); die; } $name = rmc_server_var($_POST, 'posname', ''); $tag = rmc_server_var($_POST, 'postag', ''); if ($name == '') { redirectMsg('blocks.php', __('Please provide a name and tag for this new position!', 'rmcommon'), RMMSG_ERROR); die; } if ($tag == '') { $tag = str_replace("-", "_", TextCleaner::getInstance()->sweetstring($name)); } if ($edit) { $id = rmc_server_var($_POST, 'id', ''); if ($id <= 0) { redirectMsg('blocks.php', __('You must specify a valid position ID!', 'rmcommon'), 1); } $pos = new RMBlockPosition($id); if ($pos->isNew()) { redirectMsg('blocks.php', __('Specified position does not exists!', 'rmcommon'), 1); } } else { $pos = new RMBlockPosition(); } $db = XoopsDatabaseFactory::getDatabaseConnection(); $pos->setVar('name', $name); $pos->setVar('tag', $tag); $pos->setVar('active', 1); $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_rmcommon_blocks_positions") . " WHERE name='{$name}' OR tag='{$tag}'"; if ($edit) { $sql .= " AND id_position<>{$id}"; } list($num) = $db->fetchRow($db->query($sql)); if ($num > 0) { redirectMsg('blocks.php', __('Already exists another position with same name or same tag!', 'rmcommon'), 1); } if ($pos->save()) { redirectMsg('blocks.php?from=positions', __('Database updated successfully!', 'rmcommon')); } else { redirectMsg('blocks.php', __('Errors ocurred while trying to save data', 'rmcommon') . '<br />' . $pos->errors()); } }
// License: GPL 2.0 // -------------------------------------------------------------- include '../../../mainfile.php'; XoopsLogger::getInstance()->activated = false; XoopsLogger::getInstance()->renderingEnabled = false; function error($message) { $data['error'] = 1; $data['message'] = $message; echo json_encode($data); die; } /** * Handle uploaded image files only. */ $security = TextCleaner::getInstance()->decrypt(rmc_server_var($_POST, 'rmsecurity', 0), true); $category = rmc_server_var($_POST, 'category', 0); $data = $security; //base64_decode($security); $data = explode("|", $data); // [0] = referer, [1] = session_id(), [2] = user, [3] = token $xoopsUser = new XoopsUser($data[0]); if (!isset($data[1]) || $data[1] != RMCURL . '/images.php') { error(__('You are not allowed to do this action', 'rmcommon')); } if (!$xoopsUser) { error(__('You are not allowed to do this action', 'rmcommon')); } if ($category <= 0) { error(__('Sorry, category has not been specified!', 'rmcommon')); }
} $xoopsTpl->assign('comments', $comms); // Comments form RMFunctions::comments_form('mywords', 'post=' . $post->id(), 'module', MW_PATH . '/class/mywordscontroller.php'); } // Load trackbacks $trackbacks = $post->trackbacks(); foreach ($trackbacks as $tb) { $xoopsTpl->append('trackbacks', array('id' => $tb->id(), 'title' => $tb->getVar('title'), 'blog' => $tb->getVar('blog_name'), 'url' => $tb->getVar('url'), 'text' => $tb->getVar('excerpt'), 'date' => formatTimestamp($tb->getVar('date'), 'c'))); } // Language $xoopsTpl->assign('lang_publish', __('Published in', 'mywords')); $xoopsTpl->assign('lang_tagged', __('Tagged as', 'mywords')); $xoopsTpl->assign('lang_numcoms', sprintf(__('%u Comments', 'mywords'), $post->getVar('comments'))); $xoopsTpl->assign('lang_numtracks', sprintf(__('%u trackbacks', 'mywords'), count($trackbacks))); $xoopsTpl->assign('lang_trackback', __('Trackback', 'mywords')); $xoopsTpl->assign('lang_homemw', __('Main Page', 'mywords')); $xoopsTpl->assign('enable_images', $xoopsModuleConfig['post_imgs']); //Trackback if ($post->getVar('pingstatus')) { $tb = new MWTrackback($xoopsConfig['sitename'], $editor->getVar('name')); RMTemplate::get()->add_head($tb->rdf_autodiscover(date('r', $post->getVar('pubdate')), $post->getVar('title'), TextCleaner::getInstance()->truncate($post->content(true), 255), $post->permalink(), MWFunctions::get_url(true) . $post->id(), $editor->getVar('name'))); } $rmf = RMFunctions::get(); $description = $post->get_meta('description', false); $keywords = $post->get_meta('keywords', false); $rmf->add_keywords_description($description != '' ? $description : $post->content(true), $keywords != '' ? $keywords : ''); // Send pings? $pings = $post->getVar('toping'); $xoopsTpl->assign('pingnow', empty($pings)); include 'footer.php';
/** * @desc Almacena toda la información referente a la sección **/ function saveSection($edit = 0, $ret = 0) { global $xoopsUser, $xoopsModuleConfig; foreach ($_POST as $k => $v) { ${$k} = $v; } //Verifica si se proporcionó una publicación para la sección if ($res <= 0) { redirect_header(RDURL, 1, __('Operation not allowed!', 'docs')); die; } //Verifica si la publicación existe $res = new RDResource($res); if ($res->isNew()) { redirect_header(RDURL, 1, __('Operation not allowed!', 'docs')); die; } //Verificamos si es una publicación aprobada if (!$res->getVar('approved')) { redirect_header(RDURL, 2, __('This Document has not been approved yet!', 'docs')); die; } // TODO: Crear el link correcto de retorno if ($xoopsModuleConfig['permalinks']) { $retlink = RDFunctions::url() . '/list/' . $res->getVar('nameid') . '/'; } else { $retlink = RDFunctions::url() . '?page=edit&action=list&res=' . $res->id(); } //Verificamos si el usuario tiene permisos de edicion if (!$xoopsUser->uid() == $res->getVar('owner') && !$res->isEditor($xoopsUser->uid()) && !$xoopsUser->isAdmin()) { redirect_header(RDURL, 2, __('You can not edit this content!', 'docs')); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($edit) { //Verifica si la sección es válida if ($id == '') { redirect_header($retlink, 1, __('Specified section is not valid!', 'docs')); die; } //Comprueba si la sección es existente $sec = new RDSection($id); if ($sec->isNew()) { redirect_header($retlink, 1, __('Specified section does not exists!', 'docs')); die; } //Comprueba que el título de la sección no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_sections') . " WHERE title='{$title}' AND id_res='{$res}' AND id_sec<>" . $sec->id(); list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirect_header($sec->editlink(), 1, __('Already exists another section with same title!', 'docs')); die; } /** * Comprobamos si debemos almacenar las ediciones en la * tabla temporal o directamente en la tabla de secciones */ if (!$res->getVar('editor_approve') && !$xoopsUser->isAdmin()) { $sec = new RDEdit(null, $id_sec); } } else { //Comprueba que el título de la sección no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_sections') . " WHERE title='{$title}' AND id_res='" . $res->id() . "'"; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirect_header(ah_make_link('publish/' . $res->nameId() . '/'), 1, _MS_AH_ERRTITLE); die; } $sec = new RDSection(); } //Genera $nameid Nombre identificador if ($title != $sec->getVar('title')) { $found = false; $i = 0; do { $nameid = TextCleaner::getInstance()->sweetstring($title) . ($found ? $i : ''); $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_sections') . " WHERE nameid = '{$nameid}'"; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { $found = true; $i++; } else { $found = false; } } while ($found == true); } if (!$res->getVar('editor_approve') && !$xoopsUser->isAdmin() && !($res->getVar('owner') == $xoopsUser->uid())) { $sec->setVar('id_sec', $id); } $sec->setVar('title', $title); $sec->setVar('content', $content); $sec->setVar('order', $order); $sec->setVar('id_res', $res->id()); isset($nameid) ? $sec->setVar('nameid', $nameid) : ''; $sec->setVar('parent', $parent); $sec->setVar('uid', $xoopsUser->uid()); $sec->setVar('uname', $xoopsUser->uname()); if ($edit) { $sec->setVar('modified', time()); } else { $sec->setVar('created', time()); $sec->setVar('modified', time()); } // Metas if ($edit) { $sec->clear_metas(); } // Clear all metas // Initialize metas array if not exists if (!isset($metas)) { $metas = array(); } // Get meta key if "select" is visible if (isset($meta_name_sel) && $meta_name_sel != '') { $meta_name = $meta_name_sel; } // Add meta to metas array if (isset($meta_name) && $meta_name != '') { array_push($metas, array('key' => $meta_name, 'value' => $meta_value)); } // Assign metas foreach ($metas as $value) { $sec->add_meta($value['key'], $value['value']); } RMEvents::get()->run_event('docs.saving.section', $sec); if (!$sec->save()) { redirect_header($sec->editlink(), 3, __('Section could not be saved!', 'docs')); } else { if ($edit) { $sec = new RDSection($sec->getVar('id_sec')); } if ($return == 1) { redirect_header($sec->permalink(), 1, __('Database updated successfully!', 'docs')); } elseif ($return == 2) { redirect_header($sec->editlink(), 1, __('Database updated successfully!', 'docs')); } else { redirect_header($retlink, 1, __('Database updated successfully!', 'docs')); } } }
function show_dashboard() { global $xoopsModule, $cuSettings, $cuIcons; //RMFunctions::create_toolbar(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = 'SELECT * FROM ' . $db->prefix('modules'); $result = $db->query($sql); $installed_mods = array(); while ($row = $db->fetchArray($result)) { $installed_mods[] = $row['dirname']; } require_once XOOPS_ROOT_PATH . "/class/xoopslists.php"; $dirlist = XoopsLists::getModulesList(); $available_mods = array(); $module_handler =& xoops_gethandler('module'); foreach ($dirlist as $file) { clearstatcache(); $file = trim($file); if (!in_array($file, $installed_mods)) { $module =& $module_handler->create(); if (!$module->loadInfo($file, false)) { continue; } $available_mods[] = $module; } } $installed_modules = get_modules_list(); // Modules counter $counterModules = new Common\Widgets\Counter(['id' => 'counter-modules', 'color' => 'red', 'icon' => 'svg-rmcommon-module', 'class' => 'animated bounceIn']); $counterModules->addCell(__('Modules', 'rmcommon'), count($available_mods) + count($installed_modules)); $counterModules->addCell(__('Installed', 'rmcommon'), count($installed_modules)); $counterModules->addCell(__('Available', 'rmcommon'), count($available_mods)); // Users counter $sql = "SELECT COUNT(*) FROM " . $db->prefix("users") . " WHERE level > 0"; list($active) = $db->fetchRow($db->query($sql)); $sql = "SELECT COUNT(*) FROM " . $db->prefix("users") . " WHERE level <= 0"; list($inactive) = $db->fetchRow($db->query($sql)); $counterUsers = new Common\Widgets\Counter(['id' => 'counter-users', 'color' => 'blue', 'icon' => 'svg-rmcommon-users2', 'class' => 'animated bounceIn']); $total = $active + $inactive; $counterUsers->addCell(__('Users', 'rmcommon'), $total); $counterUsers->addCell(__('Active', 'rmcommon'), $active); $counterUsers->addCell(__('Inactive', 'rmcommon'), $inactive); $ratio = $active / ($active + $inactive); if ($ratio < 1) { $ratio = number_format($ratio, 2); } $counterUsers->addCell(__('Ratio', 'rmcommon'), $ratio * 100 . '%'); // Comments counter $counterComments = new Common\Widgets\Counter(['id' => 'counter-comments', 'color' => 'green', 'icon' => 'svg-rmcommon-comments', 'class' => 'animated bounceIn']); list($approved) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("mod_rmcommon_comments") . " WHERE status = 'approved'")); list($waiting) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("mod_rmcommon_comments") . " WHERE status != 'approved'")); $counterComments->addCell(__('Comments', 'rmcommon'), $approved > 0 || $waiting > 0 ? $approved + $waiting : '0'); $counterComments->addCell(__('Approved', 'rmcommon'), $approved); $counterComments->addCell(__('Waiting', 'rmcommon'), $waiting); $ratio = $approved / ($approved + $waiting); if ($ratio < 1) { $ratio = number_format($ratio, 2); } $counterComments->addCell(__('Ratio', 'rmcommon'), $ratio * 100 . '%'); $counterSystem = new Common\Widgets\Counter(['id' => 'counter-system', 'color' => 'deep-orange', 'icon' => 'svg-rmcommon-rmcommon', 'class' => 'animated bounceIn']); $counterSystem->addCell(__('Current Version', 'rmcommon'), RMModules::get_module_version('rmcommon', false)); $counterSystem->addCell('XOOPS', str_replace('XOOPS ', '', XOOPS_VERSION)); $version = explode('-', phpversion()); $counterSystem->addCell('PHP', $version[0]); unset($version); if (method_exists($db, 'getServerVersion')) { $version = explode("-", $db->getServerVersion()); } else { $version = '--'; } $counterSystem->addCell('MySQL', $version[0]); // Management Tools $managementTools[] = (object) ['caption' => __('Modules', 'rmcommon'), 'link' => 'modules.php', 'icon' => 'svg-rmcommon-module', 'color' => 'pink']; $managementTools[] = (object) ['caption' => __('Blocks', 'rmcommon'), 'link' => 'blocks.php', 'icon' => 'svg-rmcommon-blocks', 'color' => 'blue']; $managementTools[] = (object) ['caption' => __('Users', 'rmcommon'), 'link' => 'users.php', 'icon' => 'svg-rmcommon-user2', 'color' => 'deep-orange']; $managementTools[] = (object) ['caption' => __('Groups', 'rmcommon'), 'link' => 'groups.php', 'icon' => 'svg-rmcommon-users2', 'color' => 'green']; $managementTools[] = (object) ['caption' => __('Images', 'rmcommon'), 'link' => 'images.php', 'icon' => 'svg-rmcommon-images', 'color' => 'purple']; $managementTools[] = (object) ['caption' => __('Comments', 'rmcommon'), 'link' => 'comments.php', 'icon' => 'svg-rmcommon-comments', 'color' => 'red']; $managementTools[] = (object) ['caption' => __('Plugins', 'rmcommon'), 'link' => 'plugins.php', 'icon' => 'svg-rmcommon-plug', 'color' => 'orange']; $managementTools[] = (object) ['caption' => __('Updates', 'rmcommon'), 'link' => 'updates.php', 'icon' => 'svg-rmcommon-update', 'color' => 'teal']; $managementTools[] = (object) ['caption' => __('Preferences', 'rmcommon'), 'link' => 'settings.php?action=configure&mod=rmcommon', 'icon' => 'svg-rmcommon-wrench', 'color' => 'light-blue']; $managementTools = RMEvents::get()->trigger('rmcommon.get.system.tools', $managementTools); // Load recent comments $sql = "SELECT * FROM " . $db->prefix("mod_rmcommon_comments") . " ORDER BY `posted` DESC LIMIT 0, 5"; $result = $db->query($sql); $comments = []; while ($row = $db->fetchArray($result)) { $com = new RMComment(); $com->assignVars($row); // Editor data if (!isset($ecache[$com->getVar('user')])) { $ecache[$com->getVar('user')] = new RMCommentUser($com->getVar('user')); } $editor = $ecache[$com->getVar('user')]; if ($editor->getVar('xuid') > 0) { if (!isset($ucache[$editor->getVar('xuid')])) { $ucache[$editor->getVar('xuid')] = new XoopsUser($editor->getVar('xuid')); } $user = $ucache[$editor->getVar('xuid')]; $poster = (object) array('id' => $user->getVar('uid'), 'name' => $user->getVar('uname'), 'email' => $user->getVar('email'), 'posts' => $user->getVar('posts'), 'avatar' => $user->getVar('image') != '' && $user->getVar('image') != 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $user->getVar('image') : RMCURL . '/images/avatar.gif', 'rank' => $user->rank()); } else { $poster = (object) array('id' => 0, 'name' => $editor->getVar('name'), 'email' => $editor->getVar('email'), 'posts' => 0, 'avatar' => RMCURL . '/images/avatar.gif', 'rank' => ''); } // Get item $cpath = XOOPS_ROOT_PATH . '/modules/' . $row['id_obj'] . '/class/' . $row['id_obj'] . 'controller.php'; if (is_file($cpath)) { if (!class_exists(ucfirst($row['id_obj']) . 'Controller')) { include_once $cpath; } $class = ucfirst($row['id_obj']) . 'Controller'; $controller = new $class(); $item = $controller->get_item($row['params'], $com); if (method_exists($controller, 'get_item_url')) { $item_url = $controller->get_item_url($row['params'], $com); } } else { $item = __('Unknow', 'rmcommon'); $item_url = ''; } $text = TextCleaner::getInstance()->clean_disabled_tags(TextCleaner::getInstance()->popuplinks(TextCleaner::getInstance()->nofollow(TextCleaner::getInstance()->truncate($com->getVar('content'), 100)))); $comments[] = (object) array('id' => $row['id_com'], 'text' => $text, 'poster' => $poster, 'date' => formatTimestamp($com->getVar('posted'), 'l'), 'ip' => $com->getVar('ip'), 'item' => $item, 'item_url' => $item_url, 'module' => $row['id_obj'], 'status' => $com->getVar('status')); } // Get dashboard widgets $dashboardPanels = []; $dashboardPanels = RMEvents::get()->trigger('rmcommon.dashboard.panels', $dashboardPanels); RMTemplate::getInstance()->add_body_class('dashboard'); xoops_cp_header(); //RMTemplate::get()->add_style('dashboard.min.css', 'rmcommon'); RMTemplate::get()->add_style('pagenav.css', 'rmcommon'); RMTemplate::get()->add_help(__('Dashboard Help', 'rmcommon'), 'http://www.xoopsmexico.net/docs/common-utilities/uso-de-common-utilities/standalone/1/#dashboard'); include RMTemplate::get()->path('rmc-dashboard.php', 'module', 'rmcommon'); xoops_cp_footer(); }
function saveCoach($edit = 0) { global $db, $mc, $xoopsSecurity; $nameid = ''; $teams = array(); foreach ($_POST as $k => $v) { ${$k} = $v; } if (!$xoopsSecurity->check()) { redirectMsg('coachs.php' . ($edit ? "?op=edit&id={$id}" : "?op=new"), __('El identificador de sesión ha expirado', 'admin_team'), 1); break; } if ($edit) { $id = TCFunctions::post('id'); if ($id <= 0) { redirectMsg('coachs.php', __('Id no válido', 'admin_team'), 1); die; } $coach = new TCCoach($id); if ($coach->isNew()) { redirectMsg('coachs.php', __('El entrenador especificado no existe', 'admin_team'), 1); die; } $i = 0; do { $nameid = $nameid != '' && $i == 0 ? $nameid : $util->sweetstring($name) . ($i > 0 ? $i : ''); $sql = "SELECT COUNT(*) FROM " . $db->prefix("coach_coachs") . " WHERE nameid='{$nameid}' AND id_coach<>'" . $coach->id() . "'"; list($num) = $db->fetchRow($db->query($sql)); $i++; } while ($num > 0); $sql = "SELECT COUNT(*) FROM " . $db->prefix("coach_coachs") . " WHERE name='{$name}' AND id_coach<>'" . $coach->id() . "'"; list($num) = $db->fetchRow($db->query($sql)); if ($num > 0) { redirectMsg('coachs.php?op=edit&id=' . $coach->id(), __('Ya existe un entrenador con ese nombre', 'admin_team'), 1); die; } } else { $coach = new TCCoach(); $i = 0; do { $nameid = TextCleaner::getInstance()->sweetstring($name) . ($i > 0 ? $i : ''); $sql = "SELECT COUNT(*) FROM " . $db->prefix("coach_coachs") . " WHERE nameid='{$nameid}'"; list($num) = $db->fetchRow($db->query($sql)); $i++; } while ($num > 0); $sql = "SELECT COUNT(*) FROM " . $db->prefix("coach_coachs") . " WHERE name='{$name}'"; list($num) = $db->fetchRow($db->query($sql)); if ($num > 0) { redirectMsg('coachs.php?op=new&id=' . $cat->id(), __('Ya existe un entreandor con el mismo nombre', 'admin_team'), 1); die; } } // Cargamos la imágen include_once RMCPATH . '/class/uploader.php'; $up = new RMFileUploader(XOOPS_UPLOAD_PATH . '/teams/coachs', $mc['filesize'] * 1024, array('jpg', 'png', 'gif')); if ($up->fetchMedia('image')) { if (!$up->upload()) { if ($edit) { redirectMsg('./coachs.php?op=new', $up->getErrors(), 1); die; } else { redirectMsg('./coachs.php?op=edit&id=' . $coach->id(), $up->getErrors(), 1); die; } } if ($edit && $coach->image() != '') { @unlink(XOOPS_UPLOAD_PATH . '/teams/coachs/' . $coach->image()); @unlink(XOOPS_UPLOAD_PATH . '/teams/coachs/ths/' . $coach->image()); } $filename = $up->getSavedFileName(); $fullpath = $up->getSavedDestination(); // Redimensionamos la imagen $redim = new RMImageResizer($fullpath, $fullpath); $redim->resizeWidth($mc['img_size']); $redim->setTargetFile(XOOPS_UPLOAD_PATH . "/teams/coachs/ths/{$filename}"); switch ($mc['resize_method']) { case 1: //Recortar miniatura $redim->resizeAndCrop($mc['th_size'], $mc['th_size']); break; case 0: $redim->resizeWidth($mc['th_size']); break; } } else { $filename = $edit ? $coach->image() : ''; } $coach->setName($name); $coach->setNameId($nameid); $coach->setBio($bio); $coach->setImage($filename); $coach->setRole($role); $coach->setTeams($teams); if (!$edit) { $coach->setCreated(time()); } if ($coach->save()) { redirectMsg('coachs.php', __('Base de datos actualizada correctamente', 'admin_template'), 0); } else { redirectMsg('coachs.php?op=' . ($edit ? 'edit&id=' . $coach->id() : 'new'), __('Error al actualizar la base de datos', 'admin_template') . '<br />' . $coach->errors()); } }
function preg_striptags($match) { //return TextCleaner::getInstance()->specialchars($match); $ret = ''; if (is_array($match)) { foreach ($match as $i => $t) { $ret .= TextCleaner::getInstance()->specialchars($t); } } else { $match = TextCleaner::getInstance()->specialchars($match); } return $ret; }
/** * Save file */ function dt_save_file($edit) { global $item, $file, $tpl, $xoopsTpl, $mc, $dtfunc; foreach ($_POST as $k => $v) { ${$k} = $v; } $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($edit) { //Verificamos que la característica exista $fl = new DTFile($file); if ($fl->isNew()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/' : '/?p=cpanel&action=files&id=' . $item->id()), 1, __('Specified file does not exists!', 'dtransport')); } } else { $fl = new DTFile(); } $tc = TextCleaner::getInstance(); //Comprueba que el título de la característica no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_files') . " WHERE title='{$title}' AND id_file!=" . $fl->id() . " AND id_soft=" . $item->id(); list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/edit/' . $fl->id() : '/?p=cpanel&action=files&id=' . $item->id() . '&op=edit&file=' . $fl->id()), 1, __('Another log with same title already exists!', 'dtransport')); } // Check if a file has been provided if ($_FILES['thefile']['name'] == '') { // Comprobamos si se ha proporcionado un archivo if (!$edit && !$remote) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/edit/' . $fl->id() : '/?p=cpanel&action=files&id=' . $item->id() . '&op=edit&file=' . $fl->id()), 1, __('You must provide a file to upload!', 'dtransport')); } elseif ($remote && $url == '') { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/edit/' . $fl->id() : '/?p=cpanel&action=files&id=' . $item->id() . '&op=edit&file=' . $fl->id()), 1, __('You must provide a file URL when remote type is activated!', 'dtransport')); } } else { if ($edit && !$fl->remote()) { $path = $item->getVar('secure') ? rtrim($mc['directory_secure'], '/') . '/' . $fl->file() : rtrim($mc['directory_insecure']) . '/' . $fl->file(); unlink($path); } if ($item->getVar('secure')) { $dir = $mc['directory_secure']; } else { $dir = $mc['directory_insecure']; } include RMCPATH . '/class/uploader.php'; $uploader = new RMFileUploader($dir, $mc['size_file'] * 1024 * 1024, $mc['type_file']); if (!$uploader->fetchMedia('thefile')) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/edit/' . $fl->id() : '/?p=cpanel&action=files&id=' . $item->id() . '&op=edit&file=' . $fl->id()), 1, __('File could not be uploaded!, Please try again.', 'dtransport') . $uploader->getErrors()); } if (!$uploader->upload()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/edit/' . $fl->id() : '/?p=cpanel&action=files&id=' . $item->id() . '&op=edit&file=' . $fl->id()), 1, __('File could not be uploaded!, Please try again.', 'dtransport') . $uploader->getErrors()); } } $fl->setSoftware($item->id()); $fl->setTitle($title); $fname = !$uploader && $edit ? $remote ? $url : $fl->file() : $uploader->getSavedFileName(); $fl->setFile($fname); $fl->setRemote($remote); $fl->setGroup($group); $fl->setDefault($default); $fl->setDate(time()); $fl->setSize($remote ? '' : (isset($uploader) ? $uploader->getMediaSize() : $fl->size())); $fl->setMime($remote ? '' : (isset($uploader) ? $uploader->getMediaType() : $fl->mime())); if (!$fl->save()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/' . ($edit ? 'edit/' . $fl->id() : '') : '/?p=cpanel&action=files&id=' . $item->id() . ($edit ? '&op=edit&file=' . $fl->id() : '')), 1, __('File could not be saved! Please try again.', 'dtransport')); } if ($fl->isDefault()) { $db->queryF("UPDATE " . $db->prefix("dtrans_files") . " SET `default`=0 WHERE id_soft=" . $item->id() . " AND id_file !=" . $fl->id()); } redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/' : '/?p=cpanel&action=files&id=' . $item->id()), 1, __('File saved successfully!', 'dtransport')); }