/**
  * 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
  */
 function &getDatabaseConnection()
 {
     static $instance;
     if (!isset($instance)) {
         $file = XOOPS_ROOT_PATH . '/class/database/' . XOOPS_DB_TYPE . 'database.php';
         require_once $file;
         /* patch from */
         if (defined('XOOPS_DB_ALTERNATIVE') && class_exists(XOOPS_DB_ALTERNATIVE)) {
             $class = XOOPS_DB_ALTERNATIVE;
         } else {
             /* patch to */
             if (!defined('XOOPS_DB_PROXY')) {
                 $class = 'Xoops' . ucfirst(XOOPS_DB_TYPE) . 'DatabaseSafe';
             } else {
                 $class = 'Xoops' . ucfirst(XOOPS_DB_TYPE) . 'DatabaseProxy';
             }
         }
         $instance =& new $class();
         $instance->setLogger(XoopsLogger::instance());
         $instance->setPrefix(XOOPS_DB_PREFIX);
         if (!$instance->connect()) {
             trigger_error("notrace:Unable to connect to database", E_USER_ERROR);
         }
     }
     return $instance;
 }
Example #2
0
 public function test___class()
 {
     $instance = XoopsLogger::getInstance();
     $this->assertInstanceOf($this->myclass, $instance);
     $value = $instance->tutu('tutu');
     $this->assertSame(null, $value);
 }
Example #3
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;
 }
Example #4
0
 function _setupLogger()
 {
     require_once XOOPS_ROOT_PATH . '/class/logger.php';
     $this->mLogger =& XoopsLogger::instance();
     $this->mLogger->startTime();
     $GLOBALS['xoopsLogger'] =& $this->mLogger;
 }
Example #5
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;
}
Example #6
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;
 }
Example #7
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();
 }
Example #8
0
/**
 * @package     smarty xoopsplugin
 * 
 * @author	    Hu Zhenghui <*****@*****.**>
 *  
 * how to use
 * The following code inserted in the template
 *  
 * @param module string module dirname
 * @param file  string block funciton file
 * @param show_func string show block function
 * @param options= string show block function's option
 * @param cachetime int  cachetime Unit for seconds 
 * @param user mix Generate cache solution

<{freeBlkTpl id=1}>
    <link rel="stylesheet" href="<{$xoops_url}>/modules/tag/templates/style.css" />
    <div class="tag-cloud" style="line-height: 150%; padding: 5px;">
    <{foreach item=tag from=$block.tags}>
    	<span class="tag-level-<{$tag.level}>" style="font-size: <{$tag.font}>%; display: inline; padding-right: 5px;">
    		<a href="<{$xoops_url}>/modules/<{$block.tag_dirname}>/view.tag.php<{$smarty.const.URL_DELIMITER}><{$tag.id}>/" title="<{$tag.term}>"><{$tag.term}></a>
    	</span>
    <{/foreach}>
    </div>
<{/freeBlkTpl}>
*/
function smarty_block_freeBlkTpl($params, $content, &$smarty, &$repeat)
{
    static $old_block;
    if (empty($content)) {
        $old_block = $smarty->get_template_vars('block');
        if (!isset($params['id'])) {
            return;
        }
        $block_id = intval($params['id']);
        static $block_objs;
        $blockObj = $GLOBALS['xoopsTpl']->_tpl_vars['ezblocks'][$block_id];
        // ezsky hack
        if (empty($blockObj)) {
            return false;
        }
        $xoopsLogger =& XoopsLogger::instance();
        $template =& $GLOBALS['xoopsTpl'];
        xoops_load("cache");
        $cache_key = 'xoBlkTpl_' . md5(var_export($params, true));
        $bcachetime = intval($blockObj->getVar('bcachetime'));
        if (!$bcachetime || !($bresult = XoopsCache::read($cache_key))) {
            $xoopsLogger->addBlock($blockObj->getVar('name'));
            if (!($bresult = $blockObj->buildBlock())) {
                return;
            }
            if (isset($bcachetime)) {
                XoopsCache::write($cache_key, $bresult, $bcachetime);
            }
        } else {
            $xoopsLogger->addBlock($blockObj->getVar('name'), true, $bcachetime);
        }
        $old_block = $smarty->get_template_vars('block');
        $smarty->assign('block', $bresult);
    } else {
        echo $content;
        $smarty->assign('block', $old_block);
    }
}
Example #9
0
/**
 * XOOPS Block management
 * 
 * @copyright   The XOOPS project http://www.xoops.org/
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package     smarty xoopsplugin
 * @since       2.3.3 ezsky hack
 * @author      ezsky <*****@*****.**> 
 * @version     $Id: function.block.php $
 * @package     smarty xoops plugin
 *  Examples:
 *  <{freeBlock id=1}>                   displays just the block content 
 */
function smarty_function_freeBlock($params, &$smarty)
{
    if (!isset($params['id'])) {
        return;
    }
    $block_id = intval($params['id']);
    static $block_objs;
    $blockObjs = $smarty->get_template_vars('ezblocks');
    // ezsky hack
    $blockObj = $blockObjs[$block_id];
    if (empty($blockObj)) {
        return false;
    }
    $xoopsLogger =& XoopsLogger::instance();
    $template =& $GLOBALS['xoopsTpl'];
    $bcachetime = intval($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.html";
    $cacheid = 'blk_' . $block_id;
    if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
        $xoopsLogger->addBlock($blockObj->getVar('name'));
        if (!($bresult = $blockObj->buildBlock())) {
            return;
        }
        $template->assign('block', $bresult);
        $template->display($tplName, $cacheid);
    } else {
        $xoopsLogger->addBlock($blockObj->getVar('name'), true, $bcachetime);
        $template->display($tplName, $cacheid);
    }
    $template->setCompileId($blockObj->getVar('dirname', 'n'));
}
Example #10
0
 /**
  * Deprecated, use getInstance() instead
  */
 public function instance()
 {
     return XoopsLogger::getInstance();
 }
Example #11
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();
 }
 /**
  * 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;
 }
Example #13
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 XOOPS_ROOT_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::instance();
        for ($i = 0; $i < $block_count; $i++) {
            $bcachetime = intval($block_arr[$i]->getVar('bcachetime'));
            if (empty($bcachetime)) {
                $xoopsTpl->xoops_setCaching(0);
            } else {
                $xoopsTpl->xoops_setCaching(2);
                $xoopsTpl->xoops_setCacheTime($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.html', '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.html', 'blk_' . $bid);
                    $xoopsTpl->clear_assign('block');
                } else {
                    $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime);
                    $bcontent =& $xoopsTpl->fetch('db:system_dummy.html', '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";
    }
}
Example #14
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') {
Example #15
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;
}
Example #16
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'), 'module' => $this->block->getVar('dirname'), 'title' => $this->getVar('title'), 'weight' => $this->getVar('priority'));
     $xoopsLogger =& XoopsLogger::instance();
     $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('name'));
         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;
 }
Example #17
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
Example #18
0
 public function __construct()
 {
     $this->db = XoopsDatabaseFactory::getDatabase();
     $this->db->setPrefix(XOOPS_DB_PREFIX);
     $this->db->setLogger(XoopsLogger::getInstance());
 }
Example #19
0
 /**
  * Deprecated, use getInstance() instead
  */
 function &instance()
 {
     return XoopsLogger::getInstance();
 }
Example #20
0
 define("XOOPS_MATCH_START", 0);
 define("XOOPS_MATCH_END", 1);
 define("XOOPS_MATCH_EQUAL", 2);
 define("XOOPS_MATCH_CONTAIN", 3);
 define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH . "/uploads");
 define("XOOPS_THEME_PATH", XOOPS_ROOT_PATH . "/themes");
 // ----- BEGIN: Already refactored stuff just kept for compat purposes -----
 //define( "SMARTY_DIR", XOOPS_PATH . "/Frameworks/XoopsCore/Pyro/Smarty.xoobj/smarty/" );
 define("XOOPS_CACHE_PATH", XOOPS_VAR_PATH . "/Caches");
 define("XOOPS_COMPILE_PATH", XOOPS_VAR_PATH . "/Application Support/xoops_template_Smarty");
 // ----- END: Already refactored stuff just kept for compat purposes -----
 define("XOOPS_THEME_URL", XOOPS_URL . "/themes");
 define("XOOPS_UPLOAD_URL", XOOPS_URL . "/uploads");
 set_magic_quotes_runtime(0);
 include_once XOOPS_ROOT_PATH . '/class/logger.php';
 $GLOBALS['xoopsLogger'] =& XoopsLogger::instance();
 if (!defined('XOOPS_XMLRPC')) {
     define('XOOPS_DB_CHKREF', 1);
 } else {
     define('XOOPS_DB_CHKREF', 0);
 }
 // ############## Include common functions file ##############
 include_once XOOPS_ROOT_PATH . '/include/functions.php';
 // #################### Connect to DB ##################
 require_once XOOPS_ROOT_PATH . '/class/database/database.php';
 $GLOBALS['xoopsDB'] = $xoops->loadService('legacydb');
 if (!$GLOBALS['xoopsDB']->allowWebChanges) {
     define('XOOPS_DB_PROXY', 1);
 }
 // ################# Include required files ##############
 require_once XOOPS_ROOT_PATH . '/kernel/object.php';
