- Readme First! - Read and follow the rules, otherwise your posts will be closed
There are currently, 79 guest(s) and 0 member(s) that are online. You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Enable self-generated Related Links on the Story Page [ ]
Author
Message
Imago
Captain
Joined: Jan 17, 2003
Posts: 629
Location: Europe
Posted:
Sat Apr 26, 2003 1:40 am
Open article.php and change
Code:
$boxtitle = ""._RELATED."";
$boxstuff = "<font class=\"content\">";
$sql = "select name, url from ".$prefix."_related where tid=$topic";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$name = $row[name];
$url = $row[url];
$boxstuff .= "<strong><big>&</big></strong>&<a href=\"$url\" target=\"new\">$name</a><br>\n";
}
to
Code:
$boxtitle = ""._RELATED."";
$boxstuff = "<font class=\"content\">";
unset($location);
$links = array();
$hrefs = array();
$pos = 0;
while (!(($pos = strpos($bodytext,"<",$pos)) === false)) {
$pos++;
$endpos = strpos($bodytext,">",$pos);
$tag = substr($bodytext,$pos,$endpos-$pos);
$tag = trim($tag);
if (isset($location)) {
if (!strcasecmp(strtok($tag," "),"/A")) {
$link = substr($bodytext,$linkpos,$pos-1-$linkpos);
$links[] = $link;
$hrefs[] = $location;
unset($location);
}
$pos = $endpos+1;
} else {
if (!strcasecmp(strtok($tag," "),"A")) {
if (eregi("HREF[ \t\n\r\v]*=[ \t\n\r\v]*\"([^\"]*)\"",$tag,$regs));
else if (eregi("HREF[ \t\n\r\v]*=[ \t\n\r\v]*([^ \t\n\r\v]*)",$tag,$regs));
else $regs[1] = "";
if ($regs[1]) {
$location = $regs[1];
}
$pos = $endpos+1;
$linkpos = $pos;
} else {
$pos = $endpos+1;
}
}
}
for ($i=0; $i<sizeof($links); $i++) {
if (strlen($links[$i]) > 20 AND !ereg(" ", $links[$i])) {
$alttext = "$links[$i]";
$links[$i] = substr($links[$i],0,19) . '';
} else {
$alttext = "";
}
Demo:
http://www.orientalgate.org/article378.html
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum