Ejemplo n.º 1
0
 public function test___class()
 {
     $instance = XoopsLogger::getInstance();
     $this->assertInstanceOf($this->myclass, $instance);
     $value = $instance->tutu('tutu');
     $this->assertSame(null, $value);
 }
Ejemplo n.º 2
0
 /**
  * Get a reference to the only instance of database class and connects to DB
  *
  * if the class has not been instantiated yet, this will also take
  * care of that
  *
  * @static
  * @staticvar object  The only instance of database class
  * @return object Reference to the only instance of database class
  */
 static function &getDatabaseConnection()
 {
     static $instance;
     if (!isset($instance)) {
         if (file_exists($file = XOOPS_ROOT_PATH . '/class/database/' . XOOPS_DB_TYPE . 'database.php')) {
             require_once $file;
             if (!defined('XOOPS_DB_PROXY')) {
                 $class = 'Xoops' . ucfirst(XOOPS_DB_TYPE) . 'DatabaseSafe';
             } else {
                 $class = 'Xoops' . ucfirst(XOOPS_DB_TYPE) . 'DatabaseProxy';
             }
             $xoopsPreload =& XoopsPreload::getInstance();
             $xoopsPreload->triggerEvent('core.class.database.databasefactory.connection', array(&$class));
             $instance = new $class();
             $instance->setLogger(XoopsLogger::getInstance());
             $instance->setPrefix(XOOPS_DB_PREFIX);
             if (!$instance->connect()) {
                 trigger_error('notrace:Unable to connect to database', E_USER_ERROR);
             }
         } else {
             trigger_error('notrace:Failed to load database of type: ' . XOOPS_DB_TYPE . ' in file: ' . __FILE__ . ' at line ' . __LINE__, E_USER_WARNING);
         }
     }
     return $instance;
 }
Ejemplo n.º 3
0
function get_modules_ajax()
{
    XoopsLogger::getInstance()->activated = false;
    XoopsLogger::getInstance()->renderingEnabled = false;
    $db = Database::getInstance();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("modules");
    $page = rmc_server_var($_POST, 'page', 1);
    $limit = RMFunctions::configs('mods_number');
    list($num) = $db->fetchRow($db->query($sql));
    $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('javascript:;" onclick="get_mods_page({PAGE_NUM})');
    $sql = 'SELECT * FROM ' . $db->prefix('modules') . " ORDER BY mid, weight LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $installed_mods = array();
    while ($row = $db->fetchArray($result)) {
        $mod = new XoopsModule();
        $mod->assignVars($row);
        $installed_mods[] = $mod;
    }
    include RMTemplate::get()->get_template('rmc_mods_installed.php', 'module', 'rmcommon');
    die;
}
Ejemplo n.º 4
0
 public function footer()
 {
     global $xoopsConfig, $xoopsOption, $xoopsTpl, $xoTheme, $rmc_config, $xoopsModule;
     $xoopsLogger =& XoopsLogger::getInstance();
     $xoopsLogger->stopTime('Module display');
     if (!headers_sent()) {
         header('Content-Type:text/html; charset=' . _CHARSET);
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Cache-Control: private, no-cache');
         header("Cache-Control: post-check=0, pre-check=0", false);
         header('Pragma: no-cache');
     }
     //@internal: using global $xoTheme dereferences the variable in old versions, this does not
     //if (!isset($xoTheme)) $xoTheme =& $GLOBALS['xoTheme'];
     if (!isset($xoTheme)) {
         $xoTheme =& $GLOBALS['xoTheme'];
     }
     if (isset($xoopsOption['template_main']) && $xoopsOption['template_main'] != $xoTheme->contentTemplate) {
         trigger_error("xoopsOption[template_main] should be defined before call xoops_cp_header function", E_USER_WARNING);
         if (false === strpos($xoopsOption['template_main'], ':')) {
             $xoTheme->contentTemplate = 'db:' . $xoopsOption['template_main'];
         } else {
             $xoTheme->contentTemplate = $xoopsOption['template_main'];
         }
     }
     $metas = $xoTheme->metas['script'];
     $xoTheme->metas['script'] = array();
     foreach ($metas as $id => $meta) {
         if (strpos($id, 'jquery/jquery.js') === FALSE && strpos($id, 'jquery/plugins/jquery.ui.js') === FALSE) {
             $xoTheme->metas['script'][$id] = $meta;
         }
     }
     // Check if current theme have a replacement for template
     if (preg_match("/^db:(.*)/i", $xoTheme->contentTemplate, $match)) {
         $file = RMCPATH . '/themes/' . $rmc_config['theme'] . '/modules/' . $xoopsModule->dirname() . '/' . $match[1];
         if (is_file($file)) {
             $xoTheme->contentTemplate = $file;
         }
     }
     $xoTheme->render();
     $xoopsLogger->stopTime();
     // RMCommon Templates
     RMTemplate::get()->footer();
     die;
 }
