Jump to content

WinHTTP functions


trancexx
 Share

Recommended Posts

Seems way to much cumbersome to me. Wouldn't be easy doing as i asked here?

take a look

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

Seems way to much cumbersome to me. Wouldn't be easy doing as i asked here?

take a look

Well, that's your choice, that depends of what you feel more accustomed to. I replied to you in that other thread.

@trancexx: I think there may be a little bug in the internal function __WinHttpFinalizeCtrls : I wanted to preview a post where I filled the fields subject and message only, and set the preview button to True.

The problem is that the data that was being sent (it's an application/x-www-form-urlencoded form by the way) was this:

subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=32104&s=&securitytoken=1295202737-c31b8cb3d41a8b148ce55a3b6d702722aaaaaaaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=EDITED&emailupdate=&polloptions=4&preview=Preview+Post

I debugged the value of $sAddData and in every part of the code the part with taglist was without value as it should (&taglist=) because the source code of the taglist is this:

<input type="text" class="bginput" name="taglist" id="tag_add_input" value="" size="40" tabindex="1" />

but when exiting __WinHttpFinalizeCtrls it changed to &taglist=32104 :x So I debugged the function by adding msgboxes and a consolewrite log. Here is the code:

Func __WinHttpFinalizeCtrls($sSubmit, $sRadio, $sCheckBox, $sButton, ByRef $sAddData, $sSep = "")
    If $sSubmit Then ; If no submit is specified
        Local $aSubmit = StringSplit($sSubmit, "&", 2)
        For $m = 1 To UBound($aSubmit) - 1 ; skip the first (leave that one as default)
            $sAddData = StringReplace($sAddData, $sSep & $aSubmit[$m], "") ; delete the rest
            MsgBox(0,"adddatafinalizectrls at $aSubmit and $m = "&$m,$sAddData)
            ConsoleWrite("adddatafinalizectrls at $aSubmit and $m = "&$m&" :"&@CRLF&$sAddData&@CRLF&@CRLF)
        Next
    EndIf
    If $sRadio Then ; If no radio is specified
        Local $aRadio = StringSplit($sRadio, "&", 2)
        For $m = 0 To UBound($aRadio) - 1 ; for all "radio" controls
            $sAddData = StringReplace($sAddData, $sSep & $aRadio[$m], "") ; delete
            MsgBox(0,"adddatafinalizectrls at $aRadio and $m = "&$m,$sAddData)
            ConsoleWrite("adddatafinalizectrls at $aRadio and $m = "&$m&" :"&@CRLF&$sAddData&@CRLF&@CRLF)
        Next
    EndIf
    If $sCheckBox Then ; If no checkbox is specified
        Local $aCheckBox = StringSplit($sCheckBox, "&", 2)
        For $m = 0 To UBound($aCheckBox) - 1 ; for all left "checkbox" controls in $sCheckBox string (non-set)
            $sAddData = StringReplace($sAddData, $sSep & $aCheckBox[$m], "") ; delete
            MsgBox(0,"adddatafinalizectrls at $aCheckbox and $m = "&$m,$sAddData)
            ConsoleWrite("adddatafinalizectrls at $aCheckbox and $m = "&$m&" :"&@CRLF&$sAddData&@CRLF&@CRLF)
        Next
    EndIf
    If $sButton Then ; If no button is specified
        Local $aButton = StringSplit($sButton, "&", 2)
        For $m = 0 To UBound($aButton) - 1 ; for all left "button" controls in $sButton string (non-set)
            $sAddData = StringReplace($sAddData, $sSep & $aButton[$m], "") ; delete
            MsgBox(0,"adddatafinalizectrls at $aButton and $m = "&$m,$sAddData)
            ConsoleWrite("adddatafinalizectrls at $aButton and $m = "&$m&" :"&@CRLF&$sAddData&@CRLF&@CRLF)
        Next
    EndIf
EndFunc   ;==>__WinHttpFinalizeCtrls

And this is the result of the console log (I highlighted in red and blue where &taglist changed):

adddatafinalizectrls at $aRadio and $m = 0 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=&iconid=1&iconid=13&iconid=12&iconid=11&iconid=10&iconid=9&iconid=8&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=2&iconid=14&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 1 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=9&iconid=8&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 2 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=9&iconid=8&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 3 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=9&iconid=8&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 4 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=9&iconid=8&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 5 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=9&iconid=8&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 6 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=8&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 7 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 8 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=6&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 9 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=5&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 10 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=4&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 11 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=3&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 12 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=3210&iconid=24&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 13 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=32104&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aRadio and $m = 14 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=32104&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&parseurl=1&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aCheckbox and $m = 0 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=32104&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&disablesmilies=1&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aCheckbox and $m = 1 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=32104&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&emailupdate=&postpoll=yes&polloptions=4&preview=Preview+Post

adddatafinalizectrls at $aCheckbox and $m = 2 :

&subject=Test77&message=Test77+of+previewing+a+post&wysiwyg=1&taglist=32104&s=&securitytoken=1295207273-81b1a22b1588682060384b6fe1ec2fede72faaaa&f=42&do=postthread&posthash=&poststarttime=&loggedinuser=22aaa&emailupdate=&polloptions=4&preview=Preview+Post

As you can see the changes happened when doing the $aRadio controls. That would explain why &taglist= is concatenated with numbers, because the values of radios are numbers

<input type="radio" name="iconid" value="6" id="rb_iconid_6" tabindex="1" onclick="swap_posticon('pi_6')"  />

. There may be some problem with the splits and replacements there...

Here you have the source of the form, and thanks in advance for your help!

<form action="newthread.php?do=postthread&amp;f=42" method="post" name="vbform" onsubmit="return vB_Editor['vB_Editor_001'].prepare_submit(this.subject.value, 4)">

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<tr>
    <td class="tcat">
        <span class="smallfont" style="float:right"><strong>Forum</strong>: <a href="introductions/">Introductions</a></span>

        Post New Thread
    </td>
</tr>
<tr>
    <td class="panelsurround" align="center">
    <div class="panel">
        <div style="width:640px" align="left">

        
    <!-- user is logged in -->
    <div class="smallfont" style="float:right">
        Logged in as <a href="members/22aaa.html" target="_blank">MY USERNAME</a>

    </div>



        <!-- subject field -->
        <table cellpadding="0" cellspacing="0" border="0" class="fieldset">

        <tr>
            
                <td class="smallfont" colspan="4">Title:</td>
            
        </tr>
        <tr>
            
            <td>
                <input type="text" class="bginput" id="subjecttitle" name="subject" onblur="UpdateTitle(42,22544, 25)" value="" size="40" maxlength="150" tabindex="1" />
            </td>
            <td>&nbsp;&nbsp;</td>

            <td><img id="display_posticon" src="clear.gif" alt="" /></td>
        </tr>
        </table>
        <!-- / subject field -->

        <!-- message area -->
        <div class="smallfont">Message:</div>
        <!-- Editor Scripts -->
<script type="text/javascript" src="clientscript/vbulletin_textedit.js?v=386"></script>

<script type="text/javascript">
<!--
var fontoptions = new Array("Arial", "Arial Black", "Arial Narrow", "Book Antiqua", "Century Gothic", "Comic Sans MS", "Courier New", "Fixedsys", "Franklin Gothic Medium", "Garamond", "Georgia", "Impact", "Lucida Console", "Lucida Sans Unicode", "Microsoft Sans Serif", "Palatino Linotype", "System", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana");
var sizeoptions = new Array(1, 2, 3, 4, 5, 6, 7);
var smilieoptions = { 
    'Generic Smilies' : {
        '8' : new Array('images/smilies/mad.gif', ':mad:', 'Mad'),
        '5' : new Array('images/smilies/tongue.gif', ':p', 'Stick Out Tongue'),
        '2' : new Array('images/smilies/redface.gif', ':o', 'Embarrassment'),
        '10' : new Array('images/smilies/confused.gif', ':confused:', 'Confused'),
        '4' : new Array('images/smilies/wink.gif', ';)', 'Wink'),
        '1' : new Array('images/smilies/smile.gif', ':)', 'Smile'),
        '3' : new Array('images/smilies/biggrin.gif', ':D', 'Big Grin'),
        '11' : new Array('images/smilies/frown.gif', ':(', 'Frown'),
        '7' : new Array('images/smilies/rolleyes.gif', ':rolleyes:', 'Roll Eyes (Sarcastic)'),
        '6' : new Array('images/smilies/cool.gif', ':cool:', 'Cool'),
        '9' : new Array('images/smilies/eek.gif', ':eek:', 'EEK!')} };

var istyles = { "pi_button_down" : [ "#98B5E2", "#000000", "0px", "1px solid #316AC5" ], "pi_button_hover" : [ "#C1D2EE", "#000000", "0px", "1px solid #316AC5" ], "pi_button_normal" : [ "#E1E1E2", "#000000", "1px", "none" ], "pi_button_selected" : [ "#F1F6F8", "#000000", "0px", "1px solid #316AC5" ], "pi_menu_down" : [ "#98B5E2", "#316AC5", "0px", "1px solid #316AC5" ], "pi_menu_hover" : [ "#C1D2EE", "#316AC5", "0px", "1px solid #316AC5" ], "pi_menu_normal" : [ "#FFFFFF", "#000000", "0px", "1px solid #FFFFFF" ], "pi_popup_down" : [ "#98B5E2", "#000000", "0px", "1px solid #316AC5" ] };
var ltr = 'left';

var smiliewindow_x = 240;
var smiliewindow_y = 280;

var ignorequotechars = 1;
var allowbasicbbcode = true;

// vB Phrases
vbphrase["wysiwyg_please_wait"]          = "Please wait for the WYSIWYG editor to finish loading...";
vbphrase["wysiwyg_initialized"]          = "WYSIWYG Editor initialized for %1$s in %2$s seconds.";
vbphrase["wysiwyg_command_invalid"]      = "This command is invalid or not implemented.";
vbphrase["moz_must_select_text"]         = "Mozilla requires that you must select some text for this function to work";
vbphrase["moz_edit_config_file"]         = "You need to edit your Mozilla config file to allow this action.";
vbphrase["enter_tag_option"]             = "Please enter the option for your %1$s tag:";
vbphrase["must_select_text_to_use"]      = "You must select some text to use this function.";
vbphrase["browser_is_safari_no_wysiwyg"] = "The Safari browser does not support WYSIWYG mode.";
vbphrase["enter_option_x_tag"]           = "Enter the option for the [%1$s] tag:";
vbphrase["enter_text_to_be_formatted"]   = "Enter the text to be formatted";
vbphrase["enter_link_text"]              = "Enter the text to be displayed for the link (optional):";
vbphrase["enter_list_type"]              = "What type of list do you want? Enter '1' for a numbered list, enter 'a' for an alphabetical list, or leave blank for a list with bullet points:";
vbphrase["enter_list_item"]              = "Enter a list item.\r\nLeave the box empty or press 'Cancel' to complete the list:";
vbphrase["must_enter_subject"]           = "You must enter a title / subject!";
vbphrase["message_too_short"]            = "The message you have entered is too short. Please lengthen your message to at least %1$s characters.";
vbphrase["enter_link_url"]               = "Please enter the URL of your link:";
vbphrase["enter_image_url"]              = "Please enter the URL of your image:";
vbphrase["enter_email_link"]             = "Please enter the email address for the link:";
vbphrase["complete_image_verification"]  = "You did not complete the Image Verification";
vbphrase["iespell_not_installed"]        = "ieSpell is a spell-checking tool for Internet Explorer.\r\n\r\nIf you would like to download ieSpell, click OK; otherwise click Cancel.\r\n\r\nieSpell can be downloaded from http://www.iespell.com";
vbphrase["click_quick_reply_icon"]       = "";
vbphrase["insert_all"]                   = "Insert All";

//-->
</script>
<!-- / Editor Scripts -->

<table cellpadding="0" cellspacing="0" border="0">
<tr>
    <td id="vB_Editor_001" class="vBulletin_editor" width="100%">
        <div id="vB_Editor_001_controls" class="controlbar">
            <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_removeformat"><img src="images/editor/removeformat.gif" width="21" height="20" alt="Remove Text Formatting" /></div></td>
            
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>

            
            
                <td><div class="imagebutton" id="vB_Editor_001_popup_fontname" title="Fonts">
                    <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td class="popup_feedback"><div id="vB_Editor_001_font_out" style="width:91px">&nbsp;</div></td>
                        <td class="popup_pickbutton"><img src="images/editor/menupop.gif" width="11" height="16" alt="" /></td>
                    </tr>
                    </table>
                </div></td>
            
            
                <td><div class="imagebutton" id="vB_Editor_001_popup_fontsize" title="Sizes">

                    <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td class="popup_feedback"><div id="vB_Editor_001_size_out" style="width:25px">&nbsp;</div></td>
                        <td class="popup_pickbutton"><img src="images/editor/menupop.gif" width="11" height="16" alt="" /></td>
                    </tr>
                    </table>
                </div></td>
            
            
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>
                <td><div class="imagebutton" id="vB_Editor_001_popup_forecolor" title="Colors">

                    <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td id="vB_Editor_001_color_out"><img src="images/editor/color.gif" width="21" height="16" alt="" /><br /><img src="clear.gif" id="vB_Editor_001_color_bar" alt="" style="background-color:black" width="21" height="4" /></td>
                        <td class="alt_pickbutton"><img src="images/editor/menupop.gif" width="11" height="16" alt="" /></td>
                    </tr>
                    </table>
                </div></td>
            
            
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>
                <td><div class="imagebutton" id="vB_Editor_001_popup_smilie" title="Smilies">

                    <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td><img src="images/editor/smilie.gif" alt="" width="21" height="20" /></td>
                        <td class="alt_pickbutton"><img src="images/editor/menupop.gif" width="11" height="16" alt="" /></td>
                    </tr>
                    </table>
                </div></td>
            
            
            
                <!--
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_cut"><img src="images/editor/cut.gif" width="21" height="20" alt="Cut" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_copy"><img src="images/editor/copy.gif" width="21" height="20" alt="Copy" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_paste"><img src="images/editor/paste.gif" width="21" height="20" alt="Paste" /></div></td>
                -->
    
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>

                <td><div class="imagebutton" id="vB_Editor_001_cmd_undo"><img src="images/editor/undo.gif" width="21" height="20" alt="Undo" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_redo"><img src="images/editor/redo.gif" width="21" height="20" alt="Redo" /></div></td>

            <td width="100%">&nbsp;</td>
            
                <td>
                    <div class="imagebutton" id="vB_Editor_001_cmd_resize_0_100"><img src="images/editor/resize_0.gif" width="21" height="9" alt="Decrease Size" /></div>
                    <div class="imagebutton" id="vB_Editor_001_cmd_resize_1_100"><img src="images/editor/resize_1.gif" width="21" height="9" alt="Increase Size" /></div>
                </td>
            
                <td><div class="imagebutton" id="vB_Editor_001_cmd_switchmode"><img src="images/editor/switchmode.gif" width="21" height="20" alt="Switch Editor Mode" /></div></td>

            
            </tr>
            </table>

            
            <table cellpadding="0" cellspacing="0" border="0">
            <tr>
            
                <td><div class="imagebutton" id="vB_Editor_001_cmd_bold"><img src="images/editor/bold.gif" width="21" height="20" alt="Bold" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_italic"><img src="images/editor/italic.gif" width="21" height="20" alt="Italic" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_underline"><img src="images/editor/underline.gif" width="21" height="20" alt="Underline" /></div></td>
            
            
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>

                
                <td><div class="imagebutton" id="vB_Editor_001_cmd_justifyleft"><img src="images/editor/justifyleft.gif" width="21" height="20" alt="Align Left" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_justifycenter"><img src="images/editor/justifycenter.gif" width="21" height="20" alt="Align Center" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_justifyright"><img src="images/editor/justifyright.gif" width="21" height="20" alt="Align Right" /></div></td>
                
            
            
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>
            
            
                <td><div class="imagebutton" id="vB_Editor_001_cmd_insertorderedlist"><img src="images/editor/insertorderedlist.gif" width="21" height="20" alt="Ordered List" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_insertunorderedlist"><img src="images/editor/insertunorderedlist.gif" width="21" height="20" alt="Unordered List" /></div></td>
            
            
                
                <td><div class="imagebutton" id="vB_Editor_001_cmd_outdent"><img src="images/editor/outdent.gif" width="21" height="20" alt="Decrease Indent" /></div></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_indent"><img src="images/editor/indent.gif" width="21" height="20" alt="Increase Indent" /></div></td>
                
            
            
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>

                
                    <td><div class="imagebutton" id="vB_Editor_001_cmd_createlink"><img src="images/editor/createlink.gif" width="21" height="20" alt="Insert Link" /></div></td>
                    <td><div class="imagebutton" id="vB_Editor_001_cmd_unlink"><img src="images/editor/unlink.gif" width="21" height="20" alt="Remove Link" /></div></td>
                    <td><div class="imagebutton" id="vB_Editor_001_cmd_email"><img src="images/editor/email.gif" width="21" height="20" alt="Insert Email Link" /></div></td>
                
                
                    <td><div class="imagebutton" id="vB_Editor_001_cmd_insertimage"><img src="images/editor/insertimage.gif" width="21" height="20" alt="Insert Image" /></div></td>
                
            
            
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>
                <td><div class="imagebutton" id="vB_Editor_001_cmd_wrap0_quote"><img src="images/editor/quote.gif" width="21" height="20" alt="Wrap [QUOTE] tags around selected text" /></div></td>
            
            
                <td><img src="images/editor/separator.gif" width="6" height="20" alt="" /></td>             
                
                    <td><div class="imagebutton" id="vB_Editor_001_cmd_wrap0_code"><img src="images/editor/code.gif" width="21" height="20" alt="Wrap [CODE] tags around selected text" /></div></td>
                
                
                    <td><div class="imagebutton" id="vB_Editor_001_cmd_wrap0_html"><img src="images/editor/html.gif"  width="21" height="20" alt="Wrap [HTML] tags around selected text" /></div></td>

                
                
                    <td><div class="imagebutton" id="vB_Editor_001_cmd_wrap0_php"><img src="images/editor/php.gif" width="21" height="20" alt="Wrap [PHP] tags around selected text" /></div></td>
                
            
            
            </tr>
            </table>
            

        </div>

        <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr valign="top">
            <td class="controlbar">
                <textarea name="message" id="vB_Editor_001_textarea" rows="10" cols="60" style="display:block; width:540px; height:250px" tabindex="1" dir="ltr"></textarea>

            </td>
            <td class="controlbar">
<fieldset id="vB_Editor_001_smiliebox" title="Smilies">
    <legend>Smilies</legend>
    <table cellpadding="4" cellspacing="0" border="0" align="center">
    <tr align="center" valign="bottom">
<td><img src="images/smilies/mad.gif" id="vB_Editor_001_smilie_8" alt=":mad:" title="Mad" border="0" class="inlineimg" /></td><td><img src="images/smilies/tongue.gif" id="vB_Editor_001_smilie_5" alt=":p" title="Stick Out Tongue" border="0" class="inlineimg" /></td><td><img src="images/smilies/redface.gif" id="vB_Editor_001_smilie_2" alt=":o" title="Embarrassment" border="0" class="inlineimg" /></td>
</tr>
<tr align="center" valign="bottom">
<td><img src="images/smilies/confused.gif" id="vB_Editor_001_smilie_10" alt=":confused:" title="Confused" border="0" class="inlineimg" /></td><td><img src="images/smilies/wink.gif" id="vB_Editor_001_smilie_4" alt=";)" title="Wink" border="0" class="inlineimg" /></td><td><img src="images/smilies/smile.gif" id="vB_Editor_001_smilie_1" alt=":)" title="Smile" border="0" class="inlineimg" /></td>
</tr>

<tr align="center" valign="bottom">
<td><img src="images/smilies/biggrin.gif" id="vB_Editor_001_smilie_3" alt=":D" title="Big Grin" border="0" class="inlineimg" /></td><td><img src="images/smilies/frown.gif" id="vB_Editor_001_smilie_11" alt=":(" title="Frown" border="0" class="inlineimg" /></td><td><img src="images/smilies/rolleyes.gif" id="vB_Editor_001_smilie_7" alt=":rolleyes:" title="Roll Eyes (Sarcastic)" border="0" class="inlineimg" /></td>
</tr>
<tr align="center" valign="bottom">
<td><img src="images/smilies/cool.gif" id="vB_Editor_001_smilie_6" alt=":cool:" title="Cool" border="0" class="inlineimg" /></td><td><img src="images/smilies/eek.gif" id="vB_Editor_001_smilie_9" alt=":eek:" title="EEK!" border="0" class="inlineimg" /></td>    <td colspan="1">&nbsp;</td>
</tr>

    
    </table>
</fieldset>
</td>
        </tr>
        </table>
    </td>

</tr>
</table>

<input type="hidden" name="wysiwyg" id="vB_Editor_001_mode" value="1" />

<script type="text/javascript">
<!--
vB_Editor['vB_Editor_001'] = new vB_Text_Editor('vB_Editor_001', 1, '42', '1', undefined, '');
//-->
</script>
        <!-- / message area -->

        
        <fieldset class="fieldset" style="margin-top: 6px">
            <legend>Tags</legend>
            <div style="padding:3px">

                <div>Separate tags using a comma.</div>
                <span id="tag_add"><input type="text" class="bginput" name="taglist" id="tag_add_input" value="" size="40" tabindex="1" /></span>
                <div>You may add 25 tag(s) to this thread.</div>
        </div>

            
                <div id="tag_add_menu" class="vbmenu_popup" style="display:none"></div>
                <script type="text/javascript" src="clientscript/vbulletin_ajax_tagsugg.js?v=386"></script>
                <script type="text/javascript">
                <!--
                vbmenu_register('tag_add', true);
                tag_add_comp = new vB_AJAX_TagSuggest('tag_add_comp', 'tag_add_input', 'tag_add');
                tag_add_comp.allow_multiple = true;
                tag_add_comp.set_delimiters('');
                //-->
                </script>

            
        </fieldset>
        

        
    <script type="text/javascript">
    <!--
    function swap_posticon(imgid)
    {
        var out = fetch_object("display_posticon");
        var img = fetch_object(imgid);
        if (img)
        {
            out.src = img.src;
            out.alt = img.alt;
        }
        else
        {
            out.src = "clear.gif";
            out.alt = "";
        }
    }
    // -->
    </script>
    <fieldset class="fieldset" style="margin-top: 6px">
        <legend>Post Icons</legend>
        <div style="padding:3px">
            <table cellpadding="0" cellspacing="1" border="0" width="95%">
            <tr>
                <td colspan="15"><div style="margin-bottom:3px">You may choose an icon for your message from the following list:</div></td>

            </tr>
            <tr>
                <td width="12%" nowrap="nowrap"><label for="rb_iconid_0"><input type="radio" name="iconid" value="0" id="rb_iconid_0" tabindex="1" onclick="swap_posticon(null)" checked="checked" />No icon &nbsp; &nbsp;</label></td>
                <td><input type="radio" name="iconid" value="1" id="rb_iconid_1" tabindex="1" onclick="swap_posticon('pi_1')"  /></td>
<td width="12%"><label for="rb_iconid_1"><img src="images/icons/icon1.gif" alt="Post" id="pi_1" onclick="rb_iconid_1.click()" /></label></td>
<td><input type="radio" name="iconid" value="13" id="rb_iconid_13" tabindex="1" onclick="swap_posticon('pi_13')"  /></td>
<td width="12%"><label for="rb_iconid_13"><img src="images/icons/icon13.gif" alt="Thumbs down" id="pi_13" onclick="rb_iconid_13.click()" /></label></td>
<td><input type="radio" name="iconid" value="12" id="rb_iconid_12" tabindex="1" onclick="swap_posticon('pi_12')"  /></td>
<td width="12%"><label for="rb_iconid_12"><img src="images/icons/icon12.gif" alt="Wink" id="pi_12" onclick="rb_iconid_12.click()" /></label></td>
<td><input type="radio" name="iconid" value="11" id="rb_iconid_11" tabindex="1" onclick="swap_posticon('pi_11')"  /></td>
<td width="12%"><label for="rb_iconid_11"><img src="images/icons/icon11.gif" alt="Red face" id="pi_11" onclick="rb_iconid_11.click()" /></label></td>

<td><input type="radio" name="iconid" value="10" id="rb_iconid_10" tabindex="1" onclick="swap_posticon('pi_10')"  /></td>
<td width="12%"><label for="rb_iconid_10"><img src="images/icons/icon10.gif" alt="Talking" id="pi_10" onclick="rb_iconid_10.click()" /></label></td>
<td><input type="radio" name="iconid" value="9" id="rb_iconid_9" tabindex="1" onclick="swap_posticon('pi_9')"  /></td>
<td width="12%"><label for="rb_iconid_9"><img src="images/icons/icon9.gif" alt="Unhappy" id="pi_9" onclick="rb_iconid_9.click()" /></label></td>
<td><input type="radio" name="iconid" value="8" id="rb_iconid_8" tabindex="1" onclick="swap_posticon('pi_8')"  /></td>
<td width="12%"><label for="rb_iconid_8"><img src="images/icons/icon8.gif" alt="Angry" id="pi_8" onclick="rb_iconid_8.click()" /></label></td>
</tr><tr><td>&nbsp;</td><td><input type="radio" name="iconid" value="7" id="rb_iconid_7" tabindex="1" onclick="swap_posticon('pi_7')"  /></td>
<td width="12%"><label for="rb_iconid_7"><img src="images/icons/icon7.gif" alt="Smile" id="pi_7" onclick="rb_iconid_7.click()" /></label></td>
<td><input type="radio" name="iconid" value="6" id="rb_iconid_6" tabindex="1" onclick="swap_posticon('pi_6')"  /></td>
<td width="12%"><label for="rb_iconid_6"><img src="images/icons/icon6.gif" alt="Cool" id="pi_6" onclick="rb_iconid_6.click()" /></label></td>
<td><input type="radio" name="iconid" value="5" id="rb_iconid_5" tabindex="1" onclick="swap_posticon('pi_5')"  /></td>
<td width="12%"><label for="rb_iconid_5"><img src="images/icons/icon5.gif" alt="Question" id="pi_5" onclick="rb_iconid_5.click()" /></label></td>
<td><input type="radio" name="iconid" value="4" id="rb_iconid_4" tabindex="1" onclick="swap_posticon('pi_4')"  /></td>
<td width="12%"><label for="rb_iconid_4"><img src="images/icons/icon4.gif" alt="Exclamation" id="pi_4" onclick="rb_iconid_4.click()" /></label></td>
<td><input type="radio" name="iconid" value="3" id="rb_iconid_3" tabindex="1" onclick="swap_posticon('pi_3')"  /></td>
<td width="12%"><label for="rb_iconid_3"><img src="images/icons/icon3.gif" alt="Lightbulb" id="pi_3" onclick="rb_iconid_3.click()" /></label></td>
<td><input type="radio" name="iconid" value="2" id="rb_iconid_2" tabindex="1" onclick="swap_posticon('pi_2')"  /></td>

<td width="12%"><label for="rb_iconid_2"><img src="images/icons/icon2.gif" alt="Arrow" id="pi_2" onclick="rb_iconid_2.click()" /></label></td>
<td><input type="radio" name="iconid" value="14" id="rb_iconid_14" tabindex="1" onclick="swap_posticon('pi_14')"  /></td>
<td width="12%"><label for="rb_iconid_14"><img src="images/icons/icon14.gif" alt="Thumbs up" id="pi_14" onclick="rb_iconid_14.click()" /></label></td>

                
            </tr>
            </table>
        </div>
    </fieldset>

    </div>
    </div>

    <div style="margin-top:6px">
        <input type="hidden" name="s" value="" />
        <input type="hidden" name="securitytoken" value="1295205352-0a5b470cf4842fddaf82631d5d68dee4b4701c51" />
        <input type="hidden" name="f" value="42" />
        <input type="hidden" name="do" value="postthread" />
        <input type="hidden" name="posthash" value="" />
        <input type="hidden" name="poststarttime" value="" />
        <input type="hidden" name="loggedinuser" value="22544" />

        <input type="submit" class="button" name="sbutton" id="vB_Editor_001_save" value="Submit New Thread" accesskey="s" tabindex="1" />
        <input type="submit" class="button" name="preview" value="Preview Post" accesskey="r" tabindex="1" />
    </div>
    </td>
</tr>
</table>


<br />

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<thead>
    <tr>

        <td class="tcat">
            <a style="float:right" href="#top" onclick="return toggle_collapse('newpost_options')"><img id="collapseimg_newpost_options" src="images/buttons/collapse_tcat.gif" alt="" border="0" /></a>
            Additional Options
        </td>
    </tr>
</thead>
<tbody id="collapseobj_newpost_options" style="">
    <tr valign="top">
        <td class="panelsurround" align="center">
        <div class="panel">

            <div style="width:640px" align="left">

                

                
                <fieldset class="fieldset">
                    <legend>Miscellaneous Options</legend>
                    <div style="padding:3px">
                        
                        <div><label for="cb_parseurl"><input type="checkbox" name="parseurl" value="1" id="cb_parseurl" tabindex="1" checked="checked" />Automatically parse links in text</label></div>
                        <div><label for="cb_disablesmilies"><input type="checkbox" name="disablesmilies" value="1" id="cb_disablesmilies" tabindex="1"  />Disable smilies in text</label></div>

                    </div>
                </fieldset>
                

                

                
                <fieldset class="fieldset">
                    <legend>Thread Subscription</legend>
                    <table cellpadding="0" cellspacing="3" border="0">
                    <tr>
                        <td>Notification Type:<br /><select name="emailupdate" tabindex="1">
                            <option value="9999" >Do not subscribe</option>

                            <option value="0" selected="selected">No email notification</option>
                            <option value="1" >Instant email notification</option>
                            <option value="2" >Daily email notification</option>
                            <option value="3" >Weekly email notification</option>
                        </select></td>
                        
                    </tr>
                    </table>

                </fieldset>
                

                
                <fieldset class="fieldset">
                    <legend>Post a Poll</legend>
                    <div style="padding:3px">
                        <div><label for="cb_postpoll"><input type="checkbox" name="postpoll" value="yes" id="cb_postpoll" tabindex="1"  />Yes, post a poll with this thread</label></div>
                        <div><label for="polloptnum">Number of poll options: <input type="text" class="bginput" size="5" name="polloptions" value="4" id="polloptnum" tabindex="1" /></label> (Maximum: 10)</div>

                    </div>
                </fieldset>
                

                

                </div>
            </div>

            <div style="margin-top:6px">
                <input type="submit" class="button" name="sbutton" value="Submit New Thread" accesskey="s" tabindex="1" />
                <input type="submit" class="button" name="preview" value="Preview Post" accesskey="r" tabindex="1" />
            </div>

        </td>
    </tr>
</tbody>
</table>


</form>

Link to comment
Share on other sites

I found it, I found it! :x The problem was that as stringreplace replaces from left to right when it has to replace '&iconid=1' in this string for instance:

taglist=&iconid=0&iconid=1&iconid=13&iconid=12&iconid=11&iconid=10&iconid=9&iconid=8&iconid=7&iconid=6&iconid=5&iconid=4&iconid=3&iconid=2&iconid=14&s=

It will erase '&iconid=1' but also the substring '&iconid=1' of '&iconid=13' thus leaving the 3 hanging there. I think the solution would be to put the delimiter ( $sSep ) after $aRadio and check with @extended to see if you are trying to replace the last elem of the string.

$sAddData = StringReplace($sAddData,$aRadio[$m]&$sSep, "") ; delete
If @extended = 0 Then $sAddData = StringReplace($sAddData, $sSep & $aRadio[$m], ""); delete it in the case it is the last elem of the string

and then check if $sAddData has a '&' at the end. So the code would be this:

Func __WinHttpFinalizeCtrls($sSubmit, $sRadio, $sCheckBox, $sButton, ByRef $sAddData, $sSep = "")
    If $sSubmit Then ; If no submit is specified
        Local $aSubmit = StringSplit($sSubmit, "&", 2)
        For $m = 1 To UBound($aSubmit) - 1 ; skip the first (leave that one as default)
            $sAddData = StringReplace($sAddData, $aSubmit[$m] & $sSep, "") ; delete the rest
            If @extended = 0 Then $sAddData = StringReplace($sAddData, $sSep & $aSubmit[$m], "") ; delete it in the case it is the last elem of the string
        Next
    EndIf
    If $sRadio Then ; If no radio is specified
        Local $aRadio = StringSplit($sRadio, "&", 2)
        For $m = 0 To UBound($aRadio) - 1 ; for all "radio" controls
            $sAddData = StringReplace($sAddData, $aRadio[$m] & $sSep, "") ; delete
            If @extended = 0 Then $sAddData = StringReplace($sAddData, $sSep & $aRadio[$m], ""); delete it in the case it is the last elem of the string
        Next
    EndIf
    If $sCheckBox Then ; If no checkbox is specified
        Local $aCheckBox = StringSplit($sCheckBox, "&", 2)
        For $m = 0 To UBound($aCheckBox) - 1 ; for all left "checkbox" controls in $sCheckBox string (non-set)
            $sAddData = StringReplace($sAddData, $aCheckBox[$m] & $sSep, "") ; delete
            If @extended = 0 Then $sAddData = StringReplace($sAddData, $sSep & $aCheckBox[$m], ""); delete it in the case it is the last elem of the string
        Next
    EndIf
    If $sButton Then ; If no button is specified
        Local $aButton = StringSplit($sButton, "&", 2)
        For $m = 0 To UBound($aButton) - 1 ; for all left "button" controls in $sButton string (non-set)
            $sAddData = StringReplace($sAddData, $aButton[$m] & $sSep, "") ; delete
            If @extended = 0 Then $sAddData = StringReplace($sAddData, $sSep & $aButton[$m], ""); delete it in the case it is the last elem of the string
        Next
    EndIf
    If StringRight($sAddData, 1) = '&' Then StringTrimRight($sAddData, 1);just to be sure there's no '&' hanging at the end of the string
    If StringLeft($sAddData, 1) = '&' Then StringTrimLeft($sAddData, 1);just to be sure there's no '&' hanging at the beginning of the string also
EndFunc   ;==>__WinHttpFinalizeCtrls

And since I'm a little paranoid :P (or that I envision future problems if you prefer :shifty: ) I also checked if there's an '&' hanging at the beginning of the string.

...The other thing I thought would be to use string replace with $sSep before the 'name=value' and a count of 1 but that would function to remove for instance '&iconid=1' from '&iconid=1&iconid=13' but not from '&iconid=13&iconid=1' (it would leave 3&iconid=1 ) and I don't think we can expect radios or whatever to be alphanumerically ordered...

Edited by Mithrandir
Link to comment
Share on other sites

Now that I think a bit more about it, the problem in general persists whether the delimiter is before or after (for instance if you want to erase '&iconid1' from 'iconid1&iiconid1&' and you use the string 'iconid1&' to search for replace it would leave 'i', it's a symmetric problem to the other one), so stringreplace should be used with both, and since we know at least one replacement should be done, if no replacements ocurred, check whether it's an element of the first or the last element of the string. Here is the code:

Func __WinHttpFinalizeCtrls($sSubmit, $sRadio, $sCheckBox, $sButton, ByRef $sAddData, $sSep = "")
    If $sSubmit Then ; If no submit is specified
        Local $aSubmit = StringSplit($sSubmit, "&", 2)
        For $m = 1 To UBound($aSubmit) - 1 ; skip the first (leave that one as default)
            $sAddData = StringReplace($sAddData, $sSep & $aSubmit[$m] & $sSep, $sSep) ; delete it in the case it's somewhere in the middle of the string
            If @extended = 0 Then
                $sAddData = StringReplace($sAddData, $sSep & $aSubmit[$m], "") ; delete it in the case it is the last elem of the string
                If @extended = 0 Then $sAddData = StringReplace($sAddData, $aSubmit[$m] & $sSep, ""); delete it in the case it is the first elem of the string
            EndIf
        Next
    EndIf
    If $sRadio Then ; If no radio is specified
        Local $aRadio = StringSplit($sRadio, "&", 2)
        For $m = 0 To UBound($aRadio) - 1 ; for all "radio" controls
            $sAddData = StringReplace($sAddData, $sSep & $aRadio[$m] & $sSep, $sSep) ; delete it in the case it's somewhere in the middle of the string
            If @extended = 0 Then
                $sAddData = StringReplace($sAddData, $sSep & $aRadio[$m], ""); delete it in the case it is the last elem of the string
                If @extended = 0 Then $sAddData = StringReplace($sAddData, $aRadio[$m] & $sSep, ""); delete it in the case it is the first elem of the string
            EndIf
        Next
    EndIf
    If $sCheckBox Then ; If no checkbox is specified
        Local $aCheckBox = StringSplit($sCheckBox, "&", 2)
        For $m = 0 To UBound($aCheckBox) - 1 ; for all left "checkbox" controls in $sCheckBox string (non-set)
            $sAddData = StringReplace($sAddData, $sSep & $aCheckBox[$m] & $sSep, $sSep) ; delete it in the case it's somewhere in the middle of the string
            If @extended = 0 Then
                $sAddData = StringReplace($sAddData, $sSep & $aCheckBox[$m], ""); delete it in the case it is the last elem of the string
                If @extended = 0 Then $sAddData = StringReplace($sAddData, $aCheckBox[$m] & $sSep, ""); delete it in the case it is the first elem of the string
            EndIf
        Next
    EndIf
    If $sButton Then ; If no button is specified
        Local $aButton = StringSplit($sButton, "&", 2)
        For $m = 0 To UBound($aButton) - 1 ; for all left "button" controls in $sButton string (non-set)
            $sAddData = StringReplace($sAddData, $sSep & $aButton[$m] & $sSep, $sSep) ; delete it in the case it's somewhere in the middle of the string
            If @extended = 0 Then
                $sAddData = StringReplace($sAddData, $sSep & $aButton[$m], ""); delete it in the case it is the last elem of the string
                If @extended = 0 Then $sAddData = StringReplace($sAddData, $aButton[$m] & $sSep, ""); delete it in the case it is the first elem of the string
            EndIf
        Next
    EndIf
    If StringRight($sAddData, 1) = '&' Then StringTrimRight($sAddData, 1);just to be sure there's no '&' hanging at the end of the string
    If StringLeft($sAddData, 1) = '&' Then StringTrimLeft($sAddData, 1);just to be sure there's no '&' hanging at the beginning of the string also
EndFunc   ;==>__WinHttpFinalizeCtrls

PS: I have been looking at the __WinHttpFinalizeCtrls of multipart form data and I think it doesn't screw that part :P In other case :x , well you can always have one function for each kind of form.

Edited by Mithrandir
Link to comment
Share on other sites

Another problem, this time with this part of the code (but will happen the same in the stringreplace of .getelementbyid part):

$sAddData = StringRegExpReplace($sAddData, "(?i)\Q" & $aSplit[1] & "\E=.*?(&|\Z)", $aSplit[1] & "=" & $sPassedData & "$1")
$iNumRepl = @extended                       
If $iNumRepl > 1 Then ; remove duplicates
    $sAddData = StringRegExpReplace($sAddData, "(?i)\Q" & $aSplit[1] & "\E=.*?(&|\Z)", "", $iNumRepl - 1)
EndIf

Because I want to set a field whose name is 'passwr' but there's another one which is hidden whose name is 'hash_passwrd' and the regexp (as well as i think it will occur with stringreplace) is matching both fields as 'passwr' because 'passwr' is a substring of 'hash_passwr' and moreover since it's the last set it removes 'passwr' :shifty: I think the solution would be like the one of the post before, to use the '&' as delimiters, in this case I think it is enough to add one before $aSplit, I will make some tests but I don't completely understand the regexp you used there, I would like to know:

1)You used \Q in order to use the '&' in &$aSplit[1]& ? I think there '&' is used as the operator concatenation and not as part of the string. If not, what did you use \Q for?

2)When you use (&|\Z) are you telling the regexp to match a '&' before the end of the "pattern" string? I thought it was for matching before the end of the "test" string (StringRegExp ( "test", "pattern" [, flag ] [, offset ] ] ))

What's the use of the '|' in (&|\Z) ? I guess it matches '&' or 'nothing' before the end of the string but I don't understand

3)$1 is the value of what was captured in (&|\Z) (the backreference) ? ie if it matched a '&' it will concatenate a '&' ?

Thanks for your help!

PS: I tried a regexp with \A to match the first letter of 'passwrd' at the beginning of the "pattern" match so as to avoid matching 'passwr' as a substring of 'hash_passwr' and then I matched the rest of the string ('asswr') Here is the code:

Local $FirstChar = StringMid($aSplit[1],1,1)
Local $RestofString = StringMid($aSplit[1],2)
                        
$sAddData = StringRegExpReplace($sAddData, "(?i)\A"&$FirstChar&"\Q" & $RestofString & "\E=.*?(&|\Z)", $aSplit[1] & "=" & $sPassedData & "$1")
FileWriteLine(@ScriptDir&'/log2.txt',$sAddData)
$iNumRepl = @extended                       
If $iNumRepl > 1 Then ; remove duplicates
    $sAddData = StringRegExpReplace($sAddData, "(?i)\A"&$FirstChar&"\Q" & $RestofString & "\E=.*?(&|\Z)", "", $iNumRepl - 1)
EndIf

But this is what's being sent with that code: user=myusername&passwrd=True&cookielength=True&cookieneverexp=&hash_passwrd=TrueTrue

:nuke::x:P I don't understand why there are booleans in the string...Also with the original code cookielength was being sent as True...I'm pretty lost and I appreciate any help!

PS2: My bad, I was passing a submitbutton as Default and that caused all the mess with the booleans apparently. However, the problem with 'passwr' and 'hash_passwr' persists: It stills sends the later instead of 'passwr'

Edited by Mithrandir
Link to comment
Share on other sites

Well, it's not like I know everything :P

But I know about the code I used...

1. \Q makes pair with \E because $aSplit[1] could have characters that need escaping.

2. (&|\Z) means match either & or the end of the string.

3. Yes

Thanks for the reports. I know what to do.

:x You know almost everything. Concerning the problem of substrings being matched I now think that instead of using regexp you could use _StringExplode to store the fields in an array and then do the substitutions there and with _ArrayUnique remove the duplicates. I don't know if dealing with arrays instead of using regexp will add too much execution time though. Edited by Mithrandir
Link to comment
Share on other sites

:x You know almost everything. Concerning the problem of substrings being matched I now think that instead of using regexp you could use _StringExplode to store the fields in an array and then do the substitutions there and with _ArrayUnique remove the duplicates. I don't know if dealing with arrays instead of using regexp will add too much execution time though.

Surely would. I've made some changes. Could you try it now, I've run only the most basic tests.
Link to comment
Share on other sites

84 actually.

edit:

like that movie

'Big Brother is watching you' :x I read the book and watch the film :P

On topic: There's an error with the regexp in the Else of ; like .getElementsByName, it is removing an '&', here you have the code part with the consolewrite I used to debug:

ConsoleWrite('$aSplit[1] = '&$aSplit[1]&@CRLF&@CRLF&'adddata in .getelembyname loop before regexp replace: '&@CRLF&@CRLF&$sAddData&@CRLF&@CRLF)
$sAddData = StringRegExpReplace($sAddData, "(?i)\Q" & $aSplit[1] & "\E=.*?(&|\Z)", $aSplit[1] & "=" & $sPassedData & "$1")
$iNumRepl = @extended
If $iNumRepl > 1 Then ; remove duplicates
   $sAddData = StringRegExpReplace($sAddData, "(?i)(&|\A)\Q" & $aSplit[1] & "\E=.*?(&|\Z)", "", $iNumRepl - 1)
EndIf
ConsoleWrite('adddata in .getelembyname loop after regexp replace: '&@CRLF&@CRLF,$sAddData&@CRLF&@CRLF& _
                        '--------------------------------------------------------------------------------------------------------------------------------------------------------------'&@CRLF&@CRLF)

Here is the log of the errors, I highlighted in red where the '&' is removed:

$aSplit[1] = vb_login_username

adddata in .getelembyname loop before regexp replace:

s=bb3794fca900bcf9fc507beb1e10674bAAA&do=login&vb_login_password=&vb_login_md5password=&vb_login_md5password_utf=&vb_login_username=&cookieuser=1&vb_login_password=

adddata in .getelembyname loop after regexp replace:

s=bb3794fca900bcf9fc507beb1e10674bAAA&do=login&vb_login_password=&vb_login_md5password=&vb_login_md5password_utf=&vb_login_username=MYUSERNAME&cookieuser=1&vb_login_password=

--------------------------------------------------------------------------------------------------------------------------------------------------------

$aSplit[1] = vb_login_password

adddata in .getelembyname loop before regexp replace:

s=bb3794fca900bcf9fc507beb1e10674bAAA&do=login&vb_login_password=&vb_login_md5password=&vb_login_md5password_utf=&vb_login_username=MYUSERNAME&cookieuser=1&vb_login_password=

adddata in .getelembyname loop after regexp replace:

s=bb3794fca900bcf9fc507beb1e10674bAAA&do=loginvb_login_md5password=&vb_login_md5password_utf=&vb_login_username=MYUSERNAME&cookieuser=1&vb_login_password=MYPASSWORD

--------------------------------------------------------------------------------------------------------------------------------------------------------

