vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   [SOLVED] standard_error on foreach loop (https://vborg.vbsupport.ru/showthread.php?t=315368)

omardealo 11-11-2014 02:13 PM

[SOLVED] standard_error on foreach loop
 
Hello ,

i make a plugin [stop new thread if That it contains Banned words]
every thing is okay , but when i try print all Banned words Written by User , but Do not print all the words, only the last word .
i Used the code in a php file with ECHO to print and working good , but in plugin i have problem with standard_error Do not print, but only the last value . so Where the problem ?


PHP Code:

$bwords explode("|"$vbulletin->options['banwords_wordslist']); 
$string $vbulletin->GPC['message'];
$matches = array();
$matchFound preg_match_all(
                
"/\b(" implode($bwords,"|") . ")\b/i"
                
$string
                
$matches
              
);
if (
$matchFound)
{
  
$words array_unique($matches[0]);
  foreach(
$words as $word)
  {
     eval (
standard_error"Banned Words : <li>" $word "</li>")); 
  }



Dave 11-11-2014 02:17 PM

Because the standard_error stops anything else once it's called, it will only loop once through the foreach loop.
Try something like this instead:

PHP Code:

$bwords explode("|"$vbulletin->options['banwords_wordslist']);  
$string $vbulletin->GPC['message']; 
$matches = array(); 
$matchFound preg_match_all
                
"/\b(" implode($bwords,"|") . ")\b/i",  
                
$string,  
                
$matches 
              
); 
if (
$matchFound

  
$words array_unique($matches[0]); 
  eval (
standard_error"Banned Words : <li>" implode(", "$words) . "</li>"));  



omardealo 11-11-2014 04:04 PM

Quote:

Originally Posted by Dave (Post 2522267)
Because the standard_error stops anything else once it's called, it will only loop once through the foreach loop.
Try something like this instead:

PHP Code:

$bwords explode("|"$vbulletin->options['banwords_wordslist']);  
$string $vbulletin->GPC['message']; 
$matches = array(); 
$matchFound preg_match_all
                
"/\b(" implode($bwords,"|") . ")\b/i",  
                
$string,  
                
$matches 
              
); 
if (
$matchFound

  
$words array_unique($matches[0]); 
  eval (
standard_error"Banned Words : <li>" implode(", "$words) . "</li>"));  




Well, I understand
Now The result is shown like that :

Code:

Banned Words :
  • first word, Second word


i want every word shown in <li>

Code:

Banned Words :
  • first word

  • Second word


thanks brother Dave

Dave 11-11-2014 04:16 PM

Then change
PHP Code:

eval (standard_error"Banned Words : <li>" implode(", "$words) . "</li>")); 

to

PHP Code:

eval (standard_error"Banned Words : <li>" implode('</li><li>'$words) . "</li>")); 

That should do the trick.

omardealo 11-11-2014 05:01 PM

Quote:

Originally Posted by Dave (Post 2522287)
Then change
PHP Code:

eval (standard_error"Banned Words : <li>" implode(", "$words) . "</li>")); 

to

PHP Code:

eval (standard_error"Banned Words : <li>" implode('</li><li>'$words) . "</li>")); 

That should do the trick.

Yes I've been absent from my mind :D
thanxs brother :up:


All times are GMT. The time now is 03:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01155 seconds
  • Memory Usage 1,752KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (7)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete