示例#1
0
function search_resources()
{
    global $xoopsConfig, $xoopsUser, $page, $xoopsTpl;
    $keyword = rmc_server_var($_GET, 'keyword', '');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1";
    list($num) = $db->fetchRow($db->query($sql));
    $page = rmc_server_var($_GET, 'page', 1);
    $limit = 15;
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url(RDFunctions::make_link('search') . '?keyword=' . $keyword . '&amp;page={PAGE_NUM}');
    $sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1 LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    $resources = array();
    while ($row = $db->fetchArray($result)) {
        $res = new RDResource();
        $res->assignVars($row);
        $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'desc' => TextCleaner::truncate($res->getVar('description'), 100), 'link' => $res->permalink(), 'created' => $res->getVar('created'), 'owner' => $res->getVar('owner'), 'uname' => $res->getVar('owname'), 'reads' => $res->getVar('reads'));
    }
    RDFunctions::breadcrumb();
    RMBreadCrumb::get()->add_crumb(__('Browsing recent Documents', 'docs'));
    RMTemplate::get()->add_style('docs.css', 'docs');
    include 'header.php';
    $xoopsTpl->assign('xoops_pagetitle', sprintf(__('Search results for "%s"', 'docs'), $keyword));
    include RMEvents::get()->run_event('docs.template.search', RMTemplate::get()->get_template('rd_search.php', 'module', 'docs'));
    include 'footer.php';
}
示例#2
0
/**
* Este archivo permite controlar el bloque o los bloques
* Bloques Existentes:
* 
* 1. Publicaciones Recientes
* 2. Publicaciones Populares (Mas Leídas)
* 3. Publicaciones Mejor Votadas
*/
function rd_block_resources($options)
{
    global $xoopsModule;
    include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdresource.class.php';
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $mc = RMUtilities::module_config('docs');
    $sql = "SELECT * FROM " . $db->prefix("rd_resources") . ' WHERE public=1 AND approved=1';
    switch ($options[0]) {
        case 'recents':
            $sql .= " ORDER BY created DESC";
            break;
        case 'popular':
            $sql .= " ORDER BY `reads` DESC";
            break;
    }
    $sql .= " LIMIT 0, " . ($options[1] > 0 ? $options[1] : 5);
    $result = $db->query($sql);
    $block = array();
    while ($row = $db->fetchArray($result)) {
        $res = new RDResource();
        $res->assignVars($row);
        $ret = array();
        $ret['id'] = $res->id();
        $ret['title'] = $res->getVar('title');
        if ($options[2]) {
            $ret['desc'] = $options[3] == 0 ? $res->getVar('description') : TextCleaner::truncate($res->getVar('description'), $options[3]);
        }
        $ret['link'] = $res->permalink();
        $ret['author'] = sprintf(__('Created by %s', 'docs'), '<strong>' . $res->getVar('owname') . '</strong>');
        $ret['reads'] = sprintf(__('Viewed %s times', 'docs'), '<strong>' . $res->getVar('reads') . '</strong>');
        $block['resources'][] = $ret;
    }
    RMTemplate::get()->add_style('blocks.css', 'docs');
    return $block;
}
示例#3
0
 /**
  * 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&amp;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');
 }
示例#4
0
/**
* @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> &raquo; <a href='./items.php'>" . sprintf(_AS_DT_SW, $sw->getVar('name')) . "</a> &raquo; " . _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();
}
 /**
  * Gets news with some Id
  *
  * @param int $id Id of news
  * @return mixed Associated array with news data
  * @throws APIException
  */
 public function get($id)
 {
     $element = umiHierarchy::getInstance()->getElement($id);
     if (!$element) {
         throw new APIException("Can't find news with id " . $id);
     }
     $images = array();
     $mainImage = $element->getValue("anons_pic");
     if ($mainImage) {
         $mainImage = "http://" . $_SERVER['HTTP_HOST'] . $mainImage;
         $images[] = $mainImage;
     }
     $cleaner = new TextCleaner();
     $text = $element->getValue("content");
     $text = $cleaner->clearText($text);
     $imagesFromText = $cleaner->getPhotos($text);
     $images = array_merge($images, $imagesFromText);
     $item = array("id" => $id, "header" => $element->getValue("h1"), "text" => $text, "images" => $images, "date" => $element->getValue("publish_time")->getFormattedDate("d.m.Y"), "original_link" => "http://" . $_SERVER['HTTP_HOST'] . umiHierarchy::getInstance()->getPathById($id));
     return $item;
 }
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;
}
示例#7
0
/**
* @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;
    }
}
示例#8
0
 /**
  * @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;
 }
示例#9
0
 /**
  * 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;
         }
     }
 }
示例#10
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();
}
示例#11
0
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;
}
示例#12
0
/**
* @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;
}
示例#13
0
 /**
  * This method is designed specially for MyWords
  */
 public function eventMywordsViewPost($post_data, MWPost $post)
 {
     $config = RMFunctions::get()->plugin_settings('metaseo', true);
     if (!$config['meta']) {
         $metas = '<meta name="description" content="' . TextCleaner::truncate($post->content(true), $config['len']) . '" />';
         $tags = array();
         foreach ($post->tags() as $tag) {
             $tags[] = $tag['tag'];
         }
         $tags = implode(',', $tags);
         $metas .= '<meta name="keywords" content="' . $tags . '" />';
     } else {
         $metas = '<meta name="description" content="' . $post->get_meta($config['meta_name'], false) . '" />';
         $metas = '<meta name="description" content="' . $post->get_meta($config['meta_keys'], false) . '" />';
     }
     RMTemplate::get()->add_head($metas);
     return $post_data;
 }
