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

    +136.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (mysql_num_rows($result) > 0) {
    $row=mysql_fetch_array($result);
    $strings = ($row[1]) + 1;
    $words = $row[2] + (substr_count(trim($parse[count($parse)-6]), ' ') + 1);
    $letters = $row[3]+strlen($parse[count($parse)-6]);
    $result = mysql_query("UPDATE `stat` SET `strings`='".$strings."', `words`='".$words."', `letters`='".$letters."', `last_say`='".$parse[count($parse)-6]."', `last_say_date`='".date('Y-m-d G:i:s')."' WHERE `id`=".$row['id']) or die(''.mysql_error($link));
    } else $result=mysql_query("INSERT into `stat` (`host`, `strings`, `words`, `letters`) VALUES ('".$parse[count($parse)-2]."', '1', '".(substr_count(trim($parse[count($parse)-6]), ' ') + 1)."', '".strlen($parse[count($parse)-6])."')") or die(''.mysql_error($link));

    Скрипт обновления статистики

    guest, 24 Июня 2009

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

    +54.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <form name='<? echo $tb_names[$i]; ?>' method='post' ENCTYPE='multipart/form-data' action="admin.php?task=del">
        <input type=hidden  name=login  value='<? echo @$_POST['login']; ?>'>
        <input type=hidden  name=password  value='<? echo @$_POST['password']; ?>'>
        <input name='tname' type=hidden value='<? echo $tb_names[$i]; ?>'>
        <p><input type='submit' value='Удалить прайс'>
    </form>

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

    guest, 24 Июня 2009

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

    +140.9

    1. 1
    2. 2
    3. 3
    $sqlt="select * from logos where is_delete='0'";
    $rest=$db->select_data($sqlt);
    $total=count($rest);

    Подсчет подходящих записей в таблице.
    Источник тот же, что и у говнокода 1244.
    В $rest возвращается ассоциативный массив.

    guest, 24 Июня 2009

    Комментарии (0)
  4. JavaScript / Говнокод #1244

    +150.7

    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
    function login() {
    
    
    // Optional: Show a waiting message in the layer with ID ajax_response
    
    	var img_load="<img src=images/wait.gif alt=\"error\" width=\"100\" height=\"100\" /> ";
    	document.getElementById('login_response').innerHTML = img_load;
    	// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
    	var email = encodeURI(document.getElementById('emailLogin').value);
    	var psw = encodeURI(document.getElementById('pswLogin').value);
    	//var rem = encodeURI(document.getElementById('chkrem').value);
    	var rem = document.getElementById('chkrem').checked;
    if(document.getElementById('chkrem').checked==true)
    	{
           rem=1;
    	}
    	else
    if(document.getElementById('chkrem').checked==false)
    	{
              rem=0;
    	}
    	else
    	{
    		rem=0;
    	}
    
    
    		// Set te random number to add to URL request
    		nocache = Math.random();
    		// Pass the login variables like URL variable
    		var act;
    
    		act='login.php?email='+email+'&psw='+psw+'&remchk='+rem+'&nocache='+nocache;
    		//alert(act);
    		http.open('get', 'login.php?email='+email+'&psw='+psw+'&remchk='+rem+'&nocache='+nocache);
    		http.onreadystatechange = loginReply;
    		http.send(null);
    }

    Взято с одного непонятно кем разработанного зарубежного сайта, который (судя по забагованности и унылости) всё никак не может добраться до релиза.

    Код интересен двумя пассажами: строки 13-25 и 33-35

    guest, 24 Июня 2009

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

    +140.3

    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
    if (isset($aCart['color_caption'])) {
        if (!isset($aCart['color_name']) && isset($aCart['color_caption'])) {
            $aInsert['color_name']    = $aCart[$i]['color_caption'];
            $aInsert['color_caption'] = $aCart[$i]['color_caption'];
        }
        elseif (isset($aCart['color_name']) && !isset($aCart['color_caption'])) {
            $aInsert['color_name']    = $aCart[$i]['color_name'];
            $aInsert['color_caption'] = $aCart[$i]['color_name'];
        }
        elseif (!isset($aCart['color_name']) && !isset($aCart['color_caption'])) {
            $aInsert['color_name']    = 'N/A';
            $aInsert['color_caption'] = 'N/A';
        }
        else {
            $aInsert['color_name']    = $aCart['color_caption'];
            $aInsert['color_caption'] = $aCart['color_name'];
        }
    }

    Чем была забита моя голова не известно. Как я такую логику придумал?!

    guest, 24 Июня 2009

    Комментарии (0)
  6. C++ / Говнокод #1242

    +19.1

    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
    int GetControlImplementationsCount()
    {
    	//return 17;
    	return 18;
    }
    
    CControlImplementation* GetControlImplementation(int index)
    {
    	switch (index)
    	{
    	case 0: return new CButtonImp();
    	case 1: return new CFormImp();
    	case 2: return new CLabelImp();
    	case 3: return new CHorizontalAlignment();
    	case 4: return new CVerticalAlignment();
    	case 5: return new CMouseButton();
    	case 6: return new CActionEvent();
    	case 7: return new CMouseEvent();
    	case 8: return new CWindowEvent();
    	case 9: return new CCheckBoxImp();
    	case 10: return new CComboBoxImp();
    	case 11: return new CListBoxImp();
    	case 12: return new CRadioButtonImp();
    	case 13: return new CTextBoxImp();
    	case 14: return new CItemEvent();
    	case 15: return new CTextEvent();
    	case 16: return new CButtonGroupImp();
    	case 17: return new DialogImpl();
    	}
    
    	return NULL;
    }

    вот так кладут в ДВО РАН.

    guest, 23 Июня 2009

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

    −861.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    select
    	....
    	if(n.Pinned=1,concat(n.Name,' &lt;img src=/images/icons/897634.gif>'),n.Name) as Name
    from
    	news n
    	left outer join ....
    	.....
    where
    	....

    Как вам html-верстка в sql запросах?

    guest, 23 Июня 2009

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

    +140.1

    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
    function parce($string)
    
    
    
    {//function open
    $breaktags=array ("<"," ","=","","т");
       
       for ($pos=0;$pos<strlen($string);$pos++)
       {//for text
         
         if (substr($string,$pos,1)=="{" and substr($string,$pos+1,1)=="%")
    		{// if open symbols finded
    		   $tagopened=1;
    		   while($tagopened==1){//while opened
    			   for($inpos=$pos+2;$inpos<10000;$inpos++){// =)
    				   if ( (substr($string,$inpos,1)=="%" and substr($string,$inpos+1,1)=="}") or in_array(substr($string,$inpos,1),$breaktags)) {break 2;$tagopened=0;}//br
    				   $intag=$intag.substr($string,$inpos,1);
    		   }//for inpos
    		}//while opened closing
    		$intag=explode("->",$intag,2);
    		echo("$intag[0] with $intag[1] action!<br>");
    		unset($intag);
    				} else {//if symbols finded
    					$symbol=substr($string,$pos,1);
    					echo("$symbol");
    				}
    				
       }//for all text closing
       
    }//function end;

    guest, 23 Июня 2009

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

    +147

    1. 1
    2. 2
    3. 3
    <?php
       if ($_SESSION['gde'] != 'tut') {exit();}
    ?>

    Ты не тут? Выйди!

    guest, 22 Июня 2009

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

    +92

    1. 1
    2. 2
    3. 3
    header('Location: '.$_SERVER['REQUEST_URI']);
    exit();
    die();

    на всякий случай :)

    guest, 21 Июня 2009

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