Example #21
0
 function db_manager()
 {
     $this->db = XoopsDatabaseFactory::getDatabase();
     $this->db->setPrefix(XOOPS_DB_PREFIX);
     $this->db->setLogger(XoopsLogger::instance());
 }
Example #22
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');
 }
Example #23
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;
 }
Example #24
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]);
         }
     }
 }
Example #25
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;
 }
Example #26
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;
 }
Example #27
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
Example #28
0
 function renderLog()
 {
     $xoopsLogger =& XoopsLogger::instance();
     return $xoopsLogger->dumpAll();
 }
Example #29
0
set_magic_quotes_runtime(0);
if (function_exists('mb_http_output')) {
    mb_http_output('pass');
}
$image_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if (empty($image_id)) {
    header('Content-type: image/gif');
    readfile(XOOPS_UPLOAD_PATH . '/blank.gif');
    exit;
}
$xoopsOption['nocommon'] = 1;
include './mainfile.php';
include XOOPS_ROOT_PATH . '/include/functions.php';
include_once XOOPS_ROOT_PATH . '/class/logger.php';
include_once XOOPS_ROOT_PATH . "/class/module.textsanitizer.php";
$xoopsLogger =& XoopsLogger::instance();
$xoopsLogger->startTime();
include_once XOOPS_ROOT_PATH . '/class/database/databasefactory.php';
define('XOOPS_DB_PROXY', 1);
$xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection();
// ################# Include class manager file ##############
require_once XOOPS_ROOT_PATH . '/kernel/object.php';
require_once XOOPS_ROOT_PATH . '/class/criteria.php';
$imagehandler =& xoops_gethandler('image');
$criteria = new CriteriaCompo(new Criteria('i.image_display', 1));
$criteria->add(new Criteria('i.image_id', $image_id));
$image = $imagehandler->getObjects($criteria, false, true);
if (count($image) > 0) {
    header('Content-type: ' . $image[0]->getVar('image_mimetype'));
    header('Cache-control: max-age=31536000');
    header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 31536000) . 'GMT');
function smarty_function_block($params, &$smarty)
{
    if (!isset($params['id'])) {
        return;
    }
    $display_title = isset($params['display']) && $params['display'] == 'title' ? true : false;
    $display_none = isset($params['display']) && $params['display'] == 'none' ? true : false;
    $options = isset($params['options']) ? $params['options'] : false;
    $groups = isset($params['groups']) ? explode('|', $params['groups']) : false;
    $cache = isset($params['cache']) ? intval($params['cache']) : false;
    $block_id = intval($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;
        }
        $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;
        }
    } else {
        if (!in_array($block_id, $allowed_blocks)) {
            return;
        }
    }
    if ($options) {
        $blockObj->setVar('options', $options);
    }
    if ($cache) {
        $blockObj->setVar('bcachetime', $cache);
    }
    if ($display_title) {
        return $blockObj->getVar('title');
    }
    $xoopsLogger =& XoopsLogger::instance();
    $template =& $GLOBALS['xoopsTpl'];
    $bcachetime = intval($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.html";
    $cacheid = 'blk_' . $block_id;
    if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
        $xoopsLogger->addBlock($blockObj->getVar('name'));
        if (!($bresult = $blockObj->buildBlock())) {
            return;
        }
        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'));
}