Ejemplo n.º 5
0
 function footer()
 {
     global $xoopsConfig, $xoopsOption, $xoopsTpl, $xoTheme;
     $xoopsLogger =& XoopsLogger::getInstance();
     $xoopsLogger->stopTime('Module display');
     if (!headers_sent()) {
         header('Content-Type:text/html; charset=' . _CHARSET);
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Cache-Control: private, no-cache');
         header('Pragma: no-cache');
     }
     //@internal: using global $xoTheme dereferences the variable in old versions, this does not
     if (!isset($xoTheme)) {
         $xoTheme =& $GLOBALS['xoTheme'];
     }
     $xoTheme->render();
     $xoopsLogger->stopTime();
     ob_end_flush();
 }
Ejemplo n.º 6
0
<?php

// $Id: upload.php 825 2011-12-09 00:06:11Z i.bitcero $
// --------------------------------------------------------------
// Red México Common Utilities
// A framework for Red México Modules
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// 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') {
Ejemplo n.º 7
0
 public function __construct()
 {
     $this->db = XoopsDatabaseFactory::getDatabase();
     $this->db->setPrefix(XOOPS_DB_PREFIX);
     $this->db->setLogger(XoopsLogger::getInstance());
 }
Ejemplo n.º 8
0
$xoops = new xos_kernel_Xoops2();
$xoops->pathTranslation();
$xoopsRequestUri =& $_SERVER['REQUEST_URI'];
// Deprecated (use the corrected $_SERVER variable now)
/**
 * Create Instance of xoopsSecurity Object and check Supergolbals
 */
XoopsLoad::load('xoopssecurity');
$xoopsSecurity = new XoopsSecurity();
$xoopsSecurity->checkSuperglobals();
/**
 * Create Instantance XoopsLogger Object
 */
XoopsLoad::load('xoopslogger');
$xoopsLogger =& XoopsLogger::getInstance();
$xoopsErrorHandler =& XoopsLogger::getInstance();
$xoopsLogger->startTime();
$xoopsLogger->startTime('XOOPS Boot');
/**
 * Include Required Files
 */
include_once $xoops->path('kernel/object.php');
include_once $xoops->path('class/criteria.php');
include_once $xoops->path('class/module.textsanitizer.php');
include_once $xoops->path('include/functions.php');
/**
 * YOU SHOULD NEVER USE THE FOLLOWING CONSTANT, IT WILL BE REMOVED
 */
/**
 * Set cookie dope for multiple subdomains remove the '.'. to use top level dope for session cookie;
 * Requires functions
Ejemplo n.º 9
0
 function db_manager()
 {
     $this->db = XoopsDatabaseFactory::getDatabase();
     $this->db->setPrefix(XOOPS_DB_PREFIX);
     $this->db->setLogger(XoopsLogger::getInstance());
 }
Ejemplo n.º 10
0
function make_cblock()
{
    global $xoopsUser, $xoopsOption;
    $xoopsblock = new XoopsBlock();
    $cc_block = $cl_block = $cr_block = '';
    $arr = array();
    if ($xoopsOption['theme_use_smarty'] == 0) {
        if (!isset($GLOBALS['xoopsTpl']) || !is_object($GLOBALS['xoopsTpl'])) {
            include_once $GLOBALS['xoops']->path('class/template.php');
            $xoopsTpl = new XoopsTpl();
        } else {
            $xoopsTpl =& $GLOBALS['xoopsTpl'];
        }
        if (is_object($xoopsUser)) {
            $block_arr = $xoopsblock->getAllBlocksByGroup($xoopsUser->getGroups(), true, XOOPS_CENTERBLOCK_ALL, XOOPS_BLOCK_VISIBLE);
        } else {
            $block_arr = $xoopsblock->getAllBlocksByGroup(XOOPS_GROUP_ANONYMOUS, true, XOOPS_CENTERBLOCK_ALL, XOOPS_BLOCK_VISIBLE);
        }
        $block_count = count($block_arr);
        $xoopsLogger = XoopsLogger::getInstance();
        for ($i = 0; $i < $block_count; ++$i) {
            $bcachetime = (int) $block_arr[$i]->getVar('bcachetime');
            if (empty($bcachetime)) {
                $xoopsTpl->caching = 0;
            } else {
                $xoopsTpl->caching = 2;
                $xoopsTpl->cache_lifetime = $bcachetime;
            }
            $btpl = $block_arr[$i]->getVar('template');
            if ($btpl != '') {
                if (empty($bcachetime) || !$xoopsTpl->is_cached('db:' . $btpl)) {
                    $xoopsLogger->addBlock($block_arr[$i]->getVar('name'));
                    $bresult =& $block_arr[$i]->buildBlock();
                    if (!$bresult) {
                        continue;
                    }
                    $xoopsTpl->assign_by_ref('block', $bresult);
                    $bcontent =& $xoopsTpl->fetch('db:' . $btpl);
                    $xoopsTpl->clear_assign('block');
                } else {
                    $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime);
                    $bcontent =& $xoopsTpl->fetch('db:' . $btpl);
                }
            } else {
                $bid = $block_arr[$i]->getVar('bid');
                if (empty($bcachetime) || !$xoopsTpl->is_cached('db:system_dummy.tpl', 'blk_' . $bid)) {
                    $xoopsLogger->addBlock($block_arr[$i]->getVar('name'));
                    $bresult =& $block_arr[$i]->buildBlock();
                    if (!$bresult) {
                        continue;
                    }
                    $xoopsTpl->assign_by_ref('dummy_content', $bresult['content']);
                    $bcontent =& $xoopsTpl->fetch('db:system_dummy.tpl', 'blk_' . $bid);
                    $xoopsTpl->clear_assign('block');
                } else {
                    $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime);
                    $bcontent =& $xoopsTpl->fetch('db:system_dummy.tpl', 'blk_' . $bid);
                }
            }
            $title = $block_arr[$i]->getVar('title');
            switch ($block_arr[$i]->getVar('side')) {
                case XOOPS_CENTERBLOCK_CENTER:
                    if ($title != '') {
                        $cc_block .= '<tr valign="top"><td colspan="2"><strong>' . $title . '</strong><hr />' . $bcontent . '<br><br></td></tr>' . "\n";
                    } else {
                        $cc_block .= '<tr><td colspan="2">' . $bcontent . '<br><br></td></tr>' . "\n";
                    }
                    break;
                case XOOPS_CENTERBLOCK_LEFT:
                    if ($title != '') {
                        $cl_block .= '<p><strong>' . $title . '</strong><hr />' . $bcontent . '</p>' . "\n";
                    } else {
                        $cl_block .= '<p>' . $bcontent . '</p>' . "\n";
                    }
                    break;
                case XOOPS_CENTERBLOCK_RIGHT:
                    if ($title != '') {
                        $cr_block .= '<p><strong>' . $title . '</strong><hr />' . $bcontent . '</p>' . "\n";
                    } else {
                        $cr_block .= '<p>' . $bcontent . '</p>' . "\n";
                    }
                    break;
                default:
                    break;
            }
            unset($bcontent, $title);
        }
        echo '<table width="100%">' . $cc_block . '<tr valign="top"><td width="50%">' . $cl_block . '</td><td width="50%">' . $cr_block . '</td></tr></table>' . "\n";
    }
}
Ejemplo n.º 11
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @package         kernel
 * @since           2.0.0
 * @version         $Id: footer.php 12537 2014-05-19 14:19:33Z beckmi $
 */
