Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. Ken your method works great if the string is alone by itself, but how would I go about checking the whole string to see if any of the "bad-script" filters are in the string and only replace the "bad-script" words.

     

    <?php
    $filter = array('onmouseout', 'onmouseover',
    	'onclick', 'ondblclick',
    	'onkeydown', 'onkeypress',
    	'onkeyup', 'onmousemove',
    	'onmouseup', 'onmousedown'
    	);
    $replace = "";
    $string = "I like using onmouseUp";
    echo preg_replace("/$filter/i",$replace,$string);
    ?>
    

  2. How can I use preg_replace to replace any of the "bad values," in my "bad values" array, and use case insensitivity.

     

    So: THIS = thIs.

     

    <?php
    $js_filter_array_bad = array(
    		'onmouseout', 'onmouseover',
    		'onclick', 'ondblclick',
    		'onkeydown', 'onkeypress',
    		'onkeyup', 'onmousemove',
    		'onmouseup', 'onmousedown'
    		);
    $replace = "";
    $string = "onMouseOut";
    echo preg_replace("|$js_filter_array_bad|iU",$replace,$string);
    ?>
    

  3. $sql = "SELECT * FROM `tbl` WHERE `this`='that'";
    $res = mysql_query($sql) or die(mysql_error());
    echo "<select name=\"name\">\n";
    
    while($row = mysql_fetch_assoc($res)){
    echo "<option value=\"$row[field1]\">$row[field2]</option>\n";
    }
    
    echo "</select>\n";
    

  4. Try:

     

    <?php
            $img_handle = ImageCreate (230, 20) or die ("Cannot Create image");
            $back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
            $txt_color = ImageColorAllocate ($img_handle, 233, 114, 191);
            ImageString ($img_handle, 31, 5, 5,  "My first Program with GD", $txt_color);
            header("Content-type: image/png");
            imagepng($img_handle);
    ?>
    

  5. That's javascript.

     

    <script language="Javascript">
    function addBold(){
    form.textarea.value += "[b]Your text here[/b]"
    }
    </script>
    <form name="form"><input type="button" value="Bold" onClick="addBold()"><br>
    <textarea name="textarea" cols="30" rows="14"></textarea><br><input type="submit">
    </form>
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.