示例#14
0
 function _copyFile($chmod)
 {
     $matched = array();
     if (!preg_match("/\\.([a-zA-Z0-9]+)\$/", $this->mediaName, $matched)) {
         $this->setErrors(_ER_UP_INVALIDFILENAME);
         return false;
     }
     if (isset($this->targetFileName)) {
         $this->savedFileName = $this->targetFileName;
     } else {
         if (isset($this->prefix)) {
             $this->savedFileName = uniqid($this->prefix) . '.' . strtolower($matched[1]);
         } else {
             $this->savedFileName = strtolower($this->mediaName);
         }
     }
     $fdata = pathinfo($this->savedFileName);
     $this->savedFileName = TextCleaner::sweetstring($fdata['filename']) . ($fdata['extension'] != '' ? '.' . $fdata['extension'] : '');
     $fdata = pathinfo($this->savedFileName);
     if (file_exists($this->uploadDir . '/' . $this->savedFileName)) {
         $num = 1;
         while (file_exists($this->uploadDir . '/' . $this->savedFileName)) {
             $this->savedFileName = $fdata['filename'] . '-' . $num . ($fdata['extension'] != '' ? '.' . $fdata['extension'] : '');
             $num++;
         }
     }
     $this->savedDestination = $this->uploadDir . '/' . $this->savedFileName;
     if (!move_uploaded_file($this->mediaTmpName, $this->savedDestination)) {
         $this->setErrors(sprintf(_ER_UP_FAILEDSAVEFILE, $this->savedDestination));
         return false;
     }
     // Check IE XSS before returning success
     $ext = strtolower(substr(strrchr($this->savedDestination, '.'), 1));
     if (in_array($ext, $this->imageExtensions)) {
         $info = @getimagesize($this->savedDestination);
         if ($info === false || $this->imageExtensions[(int) $info[2]] != $ext) {
             $this->setErrors(_ER_UP_SUSPICIOUSREFUSED);
             @unlink($this->savedDestination);
             return false;
         }
     }
     @chmod($this->savedDestination, $chmod);
     return true;
 }
示例#15
0
/**
* @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> &raquo; <a href='items.php'>" . __('Downloads', 'dtransport') . "</a> &raquo; " . __('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();
}
示例#16
0
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();
}
示例#17
0
 /**
  * @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', '');
 }
示例#18
0
/**
* @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> &raquo; " . __('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();
}
示例#19
0
/**
* @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();
}
示例#20
0
/**
* @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;
}
示例#21
0
 static function bad_protocol_once2($matches)
 {
     global $aprotocols;
     $allowed_protocols = $aprotocols;
     if (is_array($matches)) {
         if (!isset($matches[1]) || empty($matches[1])) {
             return '';
         }
         $string = $matches[1];
     } else {
         $string = $matches;
     }
     $string2 = TextCleaner::decode_entities($string);
     $string2 = preg_replace('/\\s/', '', $string2);
     $string2 = TextCleaner::no_null($string2);
     $string2 = strtolower($string2);
     $allowed = false;
     foreach ((array) $allowed_protocols as $one_protocol) {
         if (strtolower($one_protocol) == $string2) {
             $allowed = true;
             break;
         }
     }
     if ($allowed) {
         return "{$string2}:";
     } else {
         return '';
     }
 }
示例#22
0
/**
* 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&amp;action=logs&amp;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&amp;action=logs&amp;id=' . $item->id() . '/&amp;op=edit&amp;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&amp;action=logs&amp;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&amp;action=logs&amp;id=' . $item->id()), 1, __('Log saved successfully!', 'dtransport'));
}
示例#23
0
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());
    }
}
示例#24
0
/**
 * Agregamos nuevos editores a la base de datos
 */
function save_editor($edit = false)
{
    global $xoopsConfig, $xoopsSecurity;
    $page = rmc_server_var($_POST, 'page', 1);
    if (!$xoopsSecurity->check()) {
        redirectMsg('editors.php?page=' . $page, __('Operation not allowed!', 'mywords'), 1);
        die;
    }
    if ($edit) {
        $id = rmc_server_var($_POST, 'id', 0);
        if ($id <= 0) {
            redirectMsg('editors.php?page=' . $page, __('Editor ID has not been provided!', 'mywords'), 1);
            die;
        }
        $editor = new MWEditor($id);
        if ($editor->isNew()) {
            redirectMsg('editors.php?page=' . $page, __('Editor has not been found!', 'mywords'), 1);
            die;
        }
    } else {
        $editor = new MWEditor();
    }
    $name = rmc_server_var($_POST, 'name', '');
    $bio = rmc_server_var($_POST, 'bio', '');
    $uid = rmc_server_var($_POST, 'new_user', 0);
    $perms = rmc_server_var($_POST, 'perms', array());
    $short = rmc_server_var($_POST, 'short', '');
    if (trim($name) == '') {
        redirectMsg('editors.php?page=' . $page, __('You must provide a display name for this editor!', 'mywords'), 1);
        die;
    }
    if ($uid <= 0) {
        redirectMsg('editors.php?page=' . $page, __('You must specify a registered user ID for this editor!', 'mywords'), 1);
        die;
    }
    // Check if XoopsUser is already register
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("mw_editors") . " WHERE uid={$uid}";
    if ($edit) {
        $sql .= " AND id_editor<>" . $editor->id();
    }
    list($num) = $db->fetchRow($db->query($sql));
    if ($num > 0) {
        redirectMsg('editors.php?page=' . $page, __('This user has been registered as editor before.', 'mywords'), 1);
        die;
    }
    $editor->setVar('name', $name);
    $editor->setVar('shortname', TextCleaner::sweetstring($short != '' ? $short : $name));
    $editor->setVar('bio', $bio);
    $editor->setVar('uid', $uid);
    $editor->setVar('privileges', $perms);
    if (!$editor->save()) {
        redirectMsg('editors.php?page=' . $page, __('Errors occurs while trying to save editor data', 'mywords') . '<br />' . $editor->errors(), 1);
        die;
    } else {
        redirectMsg('editors.php?page=' . $page, __('Database updated succesfully!', 'mywords'), 0);
        die;
    }
}
示例#25
0
 /**
  * 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;
 }
示例#26
0
function clonePage()
{
    $id = rmc_server_var($_GET, 'id', 0);
    $page = new QPPage($id);
    if ($page->isNew()) {
        redirectMsg('pages.php', __('Specified page does not exists!', 'qpages'), 1);
        die;
    }
    $page->setNew();
    $page->setTitle($page->getTitle() . ' [cloned]');
    $page->setFriendTitle(TextCleaner::sweetstring($page->getTitle()));
    if (!$page->save()) {
        redirectMsg('pages.php', __('Page could not be cloned!', 'qpages'), 1);
        die;
    }
    redirectMsg('pages.php?op=edit&id=' . $page->getID(), __('Page cloned successfully!', 'qpages'), 0);
}
示例#27
0
/**
* @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);
    }
}
示例#28
0
 /**
  * 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&amp;id=' . $com->id() . '&amp;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&amp;id=' . $com->id() . '&amp;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;
     }
 }
示例#29
0
 /**
  * Add tags to database
  * @param string|array Tags names
  * @return array Tags saved ID
  */
 public function add_tags($tags)
 {
     if (!is_array($tags)) {
         $tags = array($tags);
     }
     if (empty($tags)) {
         return;
     }
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT id_tag, shortname FROM " . $db->prefix('mw_tags') . " WHERE ";
     $sa = '';
     foreach ($tags as $tag) {
         $sa .= $sa == '' ? "shortname='" . TextCleaner::sweetstring($tag) . "'" : " OR shortname='" . TextCleaner::sweetstring($tag) . "'";
     }
     $result = $db->query($sql . $sa);
     $existing = array();
     $ids = array();
     while ($row = $db->fetchArray($result)) {
         $existing[$row['shortname']] = $row['id_tag'];
         $ids[] = $row['id_tag'];
     }
     $sa = '';
     foreach ($tags as $tag) {
         if ($tag == '') {
             continue;
         }
         $short = TextCleaner::sweetstring($tag);
         if (isset($existing[$short])) {
             continue;
         }
         $sql = "INSERT INTO " . $db->prefix("mw_tags") . " (`tag`,`shortname`,`posts`) VALUES ('{$tag}','{$short}','0')";
         if ($db->queryF($sql)) {
             $ids[] = $db->getInsertId();
         }
     }
     return empty($ids) ? array() : $ids;
 }
示例#30
0
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;
}