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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function getDateFromTime($dataTime){
      $strDate = date('d-m-Y', $dataTime);
      $arrDate = explode('-', $strDate);
    
      return mktime(0, 0, 0, $arrDate[1], $arrDate[0], $arrDate[2]);
    }

    руки-жопа-голова%)

    warider, 23 Июня 2011

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

    +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
    void AClass::registerApplication( int pCaller )
    {
      if ( mRegistry == NULL )
      {
        // we will be the first application in registry
        mRegistry = createRegistryElement( pCaller );
      }
      else
      {
        // there are other applications already registered
        // first create registry entry
        Application *lApplication = NULL;
        lApplication = createRegistryElement( pCaller );
    
        // put entry in front
        lApplication->mNext = mRegistry;
        mRegistry = lApplication;
      }
    }

    добавляем новый элемент в односвязный список. mRegister голова списка. кто не видит говна - идти читать матчасть.

    Dummy00001, 22 Июня 2011

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

    +153

    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
    try
    			{
    				sw = gcnew StreamWriter(GetIniFileName());
    			}
    			catch(UnauthorizedAccessException^ e)
    			{
    				MessageBox::Show( "Access is denied.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(ArgumentNullException^ e)
    			{
    				MessageBox::Show( e->ParamName + ": File path is null.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(ArgumentException^ e)
    			{
    				MessageBox::Show( e->ParamName + ": Wrong file path.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(DirectoryNotFoundException^ e)
    			{
    				MessageBox::Show( "The specified path is invalid, such as being on an unmapped drive.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(PathTooLongException^ e)
    			{
    				MessageBox::Show( "The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. ", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(IOException^ e)
    			{
    				MessageBox::Show( "File path includes an incorrect or invalid syntax for file name, directory name, or volume label syntax. ", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(SecurityException^ e)
    			{
    				MessageBox::Show( "The caller does not have the required permission." + e->ToString(), "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(System::Exception^ e)
    			{
    				ShowException(e);
    				return;
    			}

    Обработка исключений.

    ScumCoder, 22 Июня 2011

    Комментарии (21)
  4. C++ / Говнокод #7027

    +169

    1. 1
    2. 2
    const void* const relay(const TrigClass& Overloading=*((TrigClass*)(NULpoter))){
      if(&Overloading==NULpoter){

    Говногость, 22 Июня 2011

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

    +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
    $arrParams = array();
                    $arrParams['table'] = array();
                    $arrParams['limit'] = 20;
                    
                    $arrParams['table']['id'] = 'cmt_summary';
                    $arrParams['table']['class'] = 'comments';
                    $arrParams['table']['rows_id'] = 'cmt_{{comment_id}}';
                    
                    $arrParams['table']['columns'] = array();
                    
                    $arrParams['table']['columns']['comment_id'] = array();
                    $arrParams['table']['columns']['comment_id']['name'] = 'Comment ID';
                    $arrParams['table']['columns']['comment_id']['class'] = 'a';
                    $arrParams['table']['columns']['comment_id']['sort'] = true;
                    $arrParams['table']['columns']['comment_id']['search'] = array('type'=>'int');
                    $arrParams['table']['columns']['comment_id']['row'] = $sRowOutput;
                    
                    $arrParams['table']['columns']['user_name'] = array();
                    $arrParams['table']['columns']['user_name']['name'] = 'Poster Username';
                    $arrParams['table']['columns']['user_name']['class'] = 'a';
                    $arrParams['table']['columns']['user_name']['sort'] = true;
                    $arrParams['table']['columns']['user_name']['search'] = array('type'=>'string');
                    $arrParams['table']['columns']['user_name']['row'] = $sRowOutput;
                    
                    $arrParams['table']['columns']['email'] = array();
                    $arrParams['table']['columns']['email']['name'] = 'Poster Email';
                    $arrParams['table']['columns']['email']['class'] = 'a';
                    $arrParams['table']['columns']['email']['sort'] = true;
                    $arrParams['table']['columns']['email']['search'] = array('type'=>'string');
                    $arrParams['table']['columns']['email']['row'] = $sRowOutput;

    Прошло уже почти 3 месяца как я сижу на проекте, а он не перестаёт меня удивлять :)

    Глядя на эти строки думается что-то подобное было в головах у кодеров:
    - Зачем юзать объекты, в массивы всё нормально ложится и они легче.
    - По фиг что массивы не подхватывает ни одна IDE, Notepad++ всё ещё бесплатный, а большего в PHP и не надо.
    - Зачем XML и XSD? Зачем это усложнение? Ну и что Ext4Yii хороший пример того как можно это сделать? Нам не нужны слабые духом программисты! :)

    kovel, 22 Июня 2011

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

    +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
    // Это у них такой конфиг:
    
    //--------------------------------------------------------------------------------------
    // Определение дирректорий сервера
    	$siteDir = '';
     	$DIR = array(
    	'root' => $_SERVER['DOCUMENT_ROOT'].$siteDir,
    	);
    	$DIR['HOST'] = 'http://'.$_SERVER['HTTP_HOST'];
    	$DIR['media'] = $DIR['root'].'/media/';
    	$DIR['theme'] = $DIR['root'].'/themes/';
    	$DIR['lib'] = $DIR['root'].'/lib/';
    	$DIR['script'] = $DIR['root'].'/scripts/script.';
    
    
    // А это у них такая мвц 
    // при error_reporting(E_ALL) - таааакая знатная жопа
    
    //---------------------------------------------------------------//
    /* Организация простейшего MVC							 		 */
    //---------------------------------------------------------------//
    
    	//Загружаем модель для формированния данных
    	if(file_exists($DIR['script'].$Page.'.php'))
    		require_once($DIR['script'].$Page.'.php');	
    				
    	//Загрузка шаблона для отоброжения данных
    		require_once($DIR['theme'].'default.php');

    Ща сижу на собеседование, попросили сделать пару страничек, используя местные порядки.
    Сижу в шоке.

    asdkhkadhfkha22, 22 Июня 2011

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

    +136

    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
    <td colspan="3" rowspan="2">
    	<script>
    		if(hsub>0){
    			document.write(
    	'<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0 style=position:absolute;top:'+(ah-hsub)+'px>')
    		}else{
    			document.write(
    	'<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0>')
    		}
    	</script>
    	<noscript>
    		<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0>
    	</noscript>
    <tr>

    Нет слов!

    Joe_MD, 22 Июня 2011

    Комментарии (20)
  8. C# / Говнокод #7023

    +119

    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
    // создаём источник для репитера
    
    private DataTable EventsDataTable
            {
                get
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(
                        new DataColumn("ID", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("day", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("date", typeof(DateTime)));
                    dt.Columns.Add(
                        new DataColumn("title", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("url", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("description", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("location", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("place", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("FileDirRef", typeof(string)));
                    // Добавляем строчки
                    foreach (EventInfo ei in CalendarEvents)
                    {
                        DataRow dr = dt.NewRow();
                        dr["day"] = ei.EventDate.Date.ToString("ddMMyyyy");
                        dr["date"] = ei.EventDate;
                        dr["title"] = ei.Title;
                        dr["location"] = ei.Location;
                        dr["ID"] = ei.ID;
                        dr["FileDirRef"] = ei.FileDirRef;
                        dt.Rows.Add(dr);
                    }
                    return dt;
                }
            }
    
    
    protected void repeaterItemDataBound(object sender, RepeaterItemEventArgs e)
    {
    if (e != null
                        && e.Item != null
                        && e.Item.DataItem != null
                        && e.Item.DataItem is DataRow)
                    {
                        DataRow dataItem = (DataRow)e.Item.DataItem;
    
                        Label date = (Label)(e.Item.FindControl("date"));
                        date.Text = 
                            dataItem["date"] != null
                            ? Convert.ToDateTime(dataItem["date"].ToString()).ToString()
                            : Convert.ToDateTime(dataItem["Created"].ToString()).ToString();
                        date.Text = date.Text.Substring(0, date.Text.Length - 3);
    
                        HyperLink title = (HyperLink)(e.Item.FindControl("title"));
                        title.Text = dataItem["title"].ToString();
                        Label location = (Label)(e.Item.FindControl("location"));
                        location.Text = "Расположение: " + dataItem["location"].ToString();
                    }
    }

    Современный способ привязки данных в asp.net Repeater

    Gnet, 22 Июня 2011

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

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <?php 
    function antihack(&$var){   
    if(is_array($var)) array_walk($var, 'antihack');  
    else $var = htmlspecialchars(stripslashes(mysql_real_escape_string($var)), ENT_QUOTES, 'UTF-8');   
    }   
    
    foreach(array('_SERVER', '_GET', '_POST', '_COOKIE', '_REQUEST') as $v){   
    if(!empty(${$v})) array_walk(${$v}, 'antihack');  
    }  
    ?>

    http://homephp.ru/phpcode/index.php?system=bild&stat=173445591-534250613&

    jQuery, 21 Июня 2011

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

    +151

    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
    else {
        fwrite($fp,"\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00".chr(10));
        $start=time();
        socket_set_timeout($fp,1);
        $st=fread($fp,1);
        $r=socket_get_status($fp);
        $r=$r["unread_bytes"];
        $st.=fread($fp,$r);
        fclose($fp);
        $st=substr($st,5);
        $address=SubStr($st,0,StrPos($st,chr(0)));
        $address=str_replace(chr(0),"|",$address);
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $name=SubStr($st,0,StrPos($st,chr(0)));
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $map=SubStr($st,0,StrPos($st,chr(0)));
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $current=ord(SubStr($st,0,1));
        $max=ord(SubStr($st,1,1));
        }
    if ($_GET['info'] == "map")
    {
    echo "document.write('$map');"; 
    }
    if ($_GET['info'] == "players")
    {
       if ($current == "0")
       {
          echo "document.write('<font color=red>$current</font>/$max');";
       }
       else
       {
          if($current == $max)
          {
             echo "document.write('<font color=00FF00>$current</font>/$max');";
          }else{
             echo "document.write('$current/$max');";
          }
       }
    }
    if ($_GET['info'] == "map-img")
    {
    echo "document.write('<img width=$width border=0 src=http://image.www.gametracker.com/images/maps/160x120/cs/$map.jpg>');";
    }
    if ($_GET['info'] == "source-map")
    {
    echo "document.write('$name');";
    }
    if ($_GET['info'] == "block1")
    {
    echo "document.write('<table border=0><tr><td align=center><marquee>$name</marquee><br><img width=160px height=120px style=background:url(http://www.agrank.com/images/maps/210_150/_offline.jpg); border=0 src=http://image.www.gametracker.com/images/maps/160x120/cs/$map.jpg><br>Map - $map<br>Players - <script language=JavaScript src=http://game-monitoring.tk/ucoz/cs-info.php?ip=$ip&port=$port&info=players></script><br><br><center><input value=$ip:$port readonly=readonly onclick=f2(this); class=f_linput type=text></center></td></tr></table>');";
    }
    if ($_GET['info'] == "block4")
    {
    }
    ?>

    Мало ли того, что гавнокод, так ещё и SubStr. аха

    substr, 21 Июня 2011

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