succo
06-05-2007, 07:28 AM
ok, this is what i'd like to do:
i've got a nice 'media' forum, containing many bbcode tags for stuff i'd like to show in the homepage... at the moment i'm working on making the 'upcoming' module read all the posts in some forums, find the ones containing 'my' bbcode and strip it and put it in a variable... this is my code so far:
<?php
require_once('./global.php'); // for now it's working alone :)
$mod_options['code'] = "media"; // this is my media code
$mod_options['limit'] = "5"; // i want only five records
$mod_options['forumid'] = "35"; // the forum where the media stuff is
if (!$mod_options['replace']) {
$mod_options['replace'] = $mod_options['code'];
}
$poststuffs = $db->query_read_slave("
SELECT post.pagetext
FROM " . TABLE_PREFIX . "post AS post
INNER JOIN " . TABLE_PREFIX . "thread USING (threadid)
WHERE forumid = ".$mod_options['forumid']."
AND pagetext LIKE '%[".$mod_options['code']."]%[/".$mod_options['code']."]%'
AND pagetext NOT LIKE '%[".$mod_options['code']."]%mp3[/".$mod_options['code']."]%'
AND pagetext NOT LIKE '%[".$mod_options['code']."]mms%[/".$mod_options['code']."]%'
AND pagetext NOT LIKE '%%[".$mod_options['code']."]%[/".$mod_options['code']."]%%'
ORDER BY post.dateline DESC LIMIT ".$mod_options['limit']."
");
while ($poststuff = $db->fetch_array($poststuffs)) {
$poststring[] = ereg_replace("\[/".$mod_options['code']."\].*$", "[/".$mod_options['code']."]", ereg_replace("^.*\[".$mod_options['code']."\]", "[".$mod_options['replace']."]", $poststuff[pagetext])); // remove everything before and after my tag
}
print_r($poststring); // i want to see what happened :)
?>
it's partially working, as it finds the correct posts, but (in one case) doesn't succeed in stripping some part of the post away, maybe (that's what i noticed) because it finds some " (quotes)
may anyone help in building this thing up? :)
i've got a nice 'media' forum, containing many bbcode tags for stuff i'd like to show in the homepage... at the moment i'm working on making the 'upcoming' module read all the posts in some forums, find the ones containing 'my' bbcode and strip it and put it in a variable... this is my code so far:
<?php
require_once('./global.php'); // for now it's working alone :)
$mod_options['code'] = "media"; // this is my media code
$mod_options['limit'] = "5"; // i want only five records
$mod_options['forumid'] = "35"; // the forum where the media stuff is
if (!$mod_options['replace']) {
$mod_options['replace'] = $mod_options['code'];
}
$poststuffs = $db->query_read_slave("
SELECT post.pagetext
FROM " . TABLE_PREFIX . "post AS post
INNER JOIN " . TABLE_PREFIX . "thread USING (threadid)
WHERE forumid = ".$mod_options['forumid']."
AND pagetext LIKE '%[".$mod_options['code']."]%[/".$mod_options['code']."]%'
AND pagetext NOT LIKE '%[".$mod_options['code']."]%mp3[/".$mod_options['code']."]%'
AND pagetext NOT LIKE '%[".$mod_options['code']."]mms%[/".$mod_options['code']."]%'
AND pagetext NOT LIKE '%%[".$mod_options['code']."]%[/".$mod_options['code']."]%%'
ORDER BY post.dateline DESC LIMIT ".$mod_options['limit']."
");
while ($poststuff = $db->fetch_array($poststuffs)) {
$poststring[] = ereg_replace("\[/".$mod_options['code']."\].*$", "[/".$mod_options['code']."]", ereg_replace("^.*\[".$mod_options['code']."\]", "[".$mod_options['replace']."]", $poststuff[pagetext])); // remove everything before and after my tag
}
print_r($poststring); // i want to see what happened :)
?>
it's partially working, as it finds the correct posts, but (in one case) doesn't succeed in stripping some part of the post away, maybe (that's what i noticed) because it finds some " (quotes)
may anyone help in building this thing up? :)