صفحة 2 من 2 الأولىالأولى 12
النتائج 16 إلى 24 من 24

الموضوع: كيفية إستعمال دالة ()htmlentities + استفسار

  1. #16
    عضو نشيط
    تاريخ التسجيل
    May 2010
    المشاركات
    76


    السلام عليكم

    هناك داله ستوفر عليك الكثير وهى

    strip_tags

    هذه الداله تقوم بالاتاحه لعرض تاجات معينه والباقى

    يتم تجاهله

    http://www.php.net/manual/en/function.strip-tags.php

    وهذا لينك لطريقة استخدامها

    يمكن عمل مثل هذه الوظيفه عن طريق التعابير القياسيه

    ولكن هذه الداله اعتقد انها جيده






    التعديل الأخير تم بواسطة developspot ; 27-06-2010 الساعة 06:58 PM
    __________________
    Mahmoud Abd El-Hamed
    Web Developer
    Mobile: +2 0192565454
    E-mail: admin(at)developspot.com
    Site: ( رابط ) http://developspot.com

  2. #17
    Banned
    تاريخ التسجيل
    Apr 2010
    المشاركات
    105

    Exclamation



    هذا الحل ليس جيد بالنسبة لي.

    و لكن هل هناك إمكانية لتقوية الكود الذي نجح معي
    و تعويض هذه الكلمات برموز حتى لا تتفعل و تظهر طبيعية


    كود:
     
    'cookie','JAVA','java','location','document','window','onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload','javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'script', 'embed', 'object', 'iframe','frame', 'frameset', 'ilayer', 'bgsound','base', 'union', 'UNION', 'select', 'SELECT', 'mysql', 'MYSQL', 'shell', 'SHELL', 'Refresh', 'content'







  3. #18
    عضو نشيط
    تاريخ التسجيل
    May 2010
    المشاركات
    76


    كنت اود الاضافه فقط

    كنت اامل فى ان تفيدك فيما تريد

    اذا اردت استبدال هذه الكلمات بغيرها يمكن ذلك عن طريق التعابير القياسيه

    بدالة

    preg_replace

    وهذا اللينك يشرح استخدامها

    http://www.php.net/manual/en/function.preg-replace.php

    والباتيرن المستخدم هو

    preg_replace('/[(cookie)(java)(document)(window)]/i','',$variable);


    وهكذا يمكن اضافة كلمات اخرى عن طريق

    كود PHP:
    preg_replace('/[(cookie)(java)(document)(window)(onabort)]/i','',$variable); 

    ولكن بما ان الكلمات سابته يفضل استخدام دالة

    str_replace

    وهذا رابط الشرح

    http://www.php.net/manual/en/function.str-replace.php

    ويفضل وضعهم جميعا فى مصفوفه

    مثال
    كود PHP:
    $words = array("cookie""java""document""window");
    $safe str_replace($words"""your html text"); 
    ارجو الافاده





    __________________
    Mahmoud Abd El-Hamed
    Web Developer
    Mobile: +2 0192565454
    E-mail: admin(at)developspot.com
    Site: ( رابط ) http://developspot.com

  4. #19
    Banned
    تاريخ التسجيل
    Apr 2010
    المشاركات
    105

    Unhappy



    أنا استخدمت هذه

    $tag = array('<script','<meta','<base','/</','/>/');
    $replace = array('&lt;script','&lt;meta','&lt;base','&lt;','&gt;');
    $message = str_ireplace($tag,$replace,$message);

    و الذي ينقصني الآن هو إضافة كلمات أخرى لمنع ثغرة xss






  5. #20
    عضو شرف
    تاريخ التسجيل
    May 2007
    المشاركات
    1,647


    ماذا عن htmlspecialchars() ؟





    __________________
    # اتبعني على Twitter
    # عِرفان ساهم ببناء المحتوى العربي العلمي على الإنترنت!

  6. #21
    عضو نشيط
    تاريخ التسجيل
    May 2010
    المشاركات
    76


    كود PHP:
    <?php

    function CleanXSS($str){
        
    // One of the easiest way to do XSS is to use one of the on* attributes, like onclick or onload.
        // With this you can easily execute a script, without the user even having to do something (with onload, etc)
        // or just having to click or hover over something. We just remove them all with
        
    $str preg_replace('#(<[^>]+[\s\r\n\"\'])(on|xmlns)[^>]*>#iU',"$1>",$str);
        
        
    // As you certainly know, can you use javascript: and vbscript: as protocol handlers instead of http:// and others.
        // Something like <a href="javascript:alert('foobar')">lll</a> executes just nicely if a user clicks on it.
        // We of course remove that as well. IE as also the strange behaviour that something like "java script :" is also valid,
        // so we have to check for a whitespace between every character.
        
    $str preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU','$1=$2nojavascript...',$str);
        
    $str preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU','$1=$2novbscript...',$str);
        
        
    // We removed all namespace declarations above, here we remove all elements, which have a prefix, they are not needed in HTML..
        
    $str preg_replace('#</*\w+:\w[^>]*>#i','',$str);
        
        
    // There are quite some elements in HTML, which you definitively don't want in something like user comments.
        // The reason for the while loop is, that stuff like
        // <sc<script>ript>alert('hello')
        // We remove them with:
        
    do {
            
    $oldstr $str;
            
    $str preg_replace('#</*(\?xml|applet|meta|xml|blink|link|style|script|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i',"",$str);
        } while (
    $oldstr != $str);
        
        return 
    $str;


    ?>






    __________________
    Mahmoud Abd El-Hamed
    Web Developer
    Mobile: +2 0192565454
    E-mail: admin(at)developspot.com
    Site: ( رابط ) http://developspot.com

  7. #22
    عضو نشيط
    تاريخ التسجيل
    May 2010
    المشاركات
    76


    يمكن ايضا استخدام

    DOMDocument





    __________________
    Mahmoud Abd El-Hamed
    Web Developer
    Mobile: +2 0192565454
    E-mail: admin(at)developspot.com
    Site: ( رابط ) http://developspot.com

  8. #23
    Banned
    تاريخ التسجيل
    Apr 2010
    المشاركات
    105


    عند استعمال الدالة التي وضعت لي هل ستظهر الأكواد طبيعية أم سيتم تعويضها برموز






  9. #24
    Banned
    تاريخ التسجيل
    Apr 2010
    المشاركات
    105


    وجدت هذه الدالة و لا أعرف هل هي مفيدة


    كود PHP:
    function check_text_replace($text){
     
    $search = array (
       
    '@<script[^>]*?>.*?</script>@si'// Supprime le javascript
       
    '@<[\/\!]*?[^<>]*?>@si',          // Supprime les balises HTML
       
    '@([\r\n])[\s]+@',                // Supprime les espaces
       
    '@&(quot|#34);@i',                // Remplace les entités HTML
       
    );
     
    $replace = array (
       
    '',
       
    '',
       
    '\1',
       
    '"'
       
    );
     
    $text preg_replace($search$replace$text);
    return(
    $text);












ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض