vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How do I use input cleaner to clean arrays? (https://vborg.vbsupport.ru/showthread.php?t=133457)

Antivirus 12-07-2006 11:31 PM

How do I use input cleaner to clean arrays?
 
the following code works fine for me using straight php, however when i try to get it to work using the vbulletin input cleaner, it just posts "array" into the responses field and wipes out the submittes results:

here's what's working for me using "non-vb" php:
PHP Code:

foreach ($_POST['whatyoudid'] as $feedbackdetailid => $whatyoudid)
{
    
$db->query_write("
        UPDATE scst_feedbackdetail SET 
            whatyoudid = '" 
addslashes($whatyoudid) . "', 
            responses = '" 
addslashes($_POST['responses'][$feedbackdetailid]) . "',
            comments = '" 
addslashes($_POST['comments'][$feedbackdetailid]) . "'
        WHERE feedbackdetailid = '" 
$feedbackdetailid "'
    "
);


i tried to clean it as follows but no dice:
PHP Code:

    $vbulletin->input->clean_array_gpc('p', array(
        
'feedbackdetailid'    =>    TYPE_UINT,
        
'whatyoudid'        =>    TYPE_STR,
        
'responses'            =>    TYPE_STR,
        
'comments'            =>    TYPE_STR
    
));

foreach (
$db->escape_string($vbulletin->GPC['whatyoudid']) as $feedbackdetailid => $whatyoudid)
{
    
$db->query_write("
        UPDATE " 
TABLE_PREFIX "scst_feedbackdetail SET 
            whatyoudid = '" 
$whatyoudid "', 
            responses = '" 
$db->escape_string($vbulletin->GPC['responses'][$feedbackdetailid]) . "',
            comments = '" 
$db->escape_string($vbulletin->GPC['comments'][$feedbackdetailid]) . "'
        WHERE feedbackdetailid = '" 
$feedbackdetailid "'
    "
);


I just need to figure out how to clean the two arrays above... $_POST['responses'][$feedbackdetailid] and $_POST['comments'][$feedbackdetailid]

can anyone save me from bloody torment?

Antivirus 12-10-2006 01:36 AM

ok i figured it out... thanks to Alan's HOWTO on the input cleaner class...

this works for me:
PHP Code:

$vbulletin->input->clean_array_gpc('p', array(
    
'whatyoudid'    =>    TYPE_ARRAY_STR,
    
'responses'    =>    TYPE_ARRAY_STR,
    
'comments'    =>    TYPE_ARRAY_STR
));

foreach (
$vbulletin->GPC['whatyoudid'] as $feedbackdetailid => $whatyoudid)
{
    
$db->query_write("
        UPDATE scst_feedbackdetail SET 
            whatyoudid    = '" 
$db->escape_string($whatyoudid) . "', 
            responses    = '" 
$db->escape_string($vbulletin->GPC['responses'][$feedbackdetailid]) . "', 
            comments    = '" 
$vbulletin->GPC['comments'][$feedbackdetailid] . "'
        WHERE feedbackdetailid    = '" 
$feedbackdetailid "'
    "
);


:)


All times are GMT. The time now is 05:00 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.01804 seconds
  • Memory Usage 1,734KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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