1. PHP / Говнокод #7663

    +167

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    class xsspolice 
    { 
    function getip() { 
    $ipno = getenv("REMOTE_ADDR");  
    return $ipno; 
    } 
    function look_data($data) { 
    $ip=$this->getip(); 
    $data = strtolower($data); 
    $br=$_SERVER['HTTP_USER_AGENT']; 
    $datenow=date("y-m-d h:m:s"); 
    if(isset($_SESSION['user'])) { 
    $username=$_SESSION['user']; 
    }else { 
    $username="unknown"; 
    } 
    if (strstr($data,"<") OR strstr($data,">") OR strstr($data,"(") OR strstr($data,")") OR 
    strstr($data,"..") OR 
    strstr($data,"%") OR 
    strstr($data,"*") OR 
    strstr($data,"+") OR 
    strstr($data,"!") OR 
    strstr($data,"@")) { 
    $this->validate_befor(); 
    $dirtystuff = array("\"", "\\", "/", "*", "'", "=", "- 
    ", "#", ";", "<", ">", "+", "%","(",")","}","{"); 
    $data = str_replace($dirtystuff, "", $data); 
    $data = htmlspecialchars($data); 
    $data = strip_tags($data); 
    $sql="INSERT INTO `attack` (`attacker_id`, `attacker_ip`, `attacker_username`, `attacker_date`, `attacker_comname`, `attacker_browsername`) VALUES (NULL, '".$ip."', '".$username."', '".$datenow."', 'test', '".$br."')";
    mysql_query($sql)or die("ٍError message"); 
    return $data; 
    }else 
    { 
    return $data; 
    } 
    } 
    function validate_befor() { 
    $ip=$this->getip(); 
    $sql="SELECT COUNT(`attacker_id`) FROM `attack` WHERE `attacker_ip`='".$ip."'"; 
    $sql=mysql_query($sql); 
    $sql=mysql_fetch_row($sql); 
    if ($sql[0]>=3) { 
    header("location: police.htm"); 
    } 
    } 
    } 
    ?>

    По ходу у Попова учился...
    Доставляет всё(к die() уже прувык...), но строка 26-29 О_о
    Это мания ???
    [url]http://www.phpclasses.org/package/7110-PHP-Block-accesses-attempting-to-perform-XSS-attacks.html[/url]

    AlexanderC, 26 Августа 2011

    Комментарии (12)
  2. PHP / Говнокод #7657

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    <?php
    
    header('content-type: application/x-javascript; charset=windows-1251');
    
    function utf8win1251($s){
      $out=""; $c1=""; $byte2=false;
      for ($c=0;$c<strlen($s);$c++){
        $i=ord($s[$c]); if ($i<=127) $out.=$s[$c];
        if ($byte2) { $new_c2=($c1&3)*64+($i&63); $new_c1=($c1>>2)&5;
          $new_i=$new_c1*256+$new_c2;
          if ($new_i==1025) $out_i=168; else
          if ($new_i==1105) $out_i=184; else $out_i=$new_i-848;
          $out.=chr($out_i); $byte2=false; }
        if (($i>>5)==6) {$c1=$i;$byte2=true; } }
     return $out; }
    
     
    $src = file_get_contents("http://letopisi.ru/index.php/%D0%A8%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD:%D0%97%D0%BD%D0%B0%D0%B5%D1%82%D0%B5_%D0%BB%D0%B8_%D0%B2%D1%8B");
    
     $tmp = preg_replace('/.*<ul><li>(.*)<\/ul>.*<div class="printfooter">.*/s', '$1', $src);
     $tmp = trim(preg_replace('/href="/', 'href="http://letopisi.ru', $tmp));
     $matches = explode('</li>', $tmp);
    
     if (sizeof($matches) > 1) {
       $trans = Array("\x0D" => "", "\x0A" => " ");
       do { 
         $quote = trim($matches[rand(0, sizeof($matches)-2)]); 
       } while (empty($quote));
       $quote = str_replace('<li>', '', utf8win1251(strtr($quote, $trans)));
       $quote = preg_replace('/<div class="thumb.*<\/div>/', '', $quote);
       $quote = str_replace('"', '\"', $quote);
       print 'document.write("' . $quote . '");';
     }
    
     ?>

    Аа, блин, надо было сразу все кидать.
    Нужна возможность удалять свои коды в течение 10 минут.

    7ion, 25 Августа 2011

    Комментарии (7)
  3. PHP / Говнокод #7656

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    
    header('content-type: application/x-javascript; charset=windows-1251');
    
    // Здесь сам скрипт
    
     print 'document.write("' . $quote . '");';
    
     ?>

    А вот до такого еще додуматься надо.
    http://letopisi.ru/index.php/Знаете-ли-что%3F_скрипт

    7ion, 25 Августа 2011

    Комментарии (5)
  4. PHP / Говнокод #7655

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function utf8win1251($s){
      $out=""; $c1=""; $byte2=false;
      for ($c=0;$c<strlen($s);$c++){
        $i=ord($s[$c]); if ($i<=127) $out.=$s[$c];
        if ($byte2) { $new_c2=($c1&3)*64+($i&63); $new_c1=($c1>>2)&5;
          $new_i=$new_c1*256+$new_c2;
          if ($new_i==1025) $out_i=168; else
          if ($new_i==1105) $out_i=184; else $out_i=$new_i-848;
          $out.=chr($out_i); $byte2=false; }
        if (($i>>5)==6) {$c1=$i;$byte2=true; } }
     return $out; }

    Я ничо не понял, но это круто.

    http://letopisi.ru/index.php/Знаете-ли-что%3F_скрипт

    7ion, 25 Августа 2011

    Комментарии (6)
  5. PHP / Говнокод #7651

    +147

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    $prim = mysql_result($result,$i,"prim");
    $gruz = mysql_result($result,$i,"gruz");
    $kuzov = mysql_result($result,$i,"kuzov");
    $o_strana = mysql_result($result,$i,"o_strana");
    $o_gorod = mysql_result($result,$i,"o_gorod");
    $k_strana = mysql_result($result,$i,"k_strana");
    $k_gorod = mysql_result($result,$i,"k_gorod");
    $stavka = mysql_result($result,$i,"stavka");
    $data = mysql_result($result,$i,"data");
    $m3 = mysql_result($result,$i,"m3");
    $ves = mysql_result($result,$i,"ves");
    $valuta = mysql_result($result,$i,"valuta");
    $firstname = mysql_result($result,$i,"firstname");
    $lastname = mysql_result($result,$i,"lastname");
    $middlename = mysql_result($result,$i,"middlename");
    $phone = mysql_result($result,$i,"phone");
    $cb_icq = mysql_result($result,$i,"cb_icq");
    $cb_skype = mysql_result($result,$i,"cb_skype");
    $cb_company = mysql_result($result,$i,"cb_company");
    $cb_org = mysql_result($result,$i,"cb_org");
    $cb_profession = mysql_result($result,$i,"cb_profession");

    пробуем сервер баз данных на выносливость...

    Sulik78, 25 Августа 2011

    Комментарии (5)
  6. PHP / Говнокод #7644

    +174

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if ($_SESSION['free'] <= 0) {
         if ($_SESSION['free'] > 0) {
              $_SESSION['free'] --;
         }
    }

    Нашел в один из онлине казино.

    webenter, 25 Августа 2011

    Комментарии (17)
  7. PHP / Говнокод #7635

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if($_SESSION['use_test_xml'] && false) {
    		if(!responseTestXml('chekin_'.$_GET['userid'].'_'.( ($_GET['placeid']) ? $_GET['placeid'] : $_GET['eventid'] ).'.xml')) {
    			responseTestXml('err.xml',array('message'=>'Unxpected situation. Please use these users: 12345,54321 and places|events: 1-9.'));
    		}
    	} else {
    ...

    плеать...

    realsugar, 24 Августа 2011

    Комментарии (27)
  8. PHP / Говнокод #7634

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    /**
     * @param array $config
     * @return App_Ldap
     */
    private final function __construct(array $config)
    {
    
        if (!empty($config['host'])) {
            $this->_host = $config['host'];
    
            $dnTemp = explode('.', $this->_host);
            $dnTemp = array_map(function($value)
                {
                    return 'dc=' . $value;
                }, $dnTemp);
    
            $this->_dn = implode(',', $dnTemp);
        } else {
            throw new Exception('I need LDAP host');
        }
    
        if (!empty($config['user'])) {
            $this->_user = $config['user'];
        } else {
            throw new Exception('I need LDAP login');
        }
    
        if (!empty($config['pass'])) {
            $this->_pass = $config['pass'];
        } else {
            throw new Exception('I need LDAP pass');
        }
    
        return $this;
    }

    ykhrustalev, 24 Августа 2011

    Комментарии (10)
  9. PHP / Говнокод #7633

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    function otherString($str,$style)
    {
    	$str=trim($str);
    	switch($style)
    	{
    		case 1: $str=strip_tags($str); $str=str_replace("\n",'<br />',$str); break;
    		case 2:  break;
    		case 3: $str=strip_tags($str); $str=str_replace("\n",'',$str); $str=str_replace('<br />',"\n",$str); break;
    		case 4: $str=ereg_replace('(mailto:|mailto|http://|http:/|http:|http|ftp://|ftp:/|ftp:|ftp)','',$str);break;
    		case 5: $str=stripslashes($str); break;
    		case 6: $str=stripslashes($str); $str=strip_tags($str); break;
    		case 7: $str=strip_tags($str); break;
    	}
    	return $str;
    }

    web-based cms

    odmin, 24 Августа 2011

    Комментарии (6)
  10. PHP / Говнокод #7630

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    public function title_url_formatted($len = 70)
    {
    	return Core_String::title_to_url(Core_String::unicode_truncate($this->title, 70));
    }

    писал не я, если что)

    POPSuL, 24 Августа 2011

    Комментарии (5)