/** * InitContent. * Checks the cache status and create the content. */ function pmxc_InitContent() { global $scripturl, $boardurl, $pmxCacheFunc; // if visible init the content if ($this->visible) { if ($this->cfg['cache'] > 0) { // check the block cache if (($cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) !== null) { list($dummy, $dummy, $this->posts, $this->attaches, $this->imgName) = $cachedata; } else { $this->fetch_data(); $cachedata = array(array(), array(), $this->posts, $this->attaches, $this->imgName); $pmxCacheFunc['put']($this->cache_key, $cachedata, $this->cache_time, $this->cache_mode); } unset($cachedata); } else { $this->fetch_data(); } // no posts .. disable the block if (empty($this->posts)) { $this->visible = false; } else { // create page index if set .. if (!empty($this->cfg['config']['settings']['onpage']) && count($this->posts) > $this->cfg['config']['settings']['onpage']) { // paging key $this->postKey = 'pmxpost_' . $this->cfg['blocktype'] . $this->cfg['id'] . (!empty($this->inBlockCall) ? '_0' : ''); $this->postarray = array('pg' => 0); if (isset($_POST[$this->postKey])) { pmx_GetPostKey($this->postKey, $this->postarray); $_SESSION['PortaMx'][$this->postKey] = $this->postarray; $this->startpage = $this->postarray['pg']; } elseif (isset($_SESSION['PortaMx'][$this->postKey])) { if (intval($_SESSION['PortaMx'][$this->postKey]['pg'] * $this->cfg['config']['settings']['onpage']) > count($this->posts)) { $this->startpage = 0; } else { $this->startpage = $_SESSION['PortaMx'][$this->postKey]['pg']; } } else { $this->startpage = 0; } $baseurl = function_exists('pmxsef_query') ? $boardurl . '/' : $scripturl . '?'; $this->pmxc_constructPageIndex(count($this->posts), $this->cfg['config']['settings']['onpage'], false, $this->startpage); $this->pageindex = str_replace('<a', '<a onclick="pmx_StaticBlockSub(\'' . $this->postKey . '\', this, \'/' . rtrim($baseurl, '?/') . '/\', \'' . $this->cfg['uniID'] . '\')"', $this->pageindex); } } // image rescale if (!empty($this->imgName)) { if (empty($this->cfg['config']['settings']['rescale']) && !is_numeric($this->cfg['config']['settings']['rescale'])) { addInlineCss(' .' . $this->imgName . '{}'); } else { $vals = explode(',', $this->cfg['config']['settings']['rescale']); addInlineCss(' .' . $this->imgName . '{' . (empty($vals[0]) ? 'width:auto' : 'max-width:' . (strpos($vals[0], '%') === false ? $vals[0] . 'px' : $vals[0])) . ';' . (empty($vals[1]) ? 'height:auto' : 'max-height:' . (strpos($vals[1], '%') === false ? $vals[1] . 'px' : $vals[1])) . ';}'); } } } // return the visibility return $this->visible; }
/** * InitContent. * Checks the cache status and create the content. */ function pmxc_InitContent() { global $scripturl, $boardurl, $pmxCacheFunc; if ($this->visible) { // content cached ? if ($this->cfg['cache'] > 0) { // check if the block cached if (($cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) !== null) { list($this->feedheader, $this->rsscontent) = $cachedata; } else { $this->rssreader_Content(); $cachedata = array($this->feedheader, $this->rsscontent); $pmxCacheFunc['put']($this->cache_key, $cachedata, $this->TimeToLife, $this->cache_mode); } unset($cachedata); } else { $this->rssreader_Content(); } // create page index if set .. if (!empty($this->cfg['config']['settings']['onpage']) && count($this->rsscontent) > $this->cfg['config']['settings']['onpage']) { $this->postKey = 'pmxpost_' . $this->cfg['blocktype'] . $this->cfg['id'] . (!empty($this->inBlockCall) ? '_0' : ''); $this->postarray = array('pg' => 0); if (isset($_POST[$this->postKey])) { pmx_GetPostKey($this->postKey, $this->postarray); $_SESSION['PortaMx'][$this->postKey] = $this->postarray; $this->startpage = $this->postarray['pg']; } elseif (isset($_SESSION['PortaMx'][$this->postKey])) { if (intval($_SESSION['PortaMx'][$this->postKey]['pg'] * $this->cfg['config']['settings']['onpage']) > count($this->rsscontent)) { $this->startpage = 0; } else { $this->startpage = $_SESSION['PortaMx'][$this->postKey]['pg']; } } else { $this->startpage = 0; } $baseurl = function_exists('pmxsef_query') ? $boardurl . '/' : $scripturl . '?'; $this->pmxc_constructPageIndex(count($this->rsscontent), $this->cfg['config']['settings']['onpage'], false, $this->startpage); $this->pageindex = str_replace('<a', '<a onclick="pmx_StaticBlockSub(\'' . $this->postKey . '\', this, \'/' . rtrim($baseurl, '?/') . '/\', \'' . $this->cfg['uniID'] . '\')"', $this->pageindex); } } // return the visibility flag (true/false) return $this->visible; }
/** * InitContent. * Checks the cache status and create the content. */ function pmxc_InitContent() { global $context, $pmxCacheFunc; // requested category and limited to admins?? if (empty($this->cfg['static_block'])) { if (!empty($this->cfg['config']['request']) && !allowPmx('pmx_admin')) { $this->visible = false; } // requested category ecl check if (!empty($this->cfg['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($this->cfg['config']['check_eclbots']))) { $this->visible = false; } } // if visible init the content if ($this->visible) { $this->postKey = 'pmxpost_' . (!empty($this->cfg['static_block']) ? 'cat_block' : $this->cfg['blocktype']) . $this->cfg['id'] . (!empty($this->inBlockCall) ? '_0' : ''); $this->postarray[$this->postKey] = array('cat' => '', 'child' => '', 'art' => '', 'pg' => '0'); // cleanup $_GET for vars we need here $GETpost = null; if (!empty($_GET)) { $GETpost = $_GET; $tmp = array_diff(array_keys($this->postarray[$this->postKey]), array_keys($GETpost)); while (list($d, $key) = each($tmp)) { unset($GETpost[$key]); } } if (empty($GETpost) && empty($_POST[$this->postKey]) && !empty($_SESSION['PortaMx'][$this->postKey])) { $this->postarray[$this->postKey] = array_merge($this->postarray[$this->postKey], $_SESSION['PortaMx'][$this->postKey]); } if (empty($this->postarray[$this->postKey]['cat']) && !empty($this->cfg['static_block'])) { $this->postarray[$this->postKey]['cat'] = $this->cfg['config']['settings']['category']; } // reset current page ? if (!empty($_POST[$this->postKey])) { $data = array('cat' => '', 'child' => '', 'art' => '', 'pg' => '0'); if (!empty($_POST[$this->postKey])) { $this->postarray[$this->postKey] = pmx_GetPostKey($this->postKey, $data); } else { if (isset($_SESSION['PortaMx'][$this->postKey])) { $this->postarray[$this->postKey] = $_SESSION['PortaMx'][$this->postKey]; } $data = $this->postarray[$this->postKey] = array_merge($this->postarray[$this->postKey], $GETpost); } } elseif (empty($GETpost) && empty($_POST[$this->postKey]) && isset($_SESSION['PortaMx'][$this->postKey])) { $this->postarray[$this->postKey] = $_SESSION['PortaMx'][$this->postKey]; } if (!empty($GETpost)) { $this->postarray[$this->postKey] = array_merge($this->postarray[$this->postKey], $GETpost); } $_SESSION['PortaMx'][$this->postKey] = $this->postarray[$this->postKey]; // called from static category block? if (!empty($this->cfg['static_block'])) { // get the category if (!empty($this->cfg['cache'])) { $cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode); } else { $cachedata = null; } if ($cachedata !== null) { list($this->categories, $this->articles) = $cachedata; $cats = $this->categories[$this->cfg['config']['settings']['category']]; } else { $cats = PortaMx_getCatByID(null, $this->cfg['config']['settings']['category']); $cats['config'] = unserialize($cats['config']); // inherit acs from block? if (!empty($this->cfg['config']['settings']['inherit_acs'])) { $cats['acsgrp'] = $this->cfg['acsgrp']; } // Main cat can show? if (!allowPmxGroup($cats['acsgrp'])) { return false; } // Main cat ecl check if (!empty($cats['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($cats['config']['check_eclbots']))) { return false; } // get category(s) and articles $this->getCatsAndChilds($cats, $cats['acsgrp'], !empty($cats['config']['settings']['inherit_acs'])); if (!empty($this->cfg['cache'])) { $pmxCacheFunc['put']($this->cache_key, array($this->categories, $this->articles), $this->cache_time, $this->cache_mode); } } // check category elc foreach ($this->categories as $eclKey => $eclCat) { if (!empty($eclCat['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($eclCat['config']['check_eclbots']))) { unset($this->categories[$eclKey]); } } $this->postarray[$this->postKey]['cat'] = $cats['name']; $this->firstcat = !empty($this->postarray[$this->postKey]['child']) ? $this->postarray[$this->postKey]['child'] : $cats['name']; $this->curCat = null; if (isset($this->categories[$this->firstcat])) { $this->curCat = $this->categories[$this->firstcat]; } if (!is_null($this->curCat) && !empty($this->postarray[$this->postKey]['art'])) { $found = false; foreach ($this->articles[$this->curCat['name']] as $article) { $found = $article['name'] == $this->postarray[$this->postKey]['art'] ? true : $found; } } else { $found = true; } if (!is_null($this->curCat) && !empty($found)) { if ($this->cfg['config']['settings']['usedframe'] == 'block') { $this->curCat['config']['visuals'] = $this->cfg['config']['visuals']; $this->curCat['config']['csfile'] = $this->cfg['config']['cssfile']; } // check framemode if ($this->cfg['config']['settings']['usedframe'] == 'cat') { $this->cfg['config']['skip_outerframe'] = true; $this->curCat['catid'] = $this->curCat['id']; } else { $this->curCat['config']['skip_outerframe'] = true; $this->curCat['config']['visuals']['frame'] = $this->cfg['config']['visuals']['frame']; $this->cfg['catid'] = $this->cfg['id']; $this->cfg['blocktype'] = 'catblock'; } } else { $this->visible = false; } } else { // get cat data and all childs $cats = PortaMx_getCatByID(null, $this->postarray[$this->postKey]['cat']); // Main cat can show? if (!allowPmxGroup($cats['acsgrp'])) { return false; } // Main cat ecl check if (!empty($cats['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($cats['config']['check_eclbots']))) { return false; } // get categoy(s) and articles $this->getCatsAndChilds($cats, $cats['acsgrp'], !empty($cats['config']['settings']['inherit_acs'])); $this->firstcat = !empty($this->postarray[$this->postKey]['child']) ? $this->postarray[$this->postKey]['child'] : $this->postarray[$this->postKey]['cat']; $this->curCat = null; if (isset($this->categories[$this->firstcat])) { $this->curCat = $this->categories[$this->firstcat]; } if (!is_null($this->curCat) && !empty($this->postarray[$this->postKey]['art'])) { $found = false; foreach ($this->articles[$this->curCat['name']] as $article) { $found = $article['name'] == $this->postarray[$this->postKey]['art'] ? true : $found; } } else { $found = true; } if (!is_null($this->curCat) && !empty($found)) { // save titles for linktree $context['pmx']['pagenames']['cat'] = $this->categories[$cats['name']]['title']; if (empty($context['pmx']['pagenames']['cat'])) { $context['pmx']['pagenames']['cat'] = htmlspecialchars($cats['name'], ENT_QUOTES); } if (!empty($this->postarray[$this->postKey]['child'])) { $context['pmx']['pagenames']['child'] = $this->curCat['title']; if (empty($context['pmx']['pagenames']['child'])) { $context['pmx']['pagenames']['child'] = htmlspecialchars($this->curCat['name'], ENT_QUOTES); } } $this->cfg['uniID'] = 'cat' . $this->categories[$cats['name']]['id']; $this->cfg['config']['skip_outerframe'] = true; $this->curCat['catid'] = $this->curCat['id']; } else { $this->visible = false; } } } if (!empty($this->visible) && !empty($this->articles)) { // handle special php articles foreach ($this->articles as $cn => $artlist) { foreach ($artlist as $id => $article) { if ($article['ctype'] == 'php' && preg_match('~\\[\\?pmx_initphp(.*)pmx_initphp\\?\\]~is', $article['content'], $match)) { eval($match[1]); } if (!empty($article['config']['cssfile'])) { $this->getCustomCSS($article); } } } } return $this->visible; }
/** * InitContent. * Checks the cache status and create the content. */ function pmxc_InitContent() { global $context, $scripturl, $boardurl, $pmxCacheFunc; if (empty($context['pmx']['settings']['manager']['promote']) || empty($context['pmx']['promotes'])) { $this->visible = false; } // if visible init the content if ($this->visible) { // paging key $this->postKey = 'pmxpost_' . $this->cfg['blocktype'] . $this->cfg['id'] . (!empty($this->inBlockCall) ? '_0' : ''); // posts can select by posts or boards .. defaut posts if (empty($this->cfg['config']['settings']['selectby'])) { $this->cfg['config']['settings']['selectby'] = 'posts'; } // force reload for this block? if (!empty($_SESSION['pmx_refresh_promote']) && in_array($this->cfg['id'], $_SESSION['pmx_refresh_promote'])) { if (isset($_SESSION['PortaMx'][$this->postKey])) { unset($_SESSION['PortaMx'][$this->postKey]); $this->startpage = 0; } // clear reload and fetch the data $_SESSION['pmx_refresh_promote'] = array_diff($_SESSION['pmx_refresh_promote'], array($this->cfg['id'])); $posts = $this->fetch_data(); // store in cache if enabled if ($this->cfg['cache'] > 0) { $pmxCacheFunc['put']($this->cache_key, array($posts, $this->posts, $this->attaches, $this->imgName), $this->cache_time, $this->cache_mode); } } else { // cache enabled ? if ($this->cfg['cache'] > 0) { // cache valid? if (($cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) !== null) { // yes.. list($posts, $this->posts, $this->attaches, $this->imgName) = $cachedata; unset($cachedata); } else { $posts = $this->fetch_data(); $pmxCacheFunc['put']($this->cache_key, array($posts, $this->posts, $this->attaches, $this->imgName), $this->cache_time, $this->cache_mode); } } else { $posts = $this->fetch_data(); } } // no posts .. disable the block if (empty($posts) || empty($this->posts)) { $this->visible = false; } elseif (!empty($this->cfg['config']['settings']['onpage'])) { if (!empty($this->cfg['config']['settings']['onpage']) && count($this->posts) > $this->cfg['config']['settings']['onpage']) { $this->postarray = array('pg' => 0); if (isset($_POST[$this->postKey])) { pmx_GetPostKey($this->postKey, $this->postarray); $_SESSION['PortaMx'][$this->postKey] = $this->postarray; $this->startpage = $this->postarray['pg']; } elseif (isset($_SESSION['PortaMx'][$this->postKey])) { if (intval($_SESSION['PortaMx'][$this->postKey]['pg'] * $this->cfg['config']['settings']['onpage']) > count($this->posts)) { $this->startpage = 0; } else { $this->startpage = $_SESSION['PortaMx'][$this->postKey]['pg']; } } else { $this->startpage = 0; } $baseurl = function_exists('pmxsef_query') ? $boardurl . '/' : $scripturl . '?'; $this->pmxc_constructPageIndex(count($this->posts), $this->cfg['config']['settings']['onpage'], false, $this->startpage); $this->pageindex = str_replace('<a', '<a onclick="pmx_StaticBlockSub(\'' . $this->postKey . '\', this, \'/' . rtrim($baseurl, '?/') . '/\', \'' . $this->cfg['uniID'] . '\')"', $this->pageindex); } } // image rescale.. if (!empty($this->imgName)) { if (empty($this->cfg['config']['settings']['rescale']) && !is_numeric($this->cfg['config']['settings']['rescale'])) { addInlineCss(' .' . $this->imgName . '{}'); } else { $vals = explode(',', $this->cfg['config']['settings']['rescale']); addInlineCss(' .' . $this->imgName . '{' . (empty($vals[0]) ? 'width:auto' : 'max-width:' . (strpos($vals[0], '%') === false ? $vals[0] . 'px' : $vals[0])) . ';' . (empty($vals[1]) ? 'height:auto' : 'max-height:' . (strpos($vals[1], '%') === false ? $vals[1] . 'px' : $vals[1])) . ';}'); } } } // return the visibility return $this->visible; }