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

    +171

    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
    // ИЗМЕНЕНИЕ ПАРОЛЯ
    
    if (isset($_POST['password'])) {
      $password = $_POST['password'];
      if ($password == '') exit("Вы не ввели пароль");
      if (strlen($password) < 3) 
        exit ("Пароль должен состоять не менее чем из 3 символов.");
      $password = md5($password);
      $password = $password."b3p6f";
      $result2 = mysql_query("UPDATE users SET password='$password' WHERE email='$old_email'");
      if ($result2 == 'TRUE')
        echo "<html>
                <head>
                  <meta http-equiv='Refresh' content='5; URL=page.php?id=".$_SESSION['id']."'>
                </head>
              <body>
                Ваш пароль изменен! Вы будете перемещены через 5 сек. Если не хотите ждать, то
                <a href='page.php?id=".$_SESSION['id']."'>
                  нажмите сюда.
                </a>
              </body>
            </html>";
    }

    Код из серии "Шоколадные шедевры"

    SunnyMagadan, 29 Ноября 2011

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

    +176

    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
    $query = "
    			SELECT `ord`.*,`cus`.`existing_phone_number`,`cus`.`nova_jednotka`,
    				`cus`.`order_phone`,`cus`.`custom_delivery_date`, `cus`.`delivery_address`,
    				`cus`.`invoice_address`, `cus`.`invoice_street`, `cus`.`invoice_street_number`,
    				`cus`.`invoice_city`, `cus`.`invoice_zip`
    			FROM ".(!empty($_GET["copy_view"]) && $_GET["copy_view"] == 1 ? "`orders`" : "`".$this->table."`")." AS `ord`,
    				`products`, `navigace`, `customers` AS `cus`
    			WHERE `ord`.`order_id` = ".$order_id."
    				AND `ord`.`id_produktu_db` = `products`.`id`
    				AND `products`.`navigace_polozka_id` = `navigace`.`id`
    				AND `cus`.`id` = `ord`.`customers_id`
    			union all
    			select
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, 
                                    '', tp.description, tp.product_id, tp.activation_price, tp.activation_price_EUR,
    				0, tor.pocet_kusu, tp.name, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null, 
                                    null, null, null, null, null, null, null, null, null, null, null, null, null
    			from tarifs_prop tp
    			inner join tarifs_orders tor on tp.id = tor.tarif_prop_id
    			where tor.order_id = ".$order_id."
    			union all
    			select
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, '', b.description, b.product_id, b.activation_price, b.activation_price_EUR,
    				0, tor.pocet_kusu, b.name, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null,
    				null, null, null, null, null, null, null, null, null, null, 
                                    null, null, null, null, null, null, null, 
                                    null, null, null, null, null, null
    			from balicky b
    			inner join tarifs_orders tor on b.id = tor.tarif_balicek_id
    			where tor.order_id = ".$order_id."
    			ORDER BY `user_id` desc";

    а филе нам кабанам, надо продукты из разных таблиц объединить в одну, ну и фто што таблицы разного размера. Зато когда добавляешь новый столбец в таблицу, нужно вручную считать сколько раз нужно добавить null :D

    Lameaux, 29 Ноября 2011

    Комментарии (12)
  3. C++ / Говнокод #8666

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    AnsiString DateArray = "";
    int DaysBetween = 0;
    DaysBetween = DateTimePicker2->Date - DateTimePicker1->Date;
    for (int i = 0; i <= DaysBetween; i++ )
    {
     if (i != 0)
     DateArray = DateArray + " OR ";
     DateArray =  DateArray + " date_made = '"+DateToStr(DateTimePicker1->Date + i)+"'";
    }

    Очевидно, подготавливаем запрос для отбора по диапазону дат :)

    labutinpa, 29 Ноября 2011

    Комментарии (7)
  4. SQL / Говнокод #8665

    −126

    1. 1
    2. 2
    3. 3
    AND (type = 2 OR type = 5 AND (type <> 3 OR type <> 20))
    
    Очередной перл предшественника :)

    labutinpa, 29 Ноября 2011

    Комментарии (30)
  5. Pascal / Говнокод #8664

    +102

    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
    function naq(a:integer;n:integer;m:integer):string;
    var astr:string;
    begin
      astr:=inttostr(a);
         case m of
           1: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*1)+'*p^'+inttostr(n+1);
           2: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*2)+'*p^'+inttostr(n+1)+'+'+inttostr(a*1)+'*p^'+inttostr(n+2);
           3: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*3)+'*p^'+inttostr(n+1)+'+'+inttostr(a*3)+'*p^'+inttostr(n+2)+'-'+inttostr(a*1)+'*p^'+inttostr(n+3);
           4: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*4)+'*p^'+inttostr(n+1)+'+'+inttostr(a*6)+'*p^'+inttostr(n+2)+'-'+inttostr(a*4)+'*p^'+inttostr(n+3)+'+'+inttostr(a*1)+'*p^'+inttostr(n+4);
           5: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*5)+'*p^'+inttostr(n+1)+'+'+inttostr(a*10)+'*p^'+inttostr(n+2)+'-'+inttostr(a*10)+'*p^'+inttostr(n+3)+'+'+inttostr(a*5)+'*p^'+inttostr(n+4)+'-'+inttostr(a*1)+'*p^'+inttostr(n+5);
           6: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*6)+'*p^'+inttostr(n+1)+'+'+inttostr(a*15)+'*p^'+inttostr(n+2)+'-'+inttostr(a*20)+'*p^'+inttostr(n+3)+'+'+inttostr(a*15)+'*p^'+inttostr(n+4)+'-'+inttostr(a*6)+'*p^'+inttostr(n+5)+'+'+inttostr(a*1)+'*p^'+inttostr(n+6);
           7: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*7)+'*p^'+inttostr(n+1)+'+'+inttostr(a*21)+'*p^'+inttostr(n+2)+'-'+inttostr(a*35)+'*p^'+inttostr(n+3)+'+'+inttostr(a*35)+'*p^'+inttostr(n+4)+'-'+inttostr(a*21)+'*p^'+inttostr(n+5)+'+'+inttostr(a*7)+'*p^'+inttostr(n+6)+'-'+inttostr(a*1)+'*p^'+inttostr(n+7);
           8: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*8)+'*p^'+inttostr(n+1)+'+'+inttostr(a*28)+'*p^'+inttostr(n+2)+'-'+inttostr(a*56)+'*p^'+inttostr(n+3)+'+'+inttostr(a*70)+'*p^'+inttostr(n+4)+'-'+inttostr(a*56)+'*p^'+inttostr(n+5)+'+'+inttostr(a*28)+'*p^'+inttostr(n+6)+'-'+inttostr(a*8)+'*p^'+inttostr(n+7)+'+'+inttostr(a*1)+'*p^'+inttostr(n+8);
           9: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*9)+'*p^'+inttostr(n+1)+'+'+inttostr(a*36)+'*p^'+inttostr(n+2)+'-'+inttostr(a*84)+'*p^'+inttostr(n+3)+'+'+inttostr(a*126)+'*p^'+inttostr(n+4)+'-'+inttostr(a*126)+'*p^'+inttostr(n+5)+'+'+inttostr(a*84)+'*p^'+inttostr(n+6)+'-'+inttostr(a*36)+'*p^'+inttostr(n+7)+'+'+inttostr(a*9)+'*p^'+inttostr(n+8)+'+'+inttostr(a*1)+'*p^'+inttostr(n+9);
         end;
      end;

    Лень было искать алгоритм раскрытия (1-q)^n

    rob1nzon, 28 Ноября 2011

    Комментарии (178)
  6. JavaScript / Говнокод #8663

    +148

    1. 1
    eval(' ~ function ( __ , ___ ) {  _  =  __ ( ___ ( "__",  "return __ ") ({}) ) } (eval, Function) ,  _[("_")] = _ ');

    не могу понять как работает =(

    __proto__, 28 Ноября 2011

    Комментарии (2)
  7. Куча / Говнокод #8662

    +163

    1. 1
    2. 2
    3. 3
    Обратите внимание:
    http://govnokod.ru/user/4788
    http://govnokod.ru/user/4789

    TarasGovno, 28 Ноября 2011

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

    +171

    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
    // Записываем просмотр профайла
    MySQL::QueryInsert(
    	'profile_views', 
    	array(
    		'profile_id' => (int)$user['id'], 
    		'visitor' => (int)User::$current['id'], 
    		'date' => (int)$cur_time, 
    		'hidden' => (int)User::$current['hidden']
    		)
    	);
    // Смотрим последнюю запись в просмотрах
    $prev_visit = MySQL::FetchAll(
    	MySQL::Query(
    		'SELECT `visitor`,`date` 
    		   FROM profile_views 
    		  WHERE profile_id='.(int)$user['id'].' AND `date`<'.(int)$cur_time.
              ' AND `hidden`='.(int)User::$current['hidden'].' 
           ORDER BY `date` DESC 
              LIMIT 1'
            )
        );
    // если юзер сам посмотрел свой профиль - удаляем только что вставленную запись
    if ($prev_visit[0]['visitor'] == User::$current['id']) {
        MySQL::Query(
    	    'DELETE FROM profile_views 
    	      WHERE profile_id='.(int)$user['id'].' 
    	        AND `date`='.(int)$prev_visit[0]['date'].
              ' AND `hidden`='.(int)User::$current['hidden'].' 
                AND visitor='.(int)User::$current['id']
        );
    };

    Комментарии мои. Сука, я потихоньку начинаю ненавидеть прибалтийских программеров

    Sc0rp10, 28 Ноября 2011

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

    +147

    1. 1
    $field_value = trim( $field_value, ' \n"' );

    odmin, 28 Ноября 2011

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    @jfredys 23-Mar-2011 01:07 
     I was looking for trimming all the elements in an array, I found this as the simplest solution: 
    
    <?php 
     array_walk($ids, create_function('&$val', '$val = trim($val);')); 
    ?>

    array_map? не, не слышал.

    DrFreez, 27 Ноября 2011

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