Exemple #1
0
// then slightly hacked
$cmsmodules =& $gCms->modules;
$modresult = '';
if (isset($cmsmodules)) {
    $modulename = $params['module'];
    foreach ($cmsmodules as $key => $value) {
        if (!strcasecmp($modulename, $key)) {
            $modulename = $key;
        }
    }
    if (isset($modulename)) {
        if (isset($cmsmodules[$modulename])) {
            if (isset($cmsmodules[$modulename]['object']) && $cmsmodules[$modulename]['installed'] == true && $cmsmodules[$modulename]['active'] == true && $cmsmodules[$modulename]['object']->IsSoapModule()) {
                //@ob_start();
                $id = 'm' . ++$gCms->variables["modulenum"];
                $params = array_merge($params, GetModuleParameters($id));
                $action = 'soap';
                if (isset($params['action'])) {
                    $action = $params['action'];
                }
                $returnid = '';
                if (isset($gCms->variables['pageinfo']) && isset($gCms->variables['pageinfo']->content_id)) {
                    $returnid = $gCms->variables['pageinfo']->content_id;
                }
                $params['HTTP_RAW_POST_DATA'] = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
                $result = $cmsmodules[$modulename]['object']->DoActionBase($action, $id, $params, $returnid);
                if ($result !== FALSE) {
                    echo $result;
                }
                $modresult = @ob_get_contents();
                //@ob_end_clean();
 /**
  * @since 1.11
  * @author calguy1000
  * @internal
  * @ignore
  */
 public static function smarty_internal_fetch_contentblock($params, $template)
 {
     $smarty = $template->smarty;
     $gCms = cmsms();
     $contentobj = $gCms->variables['content_obj'];
     $page_id = cmsms()->get_variable('page_id');
     if (is_object($contentobj)) {
         if (!$contentobj->IsPermitted()) {
             throw new CmsError403Exception();
         }
         $id = '';
         $modulename = '';
         $action = '';
         $inline = false;
         if (isset($_REQUEST['module'])) {
             $modulename = $_REQUEST['module'];
         }
         if (isset($_REQUEST['id'])) {
             $id = $_REQUEST['id'];
         } elseif (isset($_REQUEST['mact'])) {
             $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4);
             $modulename = isset($ary[0]) ? $ary[0] : '';
             $id = isset($ary[1]) ? $ary[1] : '';
             $action = isset($ary[2]) ? $ary[2] : '';
             $inline = isset($ary[3]) && $ary[3] == 1 ? true : false;
         }
         if (isset($_REQUEST[$id . 'action'])) {
             $action = $_REQUEST[$id . 'action'];
         } else {
             if (isset($_REQUEST['action'])) {
                 $action = $_REQUEST['action'];
             }
         }
         //Only consider doing module processing if
         //a. There is no block parameter
         //b. then
         //   1. $id is cntnt01 or _preview_
         //   2. or inline is false
         if (!isset($params['block']) && ($id == 'cntnt01' || $id == '_preview_' || $id != '' && $inline == false)) {
             // todo, would be neat here if we could get a list of only frontend modules.
             $installedmodules = ModuleOperations::get_instance()->GetInstalledModules();
             if (count($installedmodules)) {
                 // case insensitive module match.
                 foreach ($installedmodules as $key) {
                     if (strtolower($modulename) == strtolower($key)) {
                         $modulename = $key;
                     }
                 }
                 if (!isset($modulename) || empty($modulename)) {
                     // no module specified.
                     @trigger_error('Attempt to call a module action, without specifying a valid module name');
                     return self::content_return('', $params, $smarty);
                 }
                 $modobj = ModuleOperations::get_instance()->get_module_instance($modulename);
                 if (!$modobj) {
                     // module not found... couldn't even autoload it.
                     @trigger_error('Attempt to access module ' . $modulename . ' which could not be found (is it properly installed and configured?');
                     return self::content_return('', $params, $smarty);
                 }
                 if ($modobj->IsPluginModule()) {
                     @ob_start();
                     unset($params['block']);
                     unset($params['label']);
                     unset($params['wysiwyg']);
                     unset($params['oneline']);
                     unset($params['default']);
                     unset($params['size']);
                     unset($params['tab']);
                     $params = array_merge($params, GetModuleParameters($id));
                     $returnid = '';
                     if (isset($params['returnid'])) {
                         $returnid = $params['returnid'];
                     } else {
                         $returnid = $contentobj->Id();
                     }
                     $oldcache = $smarty->caching;
                     $smarty->caching = false;
                     $result = $modobj->DoActionBase($action, $id, $params, $returnid);
                     $smarty->caching = $oldcache;
                     if ($result !== FALSE) {
                         echo $result;
                     }
                     $modresult = @ob_get_contents();
                     @ob_end_clean();
                     return self::content_return($modresult, $params, $smarty);
                 } else {
                     @trigger_error('Attempt to access module ' . $key . ' which could not be found (is it properly installed and configured?');
                     return self::content_return("<!-- Not a tag module -->\n", $params, $smarty);
                 }
             }
         } else {
             $block = isset($params['block']) ? $params['block'] : 'content_en';
             $result = '';
             $oldvalue = $smarty->caching;
             $smarty->caching = false;
             if ($id == '_preview_' || $page_id == '__CMS_PREVIEW_PAGE__') {
                 // note: content precompile/postcompile events will not be triggererd in preview.
                 $val = $contentobj->Show($block);
                 $result = $smarty->fetch('string:' . $val);
             } else {
                 $result = $smarty->fetch(str_replace(' ', '_', 'content:' . $block), '|' . $block, $contentobj->Id() . $block);
             }
             $smarty->caching = $oldvalue;
             return self::content_return($result, $params, $smarty);
         }
     }
     return _smarty_cms_function_content_return('', $params, $smarty);
 }
/**
 * A function to call a module as a smarty plugin
 * This method is used by the {cms_module} plugin, and internally when {ModuleName} is called
 *
 * @internal
 * @access private
 * @param array A hash of parameters 
 * @param object The smarty object
 * @return string The module output
 */
function cms_module_plugin($params, &$template)
{
    $smarty = $template->smarty;
    $mid_cache = cms_utils::get_app_data('mid_cache');
    if (empty($mid_cache)) {
        $mid_cache = array();
    }
    for ($i = 0; $i < 10; $i++) {
        $tmp = $i;
        foreach ($params as $key => $value) {
            $tmp .= $key . '=' . $value;
        }
        $id = 'm' . substr(md5($tmp), 0, 5);
        if (!isset($mid_cache[$id])) {
            $mid_cache[$id] = $id;
            break;
        }
    }
    cms_utils::set_app_data('mid_cache', $mid_cache);
    $returnid = '';
    $content_obj = cmsms()->get_variable('content_obj');
    if (isset($content_obj) && $content_obj->Id()) {
        $returnid = $content_obj->Id();
    }
    //$params = array_merge($params, GetModuleParameters($id));
    $modulename = '';
    $action = 'default';
    $inline = false;
    $checkid = '';
    if (isset($params['module'])) {
        $modulename = $params['module'];
    } else {
        return '<!-- ERROR: module name not specified -->';
    }
    if (isset($params['idprefix'])) {
        $id = trim($params['idprefix']);
    }
    if (isset($params['action']) && $params['action'] != '') {
        // action was set in the module tag
        $action = $params['action'];
    }
    if (isset($_REQUEST['id'])) {
        $checkid = $_REQUEST['id'];
    } else {
        if (isset($_REQUEST['mact'])) {
            // we're handling an action
            $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4);
            $mactmodulename = isset($ary[0]) ? $ary[0] : '';
            if (!strcasecmp($mactmodulename, $params['module'])) {
                $checkid = isset($ary[1]) ? $ary[1] : '';
                $mactaction = isset($ary[2]) ? $ary[2] : '';
            }
            $mactinline = isset($ary[3]) && $ary[3] == 1 ? true : false;
            if ($checkid == $id) {
                // the action is for this instance of the module
                $inline = $mactinline;
                if ($inline == true) {
                    // and we're inline (the results are supposed to replace
                    // the tag, not {content}
                    $action = $mactaction;
                    $params = array_merge($params, GetModuleParameters($id));
                }
            }
        }
    }
    if ($action == '') {
        $action = 'default';
    }
    // probably not needed, but safe
    class_exists($modulename);
    $module = cms_utils::get_module($modulename);
    if ($module && $module->isPluginModule()) {
        @ob_start();
        $result = $module->DoActionBase($action, $id, $params, $returnid);
        if ($result !== FALSE) {
            echo $result;
        }
        $modresult = @ob_get_contents();
        @ob_end_clean();
        if (isset($params['assign'])) {
            $smarty->assign(trim($params['assign']), $modresult);
            return;
        }
        return $modresult;
    } else {
        return "<!-- {$modulename} is not a plugin module -->\n";
    }
}
 $USE_THEME = true;
 if (isset($_REQUEST[$id . 'disable_buffer']) || isset($_REQUEST['disable_buffer'])) {
     $USE_THEME = false;
 } else {
     if (isset($_REQUEST[$id . 'disable_theme']) || isset($_REQUEST['disable_theme'])) {
         $USE_THEME = false;
     }
 }
 if (isset($_REQUEST['showtemplate']) && $_REQUEST['showtemplate'] == 'false') {
     // for simplicity and compatibility with the frontend.
     $USE_THEME = false;
 }
 if ($modinst->SuppressAdminOutput($_REQUEST) != false || isset($_REQUEST['suppressoutput'])) {
     $USE_THEME = false;
 }
 $params = GetModuleParameters($id);
 if ($USE_THEME) {
     $themeObject = cms_utils::get_theme_object();
     @ob_start();
     echo $modinst->DoActionBase($action, $id, $params);
     $content = @ob_get_contents();
     @ob_end_clean();
     cms_admin_sendheaders();
     $txt = $modinst->GetHeaderHTML();
     if ($txt !== false) {
         $headtext = $txt;
     }
     // headtext is a global
     include_once "header.php";
     if (FALSE == empty($params['module_message'])) {
         echo $themeObject->ShowMessage($params['module_message']);
 function Show()
 {
     global $gCms;
     $variables =& $gCms->variables;
     $params = array();
     $params['albums'] = $this->GetPropertyValue('albums');
     $params['template'] = $this->GetPropertyValue('album_template');
     // $album = $this->GetModuleInstance('Album');
     global $id;
     $params = GetModuleParameters($id);
     global $AlbumCalled;
     if (TRUE == empty($params['returnid'])) {
         $newalbum = new Album();
         //Buffer all this crap spit out by the News module and return it
         @ob_start();
         $newalbum->DoAction('default', 'album', $params, $variables['content_id']);
         $text = @ob_get_contents();
         @ob_end_clean();
         return $text;
     } else {
         return '';
     }
     # return '{literal}'.$text.'{/literal}';
 }
 /**
  * Function for the subclass to perform the blocks compiled output in frontend.<br />
  * Needs to be overwritten if the blocktype provides a special kind of data that needs to be processed before compiling it in frontend.
  * @param $obj
  * @return string
  * @since 0.9.4
  */
 public function GetCompiledContent(&$obj)
 {
     $id = '';
     $modulename = '';
     $action = '';
     $inline = false;
     if (isset($_REQUEST['module'])) {
         $modulename = $_REQUEST['module'];
     }
     if (isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
     } elseif (isset($_REQUEST['mact'])) {
         $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4);
         $modulename = isset($ary[0]) ? $ary[0] : '';
         $id = isset($ary[1]) ? $ary[1] : '';
         $action = isset($ary[2]) ? $ary[2] : '';
         $inline = isset($ary[3]) && $ary[3] == 1 ? true : false;
     }
     if (isset($_REQUEST[$id . 'action'])) {
         $action = $_REQUEST[$id . 'action'];
     } else {
         if (isset($_REQUEST['action'])) {
             $action = $_REQUEST['action'];
         }
     }
     if ($this->_properties['id'] == 'content_en' && ($id == 'cntnt01' || $id == '_preview_' || $id != '' && $inline == false)) {
         $module =& ac_utils::get_module($modulename);
         if (is_object($module) && $module->IsPluginModule()) {
             @ob_start();
             $params = GetModuleParameters($id);
             $returnid = isset($params['returnid']) ? $params['returnid'] : $this->content_obj->Id();
             echo $module->DoActionBase($action, $id, $params, $returnid);
             $output = @ob_get_contents();
             @ob_end_clean();
         }
     } else {
         if (version_compare(CMS_VERSION, '1.11') < 0) {
             $smarty =& $obj;
         } else {
             $smarty =& $obj->smarty;
         }
         $oldvalue = $smarty->caching;
         $smarty->caching = false;
         if ($id == '_preview_' || $id == '') {
             $output = $smarty->fetch('string:' . $this->GetContent());
         } else {
             $output = $smarty->fetch(str_replace(' ', '_', 'content:' . $this->_properties['id']), '|' . $this->_properties['id'], $this->content_obj->Id() . $this->_properties['id']);
         }
         $smarty->caching = $oldvalue;
         if ($output == '' && !$this->_properties['allow_none']) {
             $output = $this->_properties['default'];
         }
     }
     if (!empty($this->_properties['assign'])) {
         $smarty->assign($this->_properties['assign'], $output);
         return '';
     }
     return trim($output);
 }
 /**
  * Retrieve output from a module.
  * This method grabs parameters from the request, and given the module name
  * will call the module with the specified parameters to retrieve the module output.
  * This is used to replace the contents of the {content} tag when a module action is
  * called in a non inline manner.
  *
  * @access private
  * @param string The module name.
  * @param  string (returned) The moduleoutput.
  * @param  object The smarty object.
  * @return boolean
  */
 function module_get_template($tpl_name, &$tpl_source, &$smarty_obj)
 {
     $gCms = cmsms();
     $contentobj = $gCms->variables['content_obj'];
     $config = $gCms->config;
     #Run the execute_user function and replace {content} with it's output
     $obj = cms_utils::get_module($tpl_name);
     if (is_object($obj)) {
         @ob_start();
         $id = $smarty_obj->id;
         $returnid = is_object($contentobj) ? $contentobj->Id() : '';
         $params = GetModuleParameters($id);
         $action = 'default';
         if (isset($params['action'])) {
             $action = $params['action'];
         }
         echo $obj->DoActionBase($action, $id, $params, is_object($contentobj) ? $contentobj->Id() : '');
         $modoutput = @ob_get_contents();
         @ob_end_clean();
         $tpl_source = $modoutput;
     }
     header("Content-Type: " . $gCms->variables['content-type'] . "; charset=" . get_encoding());
     if (isset($gCms->variables['content-filename']) && $gCms->variables['content-filename'] != '') {
         header('Content-Disposition: attachment; filename="' . $gCms->variables['content-filename'] . '"');
         header("Pragma: public");
     }
     #So no one can do anything nasty, take out the php smarty tags.  Use a user
     #defined plugin instead.
     if (!(isset($config["use_smarty_php_tags"]) && $config["use_smarty_php_tags"] == true)) {
         $tpl_source = preg_replace("/\\{\\/?php\\}/", "", $tpl_source);
     }
     return true;
 }
Exemple #8
0
/**
 * A function to call a module as a smarty plugin
 * This method is used by the {cms_module} plugin, and internally when {ModuleName} is called
 *
 * @internal
 * @access private
 * @param array A hash of parameters 
 * @param object The smarty object
 * @return string The module output
 */
function cms_module_plugin($params, &$smarty)
{
    global $gCms;
    $cmsmodules =& $gCms->modules;
    //$id = 'm' . ++$gCms->variables["modulenum"];
    if (!isset($gCms->variables['mid_cache'])) {
        $gCms->variables['mid_cache'] = array();
    }
    for ($i = 0; $i < 10; $i++) {
        $tmp = $i;
        foreach ($params as $key => $value) {
            $tmp .= $key . '=' . $value;
        }
        $id = 'm' . substr(md5($tmp), 0, 5);
        if (!isset($gCms->variables['mid_cache'][$id])) {
            $gCms->variables['mid_cache'][$id] = $id;
            break;
        }
    }
    $returnid = '';
    if (isset($gCms->variables['pageinfo']) && isset($gCms->variables['pageinfo']->content_id)) {
        $returnid = $gCms->variables['pageinfo']->content_id;
    }
    $params = array_merge($params, GetModuleParameters($id));
    $modulename = '';
    $action = 'default';
    $inline = false;
    $checkid = '';
    if (isset($params['module'])) {
        $modulename = $params['module'];
    } else {
        return '<!-- ERROR: module name not specified -->';
    }
    if (isset($params['idprefix'])) {
        $id = trim($params['idprefix']);
    }
    if (isset($params['action']) && $params['action'] != '') {
        // action was set in the module tag
        $action = $params['action'];
    }
    if (isset($_REQUEST['id'])) {
        $checkid = $_REQUEST['id'];
    } else {
        if (isset($_REQUEST['mact'])) {
            // we're handling an action
            $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4);
            $mactmodulename = isset($ary[0]) ? $ary[0] : '';
            if (!strcasecmp($mactmodulename, $params['module'])) {
                $checkid = isset($ary[1]) ? $ary[1] : '';
                $mactaction = isset($ary[2]) ? $ary[2] : '';
            }
            $mactinline = isset($ary[3]) && $ary[3] == 1 ? true : false;
            if ($checkid == $id) {
                // the action is for this instance of the module
                $inline = $mactinline;
                if ($inline == true) {
                    // and we're inline (the results are supposed to replace
                    // the tag, not {content}
                    $action = $mactaction;
                }
            }
        }
    }
    if ($action == '') {
        $action = 'default';
    }
    // probably not needed, but safe
    if (isset($cmsmodules)) {
        $modulename = $params['module'];
        foreach ($cmsmodules as $key => $value) {
            if (!strcasecmp($modulename, $key)) {
                $modulename = $key;
            }
        }
        if (isset($modulename)) {
            if (isset($cmsmodules[$modulename])) {
                if (isset($cmsmodules[$modulename]['object']) && $cmsmodules[$modulename]['installed'] == true && $cmsmodules[$modulename]['active'] == true && $cmsmodules[$modulename]['object']->IsPluginModule()) {
                    @ob_start();
                    $result = $cmsmodules[$modulename]['object']->DoActionBase($action, $id, $params, $returnid);
                    if ($result !== FALSE) {
                        echo $result;
                    }
                    $modresult = @ob_get_contents();
                    @ob_end_clean();
                    if (isset($params['assign'])) {
                        $smarty->assign(trim($params['assign']), $modresult);
                        return;
                    }
                    return $modresult;
                } else {
                    return "<!-- Not a tag module -->\n";
                }
            }
        }
    }
}
Exemple #9
0
function smarty_cms_function_content($params, &$smarty)
{
    global $gCms;
    $pageinfo =& $gCms->variables['pageinfo'];
    if (isset($pageinfo) && $pageinfo !== FALSE && isset($pageinfo->content_id)) {
        $id = '';
        $modulename = '';
        $action = '';
        $inline = false;
        if (isset($_REQUEST['module'])) {
            $modulename = $_REQUEST['module'];
        }
        if (isset($_REQUEST['id'])) {
            $id = $_REQUEST['id'];
        } elseif (isset($_REQUEST['mact'])) {
            $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4);
            $modulename = isset($ary[0]) ? $ary[0] : '';
            $id = isset($ary[1]) ? $ary[1] : '';
            $action = isset($ary[2]) ? $ary[2] : '';
            $inline = isset($ary[3]) && $ary[3] == 1 ? true : false;
        }
        if (isset($_REQUEST[$id . 'action'])) {
            $action = $_REQUEST[$id . 'action'];
        } else {
            if (isset($_REQUEST['action'])) {
                $action = $_REQUEST['action'];
            }
        }
        //Only consider doing module processing if
        //a. There is no block parameter
        //b. then
        //   1. $id is cntnt01
        //   2. or inline is false
        if (!isset($params['block']) && ($id == 'cntnt01' || $id != '' && $inline == false)) {
            $cmsmodules =& $gCms->modules;
            if (isset($cmsmodules)) {
                foreach ($cmsmodules as $key => $value) {
                    if (strtolower($modulename) == strtolower($key)) {
                        $modulename = $key;
                    }
                }
                if (!isset($modulename) || empty($modulename) || !isset($cmsmodules[$modulename])) {
                    // module not found
                    @trigger_error('Attempt to access module ' . $modulename . ' which could not be foune (is it properly installed and configured?');
                    return _smarty_cms_function_content_return('', $params, $smarty);
                }
                if (isset($cmsmodules[$modulename])) {
                    if (isset($cmsmodules[$modulename]['object']) && $cmsmodules[$modulename]['installed'] == true && $cmsmodules[$modulename]['active'] == true && $cmsmodules[$modulename]['object']->IsPluginModule()) {
                        @ob_start();
                        unset($params['block']);
                        unset($params['label']);
                        unset($params['wysiwyg']);
                        unset($params['oneline']);
                        unset($params['default']);
                        unset($params['size']);
                        $params = array_merge($params, GetModuleParameters($id));
                        //$params = GetModuleParameters($id);
                        $returnid = '';
                        if (isset($params['returnid'])) {
                            $returnid = $params['returnid'];
                        } else {
                            $returnid = $pageinfo->content_id;
                        }
                        $result = $cmsmodules[$modulename]['object']->DoActionBase($action, $id, $params, $returnid);
                        if ($result !== FALSE) {
                            echo $result;
                        }
                        $modresult = @ob_get_contents();
                        @ob_end_clean();
                        return _smarty_cms_function_content_return($modresult, $params, $smarty);
                    } else {
                        @trigger_error('Attempt to access module ' . $key . ' which could not be foune (is it properly installed and configured?');
                        return _smarty_cms_function_content_return("<!-- Not a tag module -->\n", $params, $smarty);
                    }
                }
            }
        } else {
            $result = '';
            $oldvalue = $smarty->caching;
            $smarty->caching = false;
            $result = $smarty->fetch(str_replace(' ', '_', 'content:' . (isset($params['block']) ? $params['block'] : 'content_en')), '', $pageinfo->content_id);
            $smarty->caching = $oldvalue;
            return _smarty_cms_function_content_return($result, $params, $smarty);
        }
    }
    return _smarty_cms_function_content_return('', $params, $smarty);
}