Created
May 7, 2012 22:18
-
-
Save ghengeveld/2630919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!defined('SED_CODE')){die('Wrong URL.'); } | |
$currenttpl = file_get_contents($mskin); | |
if (mb_strpos($currenttpl, "{PAGE_TEXT_ID_") !== false) | |
{ | |
$matches = array(); | |
preg_match_all("#{(?P<tag>PAGE_TEXT_ID_(?P<id>[0-9]+))}#", $currenttpl, $matches, PREG_SET_ORDER); | |
foreach ($matches as $match){ | |
$p_tag = $match['tag']; | |
$p_id = $match['id']; | |
// Get page content by id in tag | |
$psql = "SELECT * FROM $db_pages WHERE page_id='$p_id' LIMIT 1"; | |
$pres = sed_sql_query($psql); | |
$prow = sed_sql_fetchassoc($pres); | |
// Parse bbcode etc | |
$page_html = ""; | |
$page_html = ""; | |
switch($prow['page_type']){ | |
case '1': | |
$page_html = $prow['page_text']; | |
break; | |
case '2': | |
if ($cfg['allowphp_pages']&&$cfg['allowphp_override']){ | |
ob_start(); | |
eval($prow['page_text']); | |
$page_html = ob_get_clean(); | |
}else{ | |
$page_html = "The PHP mode is disabled for pages.<br />Please see the administration panel, then \"Configuration\", then \"Parsers\"."; | |
} | |
break; | |
default: | |
if ($cfg['parser_cache']){ | |
if (empty($prow['page_html'])&&!empty($prow['page_text'])){ | |
$prow['page_html'] = sed_parse(sed_cc($prow['page_text']), $cfg['parsebbcodepages'], $cfg['parsesmiliespages'], 1); | |
sed_sql_query("UPDATE $db_pages SET page_html = '".sed_sql_prep($prow['page_html'])."' WHERE page_id = ".$prow['page_id']); | |
} | |
$html = $cfg['parsebbcodepages'] ? sed_post_parse($prow['page_html']) : sed_cc($prow['page_text']); | |
$page_html = $html; | |
}else{ | |
$text = sed_parse(sed_cc($prow['page_text']), $cfg['parsebbcodepages'], $cfg['parsesmiliespages'], 1); | |
$text = sed_post_parse($text, 'pages'); | |
$page_html = $text; | |
} | |
break; | |
} | |
// Tag [more] (<!--more--> in html) | |
$pos_more = strpos($page_html, "<!--more-->"); | |
if ($pos_more!==false) $page_html = substr($page_html, 0, $pos_more)." <span class=\"readmore\"><a href=\"page.php?id=$p_id\">".$L['ReadMore']."</a></span>"; | |
// Adding link to edit for admins | |
if ($usr['isadmin']){ | |
$edit_link = $cfg['plugin']['pagetextbyidn']['link_to_edit']; | |
$edit_link = str_replace("{HREF_EDIT}", "href='page.php?m=edit&id=$p_id'", $edit_link); | |
if ($cfg['plugin']['pagetextbyidn']['where']=="before") | |
$page_html = $edit_link." ".$page_html; | |
if ($cfg['plugin']['pagetextbyidn']['where']=="after") | |
$page_html = $page_html." ".$edit_link; | |
} | |
// Assign tag | |
$t->assign($p_tag, $page_html); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment