PDA

View Full Version : What am i doing wrong?


MindTrix
01-11-2004, 11:48 AM
Newbie question :)
what am i doing wrong here

function fetch_censored_text($text)
{
global $vboptions;
static $censorwords;
if ($forumid == 1) {print $text;}
elseif ($vboptions['enablecensor'] AND !empty($vboptions['censorwords']))
{
if (empty($censorwords))
{
$vboptions['censorwords'] = preg_quote($vboptions['censorwords'], '#');
$censorwords = preg_split('#\s+#', $vboptions['censorwords'], -1, PREG_SPLIT_NO_EMPTY);
}
foreach ($censorwords AS $censorword)
{
if (substr($censorword, 0, 2) == '\\{')
{
$censorword = substr($censorword, 2, -2);
$text = preg_replace('#(?<=[^A-Za-z]|^)' . $censorword . '(?=[^A-Za-z]|$)#si', str_repeat($vboptions['censorchar'], strlen($censorword)), $text);
}
else
{
$text = preg_replace("#$censorword#si", str_repeat($vboptions['censorchar'], strlen($censorword)), $text);
}
}
}
// strip any admin-specified blank ascii chars
$text = strip_blank_ascii($text, $vboptions['censorchar']);
return $text;
}

Basically i added this part

if ($forumid == 1) {print $text;}
elseif

I know im probably going about everything totaly wrong.

Advice welcome :)

Lesane
01-11-2004, 12:32 PM
First: where is $forumid coming from? ;)
Change:
function fetch_censored_text($text)
Into:
function fetch_censored_text($text,$forumid)

Second: It's a function, just like the end... return the text:
Change:
print $text;
Into:
return $text;

MindTrix
01-11-2004, 12:34 PM
Will that make it work?

MindTrix
01-11-2004, 12:41 PM
Missing argument 2 for fetch_censored_text() in /home/general/public_html/forum/includes/functions.php on line 342

doh :)

MindTrix
01-11-2004, 12:41 PM
i kind of know what that error means, and obviously know why it has appeared, but not too brainy on how to sort it :)

MindTrix
01-11-2004, 12:56 PM
Well i have figured out why im getting there error and how to fix it :) Just need to find out where censored_text() is defined etc :) Im gonna get this one!!!!

MindTrix
01-11-2004, 01:19 PM
ok ok i have searched, Newthread.php, newpost.php, showthread.php, showpost.php, init.php and no where can i find where fetch_censored_text
is defined. Help :)

Xenon
01-11-2004, 02:00 PM
/home/general/public_html/forum/includes/functions.php

hmm, that's a good hint to where it's defined :p

MindTrix
01-11-2004, 02:02 PM
Well the only time i found it in that file, is the code i placed above Xenon.

Xenon
01-11-2004, 02:05 PM
well but you are calling it incorrectly :)

you have to add two parameters, but are just providing one :)

change
function fetch_censored_text($text, $forumid)

into
function fetch_censored_text($text, $forumid = -1)

that should avoid the error message :)

MindTrix
01-11-2004, 02:08 PM
I did that before, just forgot to post it here.

I had
function fetch_censored_text($text,$forumid=1)

This removed my error message. But i still cannot get the hack to work how i want it too.

I found inside

Functions_newpost.php this code


// censor main message text
$post['message'] = fetch_censored_text($post['message']);
and changed it too
// censor main message text
$post['message'] = fetch_censored_text($post['message'],$forumid);

but still no luck lol. I know im messing up somewhere (obviously)

Xenon
01-11-2004, 02:10 PM
$post['message'] = fetch_censored_text($post['message'],$forumid);

should be
$post['message'] = fetch_censored_text($post['message'],$threadinfo['forumid']); iirc

also don't use =1 use = -1 as the standart should be to censor ;)

MindTrix
01-11-2004, 02:36 PM
hmmm ok did as you suggested Xenon and still no luck, this is starting to become a pickle now :)