defined('XOOPS_ROOT_PATH') || die('Restricted access');
$xoopsPreload =& XoopsPreload::getInstance();
$xoopsPreload->triggerEvent('core.footer.start');
if (!defined("XOOPS_FOOTER_INCLUDED")) {
    define("XOOPS_FOOTER_INCLUDED", 1);
    $xoopsLogger =& XoopsLogger::getInstance();
    $xoopsLogger->stopTime('Module display');
    if ($xoopsOption['theme_use_smarty'] == 0) {
        // the old way
        $footer = htmlspecialchars($xoopsConfigMetaFooter['footer']) . '<br /><div class="txtcenter small">Powered by XOOPS &copy; <a href="http://xoops.sourceforge.net" rel="external" title="The XOOPS Project">The XOOPS Project</a></div>';
        if (isset($xoopsOption['template_main'])) {
            $xoopsTpl->caching = 0;
            $xoopsTpl->display('db:' . $xoopsOption['template_main']);
        }
        if (!isset($xoopsOption['show_rblock'])) {
            $xoopsOption['show_rblock'] = 0;
        }
        themefooter($xoopsOption['show_rblock'], $footer);
        xoops_footer();
    } else {
        // RMV-NOTIFY
Ejemplo n.º 12
0
 /**
  * Deprecated, use getInstance() instead
  */
 public function instance()
 {
     return XoopsLogger::getInstance();
 }
Ejemplo n.º 13
0
 function eventCoreClassTheme_blocksRetrieveBlocks($args)
 {
     if (DefacerCorePreload::isActive()) {
         //$args[2] = array();
         $class =& $args[0];
         $template =& $args[1];
         $block_arr =& $args[2];
         foreach ($block_arr as $key => $xobject) {
             if (strpos($xobject->getVar('title'), '_') !== 0) {
                 continue;
             }
             $block = array('id' => $xobject->getVar('bid'), 'module' => $xobject->getVar('dirname'), 'title' => ltrim($xobject->getVar('title'), '_'), 'weight' => $xobject->getVar('weight'), 'lastmod' => $xobject->getVar('last_modified'));
             $bcachetime = intval($xobject->getVar('bcachetime'));
             if (empty($bcachetime)) {
                 $template->caching = 0;
             } else {
                 $template->caching = 2;
                 $template->cache_lifetime = $bcachetime;
             }
             $template->setCompileId($xobject->getVar('dirname', 'n'));
             $tplName = ($tplName = $xobject->getVar('template')) ? "db:{$tplName}" : 'db:system_block_dummy.html';
             $cacheid = $class->generateCacheId('blk_' . $xobject->getVar('bid'));
             $xoopsLogger =& XoopsLogger::getInstance();
             if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
                 $xoopsLogger->addBlock($xobject->getVar('name'));
                 if ($bresult = $xobject->buildBlock()) {
                     $template->assign('block', $bresult);
                     $block['content'] = $template->fetch($tplName, $cacheid);
                 } else {
                     $block = false;
                 }
             } else {
                 $xoopsLogger->addBlock($xobject->getVar('name'), true, $bcachetime);
                 $block['content'] = $template->fetch($tplName, $cacheid);
             }
             $template->setCompileId();
             $template->assign("xoops_block_{$block['id']}", $block);
             unset($block_arr[$key]);
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Render the page
  *
  * The theme engine builds pages from 2 templates: canvas and content.
  *
  * A module can call this method directly and specify what templates the theme engine must use.
  * If render() hasn't been called before, the theme defaults will be used for the canvas and
  * page template (and xoopsOption['template_main'] for the content).
  *
  * @param string $canvasTpl  The canvas template, if different from the theme default
  * @param string $pageTpl    The page template, if different from the theme default (unsupported, 2.3+ only)
  * @param string $contentTpl The content template
  * @param array  $vars       Template variables to send to the template engine
  *
  * @return bool
  */
 public function render($canvasTpl = null, $pageTpl = null, $contentTpl = null, $vars = array())
 {
     if ($this->renderCount) {
         return false;
     }
     $xoopsLogger = XoopsLogger::getInstance();
     $xoopsLogger->startTime('Page rendering');
     xoops_load('xoopscache');
     $cache = XoopsCache::getInstance();
     //Get meta information for cached pages
     if ($this->contentCacheLifetime && $this->contentCacheId && ($content = $cache->read($this->contentCacheId))) {
         //we need to merge metas set by blocks ) with the module cached meta
         $this->htmlHeadStrings = array_merge($this->htmlHeadStrings, $content['htmlHeadStrings']);
         foreach ($content['metas'] as $type => $value) {
             $this->metas[$type] = array_merge($this->metas[$type], $content['metas'][$type]);
         }
         $GLOBALS['xoopsOption']['xoops_pagetitle'] = $content['xoops_pagetitle'];
         $GLOBALS['xoopsOption']['xoops_module_header'] = $content['header'];
     }
     if (!empty($GLOBALS['xoopsOption']['xoops_pagetitle'])) {
         $this->template->assign('xoops_pagetitle', $GLOBALS['xoopsOption']['xoops_pagetitle']);
     }
     $header = empty($GLOBALS['xoopsOption']['xoops_module_header']) ? $this->template->get_template_vars('xoops_module_header') : $GLOBALS['xoopsOption']['xoops_module_header'];
     //save meta information of cached pages
     if ($this->contentCacheLifetime && $this->contentCacheId && !$contentTpl) {
         $content['htmlHeadStrings'] = $this->htmlHeadStrings;
         $content['metas'] = $this->metas;
         $content['xoops_pagetitle'] =& $this->template->get_template_vars('xoops_pagetitle');
         $content['header'] = $header;
         $cache->write($this->contentCacheId, $content);
     }
     //  @internal : Lame fix to ensure the metas specified in the xoops config page don't appear twice
     $old = array('robots', 'keywords', 'description', 'rating', 'author', 'copyright');
     foreach ($this->metas['meta'] as $name => $value) {
         if (in_array($name, $old)) {
             $this->template->assign("xoops_meta_{$name}", htmlspecialchars($value, ENT_QUOTES));
             unset($this->metas['meta'][$name]);
         }
     }
     // We assume no overlap between $GLOBALS['xoopsOption']['xoops_module_header'] and $this->template->get_template_vars( 'xoops_module_header' ) ?
     $this->template->assign('xoops_module_header', $this->renderMetas(null, true) . "\n" . $header);
     if ($canvasTpl) {
         $this->canvasTemplate = $canvasTpl;
     }
     if ($contentTpl) {
         $this->contentTemplate = $contentTpl;
     }
     if (!empty($vars)) {
         $this->template->assign($vars);
     }
     if ($this->contentTemplate) {
         $this->content = $this->template->fetch($this->contentTemplate, $this->contentCacheId);
     }
     if ($this->bufferOutput) {
         $this->content .= ob_get_contents();
         ob_end_clean();
     }
     $this->template->assign_by_ref('xoops_contents', $this->content);
     // Do not cache the main (theme.html) template output
     $this->template->caching = 0;
     //mb -------------------------
     //        $this->template->display($this->path . '/' . $this->canvasTemplate);
     if (file_exists($this->path . '/' . $this->canvasTemplate)) {
         $this->template->display($this->path . '/' . $this->canvasTemplate);
     } else {
         $this->template->display($this->path . '/theme.tpl');
     }
     //mb -------------------------
     $this->renderCount++;
     $xoopsLogger->stopTime('Page rendering');
     return true;
 }
Ejemplo n.º 15
0
/**
 * @param $params
 * @param $smarty
 *
 * @return mixed
 */
function smarty_function_block($params, &$smarty)
{
    if (!isset($params['id'])) {
        return null;
    }
    $display_title = isset($params['display']) && $params['display'] === 'title';
    $display_none = isset($params['display']) && $params['display'] === 'none';
    $options = isset($params['options']) ? $params['options'] : false;
    $groups = isset($params['groups']) ? explode('|', $params['groups']) : false;
    $cache = isset($params['cache']) ? (int) $params['cache'] : false;
    $block_id = (int) $params['id'];
    static $block_objs;
    if (!isset($block_objs[$block_id])) {
        include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
        $blockObj = new XoopsBlock($block_id);
        if (!is_object($blockObj)) {
            return null;
        }
        $block_objs[$block_id] = $blockObj;
    } else {
        $blockObj = $block_objs[$block_id];
    }
    $user_groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
    static $allowed_blocks;
    if (count($allowed_blocks) == 0) {
        $allowed_blocks = XoopsBlock::getAllBlocksByGroup($user_groups, false);
    }
    if ($groups) {
        if (!array_intersect($user_groups, $groups)) {
            return null;
        }
    } else {
        if (!in_array($block_id, $allowed_blocks)) {
            return null;
        }
    }
    if ($options) {
        $blockObj->setVar('options', $options);
    }
    if ($cache) {
        $blockObj->setVar('bcachetime', $cache);
    }
    if ($display_title) {
        return $blockObj->getVar('title');
    }
    $xoopsLogger = XoopsLogger::getInstance();
    $template =& $GLOBALS['xoopsTpl'];
    $bcachetime = (int) $blockObj->getVar('bcachetime');
    if (empty($bcachetime)) {
        $template->caching = 0;
    } else {
        $template->caching = 2;
        $template->cache_lifetime = $bcachetime;
    }
    $template->setCompileId($blockObj->getVar('dirname', 'n'));
    $tplName = ($tplName = $blockObj->getVar('template')) ? "db:{$tplName}" : 'db:system_block_dummy.tpl';
    $cacheid = 'blk_' . $block_id;
    if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
        $xoopsLogger->addBlock($blockObj->getVar('name'));
        if (!($bresult = $blockObj->buildBlock())) {
            return null;
        }
        if (!$display_none) {
            $template->assign('block', $bresult);
            $template->display($tplName, $cacheid);
        }
    } else {
        $xoopsLogger->addBlock($blockObj->getVar('name'), true, $bcachetime);
        if (!$display_none) {
            $template->display($tplName, $cacheid);
        }
    }
    $template->setCompileId($blockObj->getVar('dirname', 'n'));
    return null;
}
Ejemplo n.º 16
0
 /**
  * Render the page
  *
  * The theme engine builds pages from 2 templates: canvas and content.
  *
  * A module can call this method directly and specify what templates the theme engine must use.
  * If render() hasn't been called before, the theme defaults will be used for the canvas and
  * page template (and xoopsOption['template_main'] for the content).
  *
  * @param string $canvasTpl The canvas template, if different from the theme default
  * @param string $pageTpl The page template, if different from the theme default (unsupported, 2.3+ only)
  * @param string $contentTpl The content template
  * @param array $vars Template variables to send to the template engine
  */
 function render($canvasTpl = null, $pageTpl = null, $contentTpl = null, $vars = array())
 {
     if ($this->renderCount) {
         return false;
     }
     $xoopsLogger =& XoopsLogger::getInstance();
     $xoopsLogger->startTime('Page rendering');
     //  @internal : Lame fix to ensure the metas specified in the xoops config page don't appear twice
     $old = array('robots', 'keywords', 'description', 'rating', 'author', 'copyright');
     foreach ($this->metas['meta'] as $name => $value) {
         if (in_array($name, $old)) {
             $this->template->assign("xoops_meta_{$name}", htmlspecialchars($value, ENT_QUOTES));
             unset($this->metas['meta'][$name]);
         }
     }
     if ($canvasTpl) {
         $this->canvasTemplate = $canvasTpl;
     }
     if ($contentTpl) {
         $this->contentTemplate = $contentTpl;
     }
     if (!empty($vars)) {
         $this->template->assign($vars);
     }
     if ($this->contentTemplate) {
         $this->content = $this->template->fetch($this->contentTemplate, $this->contentCacheId);
     }
     if ($this->bufferOutput) {
         $this->content .= ob_get_contents();
         ob_end_clean();
     }
     $this->template->assign_by_ref('xoops_contents', $this->content);
     // We assume no overlap between $GLOBALS['xoopsOption']['xoops_module_header'] and $this->template->get_template_vars( 'xoops_module_header' ) ?
     $header = empty($GLOBALS['xoopsOption']['xoops_module_header']) ? $this->template->get_template_vars('xoops_module_header') : $GLOBALS['xoopsOption']['xoops_module_header'];
     $this->template->assign('xoops_module_header', $this->renderMetas(null, true) . "\n" . $header);
     if (!empty($GLOBALS['xoopsOption']['xoops_pagetitle'])) {
         $this->template->assign('xoops_pagetitle', $GLOBALS['xoopsOption']['xoops_pagetitle']);
     }
     // Do not cache the main (theme.html) template output
     $this->template->caching = 0;
     $this->template->display($this->path . '/' . $this->canvasTemplate);
     $this->renderCount++;
     $xoopsLogger->stopTime('Page rendering');
 }
Ejemplo n.º 17
0
/**
* @desc Almacena la información del grupo de imágenes
**/
function saveBulkImages()
{
    global $util, $mc, $xoopsUser;
    XoopsLogger::getInstance()->activated = false;
    XoopsLogger::getInstance()->renderingEnabled = false;
    set_time_limit(0);
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $ruta = "page={$page}&search={$search}&owner={$uid}&sort={$sort}&mode={$mode}";
    if ($xoopsUser->uid() == $uid) {
        $xu = $xoopsUser;
    } else {
        $xu = new XoopsUser($uid);
    }
    //Verificamos si el usuario se encuentra registrado
    $user = new GSUser($xu->uname());
    if ($user->isNew()) {
        //Insertamos información del usuario
        $user->setUid($uid);
        $user->setUname($xu->uname());
        $user->setQuota($mc['quota'] * 1024 * 1024);
        $user->setDate(time());
        if (!$user->save()) {
            send_error(__('User owner could not be created!', 'galleries') . "<br />" . $user->errors());
            die;
        } else {
            mkdir($mc['storedir'] . "/" . $user->uname());
            mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
            mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
        }
    } else {
        @mkdir($mc['storedir'] . "/" . $user->uname());
        @mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
        @mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
    }
    // Insertamos las etiquetas
    $tgs = explode(",", $tags);
    /**
     * @desc Almacena los ids de las etiquetas que se asignarán a la imágen
     */
    $ret = array();
    foreach ($tgs as $k) {
        $k = trim($k);
        if ($k == '') {
            continue;
        }
        // Comprobamos que la palabra tenga la longitud permitida
        if (strlen($k) < $mc['min_tag'] || strlen($k) > $mc['max_tag']) {
            continue;
        }
        // Creamos la etiqueta
        $tag = new GSTag($k);
        if (!$tag->isNew()) {
            // Si ya existe nos saltamos
            $ret[] = $tag->id();
            continue;
        }
        $tag->setTag($k);
        if ($tag->save()) {
            $ret[] = $tag->id();
        }
    }
    $errors = '';
    $k = 1;
    include_once RMCPATH . '/class/uploader.php';
    $updir = $mc['storedir'] . "/" . $xu->uname();
    $upths = $mc['storedir'] . "/" . $xu->uname() . "/ths";
    // Cargamos la imágen
    if (!file_exists($updir)) {
        mkdir($updir, 511);
    }
    if (!file_exists($upths)) {
        mkdir($upths, 511);
    }
    $uploader = new RMFileUploader($updir, $mc['size_image'] * 1024, array('gif', 'jpg', 'jpeg', 'png'));
    $err = array();
    if (!$uploader->fetchMedia('Filedata')) {
        send_error($uploader->getErrors());
    }
    if (!$uploader->upload()) {
        send_error($uploader->getErrors());
    }
    // Insertamos el archivo en la base de datos
    $img = new GSImage();
    $img->setTitle($uploader->savedFileName);
    $img->setOwner($uid);
    $img->setPublic(2);
    $img->setCreated(time());
    $img->setImage($uploader->getSavedFileName());
    if (!$image->save()) {
        unlink($uploader->savedDestination);
        send_error(__('File could not be inserted to database!', 'galleries'));
    }
    $ret['message'] = '1';
    $ret['id'] = $image->id();
    echo json_encode($ret);
    die;
}
Ejemplo n.º 18
0
 /**
  * xos_logos_PageBuilder::buildBlock()
  *
  * @param mixed $xobject
  * @param mixed $template
  * @return
  */
 function buildBlock($xobject, &$template)
 {
     // The lame type workaround will change
     // bid is added temporarily as workaround for specific block manipulation
     $block = array('id' => $xobject->getVar('bid'), 'module' => $xobject->getVar('dirname'), 'title' => $xobject->getVar('title'), 'weight' => $xobject->getVar('weight'), 'lastmod' => $xobject->getVar('last_modified'));
     $bcachetime = intval($xobject->getVar('bcachetime'));
     if (empty($bcachetime)) {
         $template->caching = 0;
     } else {
         $template->caching = 2;
         $template->cache_lifetime = $bcachetime;
     }
     $template->setCompileId($xobject->getVar('dirname', 'n'));
     $tplName = ($tplName = $xobject->getVar('template')) ? "db:{$tplName}" : 'db:system_block_dummy.html';
     $cacheid = $this->generateCacheId('blk_' . $xobject->getVar('bid'));
     $xoopsLogger =& XoopsLogger::getInstance();
     if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
         //Get theme metas
         if ($this->theme && $bcachetime) {
             foreach ($this->theme->metas as $type => $value) {
                 $old[$type] = $this->theme->metas[$type];
             }
         }
         //build block
         $xoopsLogger->addBlock($xobject->getVar('name'));
         if ($bresult = $xobject->buildBlock()) {
             $template->assign('block', $bresult);
             $block['content'] = $template->fetch($tplName, $cacheid);
         } else {
             $block = false;
         }
         //check if theme added new metas
         if ($this->theme && $bcachetime) {
             $metas = array();
             foreach ($this->theme->metas as $type => $value) {
                 $dif = array_diff_assoc($this->theme->metas[$type], $old[$type]);
                 if (count($dif)) {
                     $metas[$type] = $dif;
                 }
             }
             if (count($metas)) {
                 xoops_load('xoopscache');
                 $cache =& XoopsCache::getInstance();
                 $cache->write($cacheid, $metas);
             }
         }
     } else {
         $xoopsLogger->addBlock($xobject->getVar('name'), true, $bcachetime);
         $block['content'] = $template->fetch($tplName, $cacheid);
     }
     //add block cached metas
     if ($this->theme && $bcachetime) {
         xoops_load('xoopscache');
         $cache =& XoopsCache::getInstance();
         if ($metas = $cache->read($cacheid)) {
             foreach ($metas as $type => $value) {
                 $this->theme->metas[$type] = array_merge($this->theme->metas[$type], $metas[$type]);
             }
         }
     }
     $template->setCompileId();
     return $block;
 }
Ejemplo n.º 19
0
 function buildBlock($bobj)
 {
     global $xoopsTpl, $xoTheme;
     $template = $xoopsTpl;
     $block = array('id' => $bobj->getVar('bid'), 'module' => $bobj->getVar('dirname'), 'title' => $bobj->getVar('name'), 'weight' => $bobj->getVar('weight'), 'type' => $bobj->getVar('element_type'));
     $bcachetime = intval($bobj->getVar('bcachetime'));
     if (empty($bcachetime)) {
         $template->caching = 0;
     } else {
         $template->caching = 2;
         $template->cache_lifetime = $bcachetime;
     }
     $template->setCompileId($bobj->getVar('dirname', 'n'));
     if ($bobj->getVar('element_type') == 'plugin') {
         $tplName = XOOPS_ROOT_PATH . '/modules/' . $bobj->getVar('element') . '/plugins/' . $bobj->getVar('dirname') . '/templates/blocks/' . $bobj->getVar('template');
     } elseif ($bobj->getVar('element_type') == 'theme') {
         $tplName = XOOPS_ROOT_PATH . '/themes/' . $bobj->getVar('dirname') . '/templates/blocks/' . $bobj->getVar('template');
     } else {
         $tplName = ($tplName = $bobj->getVar('template')) ? "db:{$tplName}" : 'db:system_block_dummy.html';
     }
     $cacheid = $xoTheme->generateCacheId('blk_' . $bobj->getVar('bid'));
     /**
      * , $bobj->getVar( 'show_func', 'n' )
      */
     $xoopsLogger =& XoopsLogger::getInstance();
     if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
         $xoopsLogger->addBlock($bobj->getVar('name'));
         if ($bresult = $bobj->buildBlock()) {
             $template->assign('block', $bresult);
             $block['content'] = $template->fetch($tplName, $cacheid);
         } else {
             $block = false;
         }
     } else {
         $xoopsLogger->addBlock($bobj->getVar('name'), true, $bcachetime);
         $block['content'] = $template->fetch($tplName, $cacheid);
     }
     $template->setCompileId();
     return $block;
 }
Ejemplo n.º 20
0
 public function footer()
 {
     global $xoopsConfig, $xoopsOption, $xoopsTpl, $xoTheme;
     $xoopsLogger = XoopsLogger::getInstance();
     $xoopsLogger->stopTime('Module display');
     if (!headers_sent()) {
         header('Content-Type:text/html; charset=' . _CHARSET);
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Cache-Control: private, no-cache');
         header('Pragma: no-cache');
     }
     //@internal: using global $xoTheme dereferences the variable in old versions, this does not
     if (!isset($xoTheme)) {
         $xoTheme = $GLOBALS['xoTheme'];
     }
     if (isset($GLOBALS['xoopsOption']['template_main']) && $GLOBALS['xoopsOption']['template_main'] != $xoTheme->contentTemplate) {
         trigger_error('xoopsOption[template_main] should be defined before call xoops_cp_header function', E_USER_WARNING);
         if (false === strpos($GLOBALS['xoopsOption']['template_main'], ':')) {
             $xoTheme->contentTemplate = 'db:' . $GLOBALS['xoopsOption']['template_main'];
         } else {
             $xoTheme->contentTemplate = $GLOBALS['xoopsOption']['template_main'];
         }
     }
     $xoTheme->render();
     $xoopsLogger->stopTime();
     ob_end_flush();
 }
Ejemplo n.º 21
0
 /**
  * Prepares the system for an AJAX response.
  * This function deactivate the XoopsLogger rendering
  */
 public function prepare_ajax_response()
 {
     error_reporting(0);
     XoopsLogger::getInstance()->activated = false;
 }
Ejemplo n.º 22
0
 /**
  * @desc Almacena toda la información de la API
  */
 public function trigger($event_name, $value = null)
 {
     $pre = $event_name;
     $event_name = strtolower(str_replace('.', '', $event_name));
     $args = func_get_args();
     if (!isset($this->_events[$event_name])) {
         return $value;
     }
     $xoopsLogger = XoopsLogger::getInstance();
     foreach ($this->_events[$event_name] as $event) {
         $args[1] =& $value;
         //$xoopsLogger->addExtra($pre, $event['class_name'].'::'.$event['method']);
         $value = call_user_func_array(array($event['class_name'], $event['method']), array_slice($args, 1));
     }
     return $value;
 }
Ejemplo n.º 23
0
 /**
  * Get content for this page block
  *
  * @param int $unique
  * @param bool $last
  * @return array
  */
 function render($template, $unique = 0)
 {
     $block = array('blockid' => $this->getVar('pageblockid'), 'tabid' => $this->getVar('tabid'), 'module' => $this->block->getVar('dirname'), 'title' => $this->getVar('title'), 'placement' => $this->getVar('placement'), 'weight' => $this->getVar('priority'));
     $xoopsLogger = XoopsLogger::getInstance();
     $bcachetime = intval($this->getVar('pbcachetime'));
     if (empty($bcachetime)) {
         $template->caching = 0;
     } else {
         $template->caching = 2;
         $template->cache_lifetime = $bcachetime;
     }
     $tplName = ($tplName = $this->block->getVar('template')) ? "db:{$tplName}" : "db:system_block_dummy.html";
     $cacheid = 'blk_' . $this->getVar('pageblockid');
     if ($this->getVar('cachebyurl')) {
         $cacheid .= "_" . md5($_SERVER['REQUEST_URI']);
     }
     if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
         $xoopsLogger->addBlock($this->block->getVar('title'));
         if (!($bresult = $this->block->buildBlock())) {
             return false;
         }
         $template->assign('block', $bresult);
         $block['content'] = $template->fetch($tplName, $cacheid);
     } else {
         $xoopsLogger->addBlock($this->block->getVar('name'), true, $bcachetime);
         $block['content'] = $template->fetch($tplName, $cacheid);
     }
     return $block;
 }
Ejemplo n.º 24
0
 /**
  * Deprecated, use getInstance() instead
  */
 function &instance()
 {
     return XoopsLogger::getInstance();
 }
Ejemplo n.º 25
0
 /**
  * xos_logos_PageBuilder::buildBlock()
  *
  * @param mixed $xobject
  * @param mixed $template
  * @return
  */
 function buildBlock($xobject, &$template)
 {
     // The lame type workaround will change
     // bid is added temporarily as workaround for specific block manipulation
     $block = array('id' => $xobject->getVar('bid'), 'module' => $xobject->getVar('dirname'), 'title' => $xobject->getVar('title'), 'weight' => $xobject->getVar('weight'), 'lastmod' => $xobject->getVar('last_modified'));
     $bcachetime = intval($xobject->getVar('bcachetime'));
     if (empty($bcachetime)) {
         $template->caching = 0;
     } else {
         $template->caching = 2;
         $template->cache_lifetime = $bcachetime;
     }
     $template->setCompileId($xobject->getVar('dirname', 'n'));
     $tplName = ($tplName = $xobject->getVar('template')) ? "db:{$tplName}" : 'db:system_block_dummy.html';
     $cacheid = $this->generateCacheId('blk_' . $xobject->getVar('bid'));
     /**
      * , $xobject->getVar( 'show_func', 'n' )
      */
     $xoopsLogger =& XoopsLogger::getInstance();
     if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
         $xoopsLogger->addBlock($xobject->getVar('name'));
         if ($bresult = $xobject->buildBlock()) {
             $template->assign('block', $bresult);
             $block['content'] = $template->fetch($tplName, $cacheid);
         } else {
             $block = false;
         }
     } else {
         $xoopsLogger->addBlock($xobject->getVar('name'), true, $bcachetime);
         $block['content'] = $template->fetch($tplName, $cacheid);
     }
     $template->setCompileId();
     return $block;
 }