Empire CMS: Stripping Off-Site Links from Posts on Publish and Update

When you edit or publish a post in Empire CMS, the article often comes from another site, so pasting it inevitably drags along the original formatting (which you can fix with the editor's Clear Formatting button) and off-site links — the text links and image links pointing at the other site.

So is there a smarter, faster way to solve this once and for all?

PS. This fix may only suit the Empire CMS 7.2 issue where non-local links can't be deleted.

Open the file \e\class\hinfofun.php

  1. Just before the closing "?>" at the end of the file, add:
function Replace_Links($body)
{
$host_rule = $_SERVER[‘HTTP_HOST’];
$arr = ”;
preg_match_all(“#]*)>(.*)#iU”, $body, $arr);
if( is_array($arr[0]) )
{
$rparr = array();
$tgarr = array();
foreach($arr[0] as $i=>$v)
{
if( $host_rule != ” && preg_match(‘#’.$host_rule.’#i’, $arr[1][$i]) )
{
continue;
} else {
$rparr[] = $v;
$tgarr[] = $arr[2][$i];
}
}
if( !empty($rparr) )
{
$body = str_replace($rparr, $tgarr, $body);
}
}
$arr = $rparr = $tgarr = ”;
return $body;
}
  1. Find if(!$add[id]||!$add[title]||!$add[classid]||!$add[filename]) and add this above it:
// Empire CMS: remove links to other sites
$add[‘newstext’] = Replace_Links($add[‘newstext’]);
  1. Find $ret_r=ReturnAddF($add,$class_r[$add[classid]][modid],$userid,$username,0,0,1);//return custom fields, and add this above it:
// Empire CMS: remove links to other sites
$add[‘newstext’] = Replace_Links($add[‘newstext’]);

Leave a Comment

Comments No Comments

Table of Contents