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

    +163

    1. 1
    <input type="submit" value="<?=lang('Send','Отправить')?>" />

    Говнокод или нет?

    Morsik, 31 Мая 2010

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

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function __get($propertyName) {
    ....
          
          if (!isset($propertyName[$this->propertyTable])) {
                var_dump($this->propertyTable);
                throw new Exception("Wrong property name \"$propertyName\"");
          }
         
    .....
        }

    Глубоко в дебрях...

    MaksSlesarenko, 31 Мая 2010

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

    +165

    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
    function is_bot() {
    	if (defined("IS_BOT")) {
    		return 1;
    	}
    	elseif (defined("IS_NOT_BOT")) {
    		return 0;
    	}
    	elseif (!defined("IS_BOT") and !defined("IS_NOT_BOT")) {
    		if (file_exists(INCLUDE_PATH."includes/core/is_bot.php")) {
    			require_once(INCLUDE_PATH."includes/core/is_bot.php");
    			if (function_exists('is_bot_real')) {
    				return is_bot_real();
    			}
    			else {
    				define("IS_NOT_BOT", true);
    				return 0;
    			}
    		}
    		else {
    			define("IS_NOT_BOT", true);
    			return 0;
    		}
    	}
    	else {
    		define("IS_NOT_BOT", true);
    		return 0;
    	}
    }

    PHPNuke, mainfile.php

    telnet, 30 Мая 2010

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

    +156

    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
    $div = false;
    while (true) {
        if ($div = !$div) {
            // тут действие если четная итерация цикла
        } else {
            // тут если нечетная
        }
    }
    
    ну, или так
    
    for ($i=0, $div = true; $i<$max; $i++, $div = !$div){
        if ($div) {
            // тут действие если четная итерация цикла
        } else {
            // тут если нечетная
        }
    }

    человек один говорит, что такая проверка на четность/нечетность - говно.
    говно ли?

    shmaltorhbooks, 30 Мая 2010

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

    +109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(!mysql_select_db($db_name,$data)){
         print "<BR>";
         echo mysql_error();
         die();
        }

    Нашел в одном из движков онлайн игры

    Vasiliy, 30 Мая 2010

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

    +152

    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
    $data = curl_init('http://'.$site.'/index/sub/'); 
    curl_setopt($data, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($data, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($data, CURLOPT_POST, 1); 
    curl_setopt($data, CURLOPT_POSTFIELDS, $post); 
    curl_setopt($data, CURLOPT_HTTPHEADER, $headers); 
    curl_setopt($data, CURLOPT_COOKIEJAR, $cookie); 
    curl_setopt($data, CURLOPT_CONNECTTIMEOUT,$timeout); 
    curl_setopt($data, CURLOPT_TIMEOUT,$timeout); 
    //curl_setopt($data, CURLOPT_COOKIEFILE, $cookie); 
    $data2 = curl_exec($data); 
    curl_close($data); 
    $return = iconv('utf-8','cp1251',$data2); 
    if (preg_match('/Неправильный логин или пароль/Ui',$return)) return FALSE; else return TRUE;

    eval, 28 Мая 2010

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

    +157

    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
    <?php
    set_time_limit(0);
    Error_Reporting(E_ALL & ~E_NOTICE);
    
    $mail = "@rambler.ru"; //e-mail или логин от контакта
    $pass = ""; //пароль от контакта
    $uids = "3,5,7,8,10,15,1955,54665,233254"; //кого проверяем
    
    function get($link,$cookie){ 
    
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL,$link); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    
    $otvet = curl_exec($ch); 
    curl_close($ch); 
    return $otvet; 
    }
    
    $aut=file_get_contents('http://login.vk.com/?act=login&email='.urlencode($mail).'&pass='.urlencode($pass).'&expire=&vk=');
    preg_match("/id=\'s\' value=\'(.*?)\'/",$aut,$sid);
    $cookie="remixsid=$sid[1];";
    
    $res=get("http://vkontakte.ru/feed2.php",$cookie);
    $feed=json_decode($res);
    $id=$feed->user->id;
    
    $count = substr_count($uids,",");
    $count = $count+1;
    
    $sig=md5(''.$id.'api_id=35569fields=has_mobileformat=JSONmethod=getProfilesuids='.$uids.'v=2.0SRkM2ws8NQ');
    
    $res=get("http://api.vkontakte.ru/api.php?api_id=35569&fields=has_mobile&format=JSON&method=getProfiles&uids=$uids&v=2.0&sig=$sig",$cookie);
    preg_match_all("/uid\":(.*?),\"first_name\":\"(.*?)\",\"last_name\":\"(.*?)\",\"has_mobile\":(.*?)\}/",$res,$info);
    
    for($i=0;$i<$count;$i) { 
    
    $qwe=$i++;
    
    $uidx=$info[1][$qwe];
    $first_name=$info[2][$qwe];
    $last_name=$info[3][$qwe];
    $has_mobile=$info[4][$qwe];
    
    print iconv('utf-8', '866', "\n--------id$uidx: $first_name $last_name [$has_mobile]--------\n\n\n"); }
    
    ?>

    http://volk.hx0.ru

    r00t, 27 Мая 2010

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

    +169

    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
    htaccess:
    
    DirectoryIndex index.php
    RewriteEngine on
    RewriteBase /
    RewriteRule ^0.html$ style/index.php
    RewriteRule ^1.html$ style/index.php?id=register
    RewriteRule ^2.html$ style/index.php?id=download
    RewriteRule ^3.html$ style/index.php?id=top_chars
    RewriteRule ^4.html$ style/index.php?id=who_online
    RewriteRule ^5.html$ style/index.php?id=top_zeny
    RewriteRule ^6.html$ style/index.php?id=top_mvp
    RewriteRule ^7.html$ style/index.php?id=top_pvp
    RewriteRule ^8.html$ style/index.php?id=top_guild
    RewriteRule ^9.html$ style/index.php?id=who_sell_buy
    RewriteRule ^10.html$ style/index.php?id=first_class
    
    
    php:
    
    <?php
    $url = $REQUEST_URI;
    $url2 = strlen($url);
    if($url2 > 14) { 
    header("location: ./");
    exit;
    }
        
    ?>

    Комментарий от автора:

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

    xynta, 26 Мая 2010

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

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    <script>                                                                                                                           
    function build_view(){
      $('div.content').append(""+  <?php $flag=false; foreach($work_meters as $work){?> "<div id=\"<?=$work->id?>\" style='margin-bottom:30px;' >  <span class=\"name\"><?=$work->name?> </span>  <div s\
    tyle=\"display:inline;float:left\" align=\"left\" >   <table class='data_table' style=\"margin-top:50px;\" id='table_<?=$work->id?>'>    <tr>    <td>дата</td><td>значение</td>"+  <?php if(in_array\
    (5, $user->roles)) { ?> "  <td></td>    "+  <?php } ?> <?php while(list($key, $vals) = each($work->data)){ ?>  "  <tr><td><?=$vals[0]?></td> <td><?=$vals[1]?></td>      "+     <?php if(in_array(5,\
     $user->roles)) { ?>        "    <td><a onclick=\"delete_row(<?=$key?>, <?=$work->id?>)\" href='javascript:void(0);'>удалить</a></td>       "+    <?php } ?>  "     </tr>   "+        <?php } ?>"   \
    </tr>     "+  <?php if(in_array(5, $user->roles)) { ?>  "  <tr><td><input type='text' name='date' size='7'/></td><td><input type='text' name='value' size='5'/></td><td><input type='button' value='\
    добавить' onclick='add_data(<?=$work->id?>, $(this).parent().parent());'></td></tr>       <tr><td colspan='3' style='text-align:right;'><input type='button' onclick='save(<?=$work->id?>);' value='\
    сохранить'></td></tr>       "+  <?php } ?>  "  </table> </div>  <div style=\"width:600px;height:300px;margin-left:120px;\" class=\"image\">     </div>  <div class=\"description\" style='margin-top\
    =10px;'>    <?=$work->description?> </div>  </div>"+        <?php $flag = true;} ?>"" );
      }
    </script>

    эта ересь генерирует html для javascript функции которая втсавляет это всё в страницу.

    Arnial, 26 Мая 2010

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

    +157

    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
    /**********************************************************************
    		*  Connect to DB - over-ridden by specific DB class
    		*/
    
    		function connect()
    		{
    			die(EZSQL_CORE_ERROR);
    		}
    
    		/**********************************************************************
    		*  Select DB - over-ridden by specific DB class
    		*/
    
    		function select()
    		{
    			die(EZSQL_CORE_ERROR);
    		}
    
    		/**********************************************************************
    		*  Basic Query	- over-ridden by specific DB class
    		*/
    
    		function query()
    		{
    			die(EZSQL_CORE_ERROR);
    		}
    
    		/**********************************************************************
    		*  Format a string correctly for safe insert - over-ridden by specific
    		*  DB class
    		*/
    
    		function escape()
    		{
    			die(EZSQL_CORE_ERROR);
    		}
    
    		/**********************************************************************
    		*  Return database specific system date syntax
    		*  i.e. Oracle: SYSDATE Mysql: NOW()
    		*/
    
    		function sysdate()
    		{
    			die(EZSQL_CORE_ERROR);
    		}

    Продвинутый способ создания абстрактных методов. Это кагбе абстрактный класс, от которого наследуются БД-специфичные классы. Затем какая вам БД нужна, под такую руками и создавайте экземпляр нужного класса, "фабрикой" даже и не пахнет.
    Зовётся сие чудо ezSQL. Используется в NetCat. Ладно хоть не сами наложили (налажали?), но всё ж головой не подумали, когда брали.

    telnet, 26 Мая 2010

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