$aSplit[1] = vb_login_md5password

adddata in .getelembyname loop before regexp replace:

s=bb3794fca900bcf9fc507beb1e10674bAAA&do=loginvb_login_md5password=&vb_login_md5password_utf=&vb_login_username=MYUSERNAME&cookieuser=1&vb_login_password=MYPASSWORD

adddata in .getelembyname loop after regexp replace:

s=bb3794fca900bcf9fc507beb1e10674bAAA&do=loginvb_login_md5password=e50a187a5967361541265aefccaaaaaaaAA&vb_login_md5password_utf=&vb_login_username=MYUSERNAME&cookieuser=1&vb_login_password=MYPASSWORD

--------------------------------------------------------------------------------------------------------------------------------------------------------

I saw you introduced $sGrSep = Chr(29) as separator but you didn't use it in this part of the code, maybe using it may help? As I said previously, I'd rather go with string split and don't complicate myself with regexp. I may code it and make a test comparing the two alternatives (regexp or stringsplit/_stringexplode) using TimerDiff or _Timer_Diff to research if the difference of time is considerable. The problem is that in other tests they showed contradictory results so I asked which is more precise.

Edited by Mithrandir
Link to comment
Share on other sites

Objective speed tests in AutoIt are very hard to do. It's very important to create the same "environmental" conditions for every tested sequence of code. It's kinda hard to explain without examples so I won't :x You'll figure it out your self.

All in all there shouldn't be doubt that lesser code is faster, particularly in this case.

I think I got that "&" correct now.

Link to comment
Share on other sites

Objective speed tests in AutoIt are very hard to do. It's very important to create the same "environmental" conditions for every tested sequence of code. It's kinda hard to explain without examples so I won't :x You'll figure it out your self.

All in all there shouldn't be doubt that lesser code is faster, particularly in this case.

I think I got that "&" correct now.

Yeah I agree but If it isn't considerable the difference I wouldn't complicate myself :P . I'm going to test rev 85 but I see that you didn't change this part of the Else ; like .getElementsByName from the Case "", "application/x-www-form-urlencoded" :

$sAddData = StringRegExpReplace($sAddData, "(?i)\Q" & $aSplit[1] & "\E=.*?(&|\Z)", $aSplit[1] & "=" & $sPassedData & "$1")

If you have one field whose name is 'myname' and I set its value to 'Mithrandir' and another whose name is 'name' and I set its value to 'trancexx' and $sAddData = 'name=&myname=' then wouldn't that regexp replace 'name' with 'name=trancexx' AND 'myname' with 'myname=trancexx' (which is wrong)?

so $sAddData would end up 'name=trancexx&myname=trancexx' and after replacing the duplicates from left to right it would end up 'name=trancexx&' (which after __WinHttpTrimBounds($sAddData, "&") would end up as name=trancexx so your code would not sent 'myname' field with its data but that's not what I expect it to do.

By the way, I experimented that problem (the 'passwr' and 'hash_passwr' problem)

I think the problem of regular expressions matching fields names and substrings of field names can't be avoided. I think a way would be to make some 'cheat' changing this part:

If $aInputIds[1][$i] Then ; if there is 'name' field then add it
                        $sAddData &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & "&"
                        If $aInputIds[3][$i] = "submit" Then $sSubmit &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "submit" string
                        If $aInputIds[3][$i] = "radio" Then $sRadio &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "radio" string
                        If $aInputIds[3][$i] = "checkbox" Then $sCheckBox &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "checkbox" string
                        If $aInputIds[3][$i] = "button" Then $sButton &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "button" string
                    EndIf

by:

If $aInputIds[1][$i] Then ; if there is 'name' field then add it
                        $sAddData &= $sGrSep&$aInputIds[1][$i]&$sGrSep & "=" & $aInputIds[2][$i] & "&"
                        If $aInputIds[3][$i] = "submit" Then $sSubmit &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "submit" string
                        If $aInputIds[3][$i] = "radio" Then $sRadio &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "radio" string
                        If $aInputIds[3][$i] = "checkbox" Then $sCheckBox &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "checkbox" string
                        If $aInputIds[3][$i] = "button" Then $sButton &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "button" string
                    EndIf

and then this:

$sAddData = StringRegExpReplace($sAddData, "(?i)\Q" & $aSplit[1] & "\E=.*?(&|\Z)", $aSplit[1] & "=" & $sPassedData & "$1")
                        $iNumRepl = @extended
                        If $iNumRepl > 1 Then ; remove duplicates
                            $sAddData = StringRegExpReplace($sAddData, "(?i)(?:&|\A)\Q" & $aSplit[1] & "\E=.*?(?:&|\Z)", "&", $iNumRepl - 1)
                        EndIf
                        __WinHttpTrimBounds($sAddData, "&")

by this:

$sAddData = StringRegExpReplace($sAddData, "(?i)\Q" $sGrSep& $aSplit[1]& $sGrSep & "\E=.*?(&|\Z)", $sGrSep& $aSplit[1] & $sGrSep "=" & $sPassedData & "$1")
                        $iNumRepl = @extended
                        If $iNumRepl > 1 Then ; remove duplicates
                            $sAddData = StringRegExpReplace($sAddData, "(?i)(?:&|\A)\Q" $sGrSep& $aSplit[1] & $sGrSep& "\E=.*?(?:&|\Z)", "&", $iNumRepl - 1)
                        EndIf
                        __WinHttpTrimBounds($sAddData, "&")

and before __WinHttpFinalizeCtrls at this part:

__WinHttpFinalizeCtrls($sSubmit, $sRadio, $sCheckBox, $sButton, $sAddData, $sGrSep, "&")
                If $sMethod = "GET" Then
                    $sAction &= "?" & $sAddData
                    $sAddData = "" ; not to send as addition to the request (this is GET)
                EndIf
                ExitLoop

remove the $sGrSep from it. The same would be needed for the multipart form as well as with getelementsbyid part of both. What do you think?

Edit: Now I see you used $sGrSep for other things, so use it other ascii char that is less than 30.

Edited by Mithrandir
Link to comment
Share on other sites

So, what are we gonna do when that function becomes perfect?

I felt a great disturbance in the force when submitted rev86.

...no, I'm lying.

Hehe, 'may the force be with you' (even though it would be strange to see Gandalf with a lightsaber). Well, if this function becomes 'perfect' we can search for other problems to solve :x What I did was to use a new variable $sBlSep = Chr(30) to 'surround' input ids and names so that there's no way a substring is matched (ie chr(30)namechr(30) is not a substring of chr(30)mynamechr(30) ) and then I -here I have to correct what I posted before- removed the $sBlSep from $sAddData after __WinHttpFinalizeCtrls.

I finished all my tests, and everything is ok.

Edited by Mithrandir
Link to comment
Share on other sites

New version of this UDF is available for those who would be interested. All the adjustments from the above for _WinHttpSimpleFormFill are included. That function is much better now. Special thanks to Mithrandir. His help is very much appreciated.

_WinHttpSimpleFormFill can also take form as variable with this version. In that case you should provide session handle as second parameter. Form variable goes in byref. On successful return it will be changed to connection handle of the created connection. "Action" for this type of forms must be full (not relative) address.

Link to comment
Share on other sites

  • 4 weeks later...

How to Use SetOption to set a Proxy?

by using this code,I receive ERROR_INVALID_PARAMETER, what's wrong with it?

#include <winhttp.au3>

$MyOpen=_WinHttpOpen()

    $tWINHTTP_PROXY_INFO = DllStructCreate("DWORD dwAccessType[2];wchar lpszProxy[18];wchar lpszProxyBypass[7]")
    DllStructSetData($tWINHTTP_PROXY_INFO,1,$WINHTTP_ACCESS_TYPE_NAMED_PROXY)
    DllStructSetData($tWINHTTP_PROXY_INFO,2,"119.40.187.49:8080")
    DllStructSetData($tWINHTTP_PROXY_INFO,3,"<local>")
    $pWINHTTP_PROXY_INFO=DllStructGetPtr($tWINHTTP_PROXY_INFO)
    If @error Then MsgBox(0,"1",@error)
    
    _WinHttpSetOption($MyOpen,$WINHTTP_OPTION_PROXY,$pWINHTTP_PROXY_INFO,DllStructGetSize($tWINHTTP_PROXY_INFO))
    If @error Then MsgBox(0,@error,_GetLastError_Winhttp())

_WinHttpCloseHandle($MyOpen) 

Func _GetLastError_Winhttp()
    Local $lastError = DllCall ( "kernel32.dll", "dword", "GetLastError" )
    Return $lastError[0]
EndFunc
Link to comment
Share on other sites

The DLLStruct is incorrect. This is a working version:

#include<WinHTTP.au3>
Global Const $tagWINHTTP_PROXY_INFO = "DWORD  dwAccessType;ptr lpszProxy;ptr lpszProxyBypass;"

Func _WinHttpProxyInfoCreate($dwAccessType, $sProxy, $sProxyBypass)
    Local $tWINHTTP_PROXY_INFO[2] = [DllStructCreate($tagWINHTTP_PROXY_INFO), DllStructCreate('wchar proxychars[' & StringLen($sProxy)+1 & ']; wchar proxybypasschars[' & StringLen($sProxyBypass)+1 & ']')]
    DllStructSetData($tWINHTTP_PROXY_INFO[0], "dwAccessType", $dwAccessType)
    If StringLen($sProxy) Then DllStructSetData($tWINHTTP_PROXY_INFO[0], "lpszProxy", DllStructGetPtr($tWINHTTP_PROXY_INFO[1], 'proxychars'))
    If StringLen($sProxyByPass) Then DllStructSetData($tWINHTTP_PROXY_INFO[0], "lpszProxyBypass", DllStructGetPtr($tWINHTTP_PROXY_INFO[1], 'proxybypasschars'))
    DllStructSetData($tWINHTTP_PROXY_INFO[1], "proxychars", $sProxy)
    DllStructSetData($tWINHTTP_PROXY_INFO[1], "proxybypasschars", $sProxyBypass)
    Return $tWINHTTP_PROXY_INFO
EndFunc

$hInternet = _WinHttpOpen()

$hConnect = _WinHttpConnect($hInternet, "api.hostip.info")
$standard = _WinHttpSimpleRequest($hConnect, "GET", "/get_html.php")
_WinHttpCloseHandle($hConnect)


$tProxyInfo = _WinHttpProxyInfoCreate($WINHTTP_ACCESS_TYPE_NAMED_PROXY, "122.146.153.125:80", "localhost")
_WinHttpSetOption($hInternet, $WINHTTP_OPTION_PROXY, $tProxyInfo[0])

$hConnect = _WinHttpConnect($hInternet, "api.hostip.info")
$mit_proxy = _WinHttpSimpleRequest($hConnect, "GET", "/get_html.php")
_WinHttpCloseHandle($hConnect)

MsgBox(0, 'Proxyinfo', "Before setting proxy" & @CRLF & $standard & @CRLF & @CRLF & "After setting proxy: " & @CRLF & $mit_proxy)

_WinHttpCloseHandle($hInternet)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

It works very well, Thank you!~~~

The DLLStruct is incorrect. This is a working version:

#include<WinHTTP.au3>
Global Const $tagWINHTTP_PROXY_INFO = "DWORD  dwAccessType;ptr lpszProxy;ptr lpszProxyBypass;"

Func _WinHttpProxyInfoCreate($dwAccessType, $sProxy, $sProxyBypass)
    Local $tWINHTTP_PROXY_INFO[2] = [DllStructCreate($tagWINHTTP_PROXY_INFO), DllStructCreate('wchar proxychars[' & StringLen($sProxy)+1 & ']; wchar proxybypasschars[' & StringLen($sProxyBypass)+1 & ']')]
    DllStructSetData($tWINHTTP_PROXY_INFO[0], "dwAccessType", $dwAccessType)
    If StringLen($sProxy) Then DllStructSetData($tWINHTTP_PROXY_INFO[0], "lpszProxy", DllStructGetPtr($tWINHTTP_PROXY_INFO[1], 'proxychars'))
    If StringLen($sProxyByPass) Then DllStructSetData($tWINHTTP_PROXY_INFO[0], "lpszProxyBypass", DllStructGetPtr($tWINHTTP_PROXY_INFO[1], 'proxybypasschars'))
    DllStructSetData($tWINHTTP_PROXY_INFO[1], "proxychars", $sProxy)
    DllStructSetData($tWINHTTP_PROXY_INFO[1], "proxybypasschars", $sProxyBypass)
    Return $tWINHTTP_PROXY_INFO
EndFunc

$hInternet = _WinHttpOpen()

$hConnect = _WinHttpConnect($hInternet, "api.hostip.info")
$standard = _WinHttpSimpleRequest($hConnect, "GET", "/get_html.php")
_WinHttpCloseHandle($hConnect)


$tProxyInfo = _WinHttpProxyInfoCreate($WINHTTP_ACCESS_TYPE_NAMED_PROXY, "122.146.153.125:80", "localhost")
_WinHttpSetOption($hInternet, $WINHTTP_OPTION_PROXY, $tProxyInfo[0])

$hConnect = _WinHttpConnect($hInternet, "api.hostip.info")
$mit_proxy = _WinHttpSimpleRequest($hConnect, "GET", "/get_html.php")
_WinHttpCloseHandle($hConnect)

MsgBox(0, 'Proxyinfo', "Before setting proxy" & @CRLF & $standard & @CRLF & @CRLF & "After setting proxy: " & @CRLF & $mit_proxy)

_WinHttpCloseHandle($hInternet)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...