vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Is this function good? (https://vborg.vbsupport.ru/showthread.php?t=95603)

Guest190829 09-04-2005 02:03 AM

Is this function good?
 
Here's my edit_comment function, is it good? It's coding in OOP, though I kind of lost my understanding for it, so I'm going to have to reread on it. That's why I'm posting this, and also if it meets 3.5 syntax standards correctly, and if it's secure. This way, I can edit all my mistakes in previous functions I wrote. Any comments are greatly appreciated.

PHP Code:

function edit_comment() // edit comment
    
{
    
    global 
$id$vbulletin
        
        $this
->id $vbulletin->input->clean_gpc('g''commentid'TYPE_UINT);
        
        
$getcomment $vbulletin->db->query_first("SELECT comment_text, comment_title 
                                                   FROM space_comments
                                                   WHERE comment_id = '" 
$this->id "'
                                                 "
);
                                
        eval(
'$edit_comment .= "' fetch_template('edit_comment') . '";');
        
        if (
$_REQUEST['do'] == 'submit')
        {
            
$vbulletin->input->clean_array_gpc('p', array('title' => TYPE_STR'text' => TYPE_STR))
            
            
$this->title $vbulletin->GPC['title'];
            
$this->text $vbulletin->GPC['text'];
    
            
$add_edited_comment $vbulletin->db->query_write("UPDATE space_comments
                                                               SET comment_title = '" 
$db->escape_string($this->title"', 
                                                                   comment_text = '" 
$db->esacpe_string($this->text"'
                                                               WHERE comment_id = '" 
$this->id "'
                                                              "
);
                                                    
        }
    } 


Adrian Schneider 09-04-2005 02:08 AM

I'd change the $_REQUEST['do'] to $_POST['do'] so someone can't manipulate the URL and have it submit.

Guest190829 09-04-2005 02:28 AM

Well I was also going to add permissions to that if statement, would the $_POST['do'] still be needed?

Adrian Schneider 09-04-2005 02:47 AM

It depends what triggers the function and any other security checks you have, but personally I would use $_POST for doing this.

Andreas 09-04-2005 02:48 AM

$_POST can be manipulates as easily as $_GET, so you won't gain much.

AN-net 09-04-2005 02:58 AM

i would go with post, at least its checked from which referrer:)

Guest190829 09-04-2005 02:59 AM

Okay, then I guess I will change it to post for added security. Is everything else okay, besides that?


All times are GMT. The time now is 03:33 AM.

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.01055 seconds
  • Memory Usage 1,735KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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