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

    +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
    // редиректим адреса без слеша на такие же со слешем
    $uri = $_SERVER['REQUEST_URI'];
    $is_file = false;
    if (	(substr_count($uri,".php")>0) or (substr_count($uri,".html")>0)		) {
    	$is_file = true;
    }
    
    if ($is_file == false) {
    	$len_uri = strlen($uri);
    	// находим последнее вхождение слеша
    	$reverst_str = strrev($uri);
    	//die($reverst_str);
    	$last_slash = strpos($reverst_str,"/");
    	
    	//die($last_slash);
    	if  ($last_slash!==0) {
    		
    		$uri .="/";
    		$status = "301 Found";
    		//header("Status: ".$status);
    		header('HTTP/1.1 301 Moved Permanently');
    		header("Location: http://www.thermostudio.ru"."$uri");
    		exit();
    
    	}
    }

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

    nislova, 23 Июня 2011

    Комментарии (14)
  2. Pascal / Говнокод #7033

    +115

    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
    procedure info_();
      var
       i:integer;
       ActivityCategory,stroka,strok,stroka_sopr,http1100,http_sopr,tag,tag_sopr,until_date,date_:string;
       f1100,f_sopr,inf:textfile;
    begin  //главный
    clear();
    if form1.radioGroup1.ItemIndex=0 then begin
                                          http1100:='\\server1\Отдел 1\Program Files\Prof\profiki\1100\'+m+'.smc';
                                          http_sopr:='\\server1\Отдел 1\Program Files\prof\profiki\сопроводительное\'+m+'.smc';
                                          end;
    if form1.radioGroup1.ItemIndex=1 then begin
                                          http1100:='\\server1\Отдел 1\Program Files\Prof\banki\1100\'+m+'.smc';
                                          http_sopr:='\\server1\Отдел 1\Program Files\prof\banki\сопроводительное\'+m+'.smc';
                                          end;
    if form1.radioGroup1.ItemIndex=2 then begin
                                          http1100:='\\server1\Отдел 1\Program Files\Prof\YK\1100\'+m+'.smc';
                                          http_sopr:='\\server1\Отдел 1\Program Files\prof\YK\сопроводительное\'+m+'.smc';
                                          end;
    if form1.radioGroup1.ItemIndex=3 then begin
                                          http1100:='\\server1\Отдел 1\Program Files\Prof\NPF\1100\'+m+'.smc';
                                          http_sopr:='\\server1\Отдел 1\Program Files\prof\NPF\сопроводительное\'+m+'.smc';
                                          end;
    if form1.radioGroup1.ItemIndex=4 then begin
                                          http1100:='\\server1\Отдел 1\Program Files\Prof\REGISTRATOR\1100\'+m+'.smc';
                                          http_sopr:='\\server1\Отдел 1\Program Files\prof\REGISTRATOR\сопроводительное\'+m+'.smc';
                                          end;

    Пытался перенести в другую папку программу, после чего она по сути перестала работать, ругаясь ошибкой 63. Нашел ее исходники и увидел ЭТО... это лишь 5-10% всей процедуры, которая мало того, что ищет XML-файлы по определенному пути, так еще и парсит их...

    GhOsTMZ, 23 Июня 2011

    Комментарии (6)
  3. Java / Говнокод #7032

    +74

    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
    private static java.util.Hashtable<String, Session> sessions =
        new java.util.Hashtable<String, Session>();
    ...
    public static SessionOperations[] getSessions() {
        int cnt = sessions.size();
        SessionOperations[] res = new SessionOperations[cnt];
        java.util.Enumeration<String> e = sessions.keys();
        for( int i = 0; i < res.length; i++ ) {
          String sid = e.nextElement();
          res[i] = sessions.get( sid ).getOperations( sid );
        }
        return res;
    }

    Удаление из sessions между получением размера и набора ключей приводит к весьма печальным последствиям...

    P.S. В результате в течение трех суток в production не удалялись оставленные сессии (без Logout), sessions отожрал 600М и всё свалилось с OOM.

    Skipy, 23 Июня 2011

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

    +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
    #include <a_samp>
    
    new objects[MAX_OBJECTS];
    
    public OnFilterScriptInit()
    {
    	objects[0] = CreateObject(980, -2491.1276855469, -129.08126831055, 27.397054672241, 0, 0, 90.675659179688);
    	objects[1] = CreateObject(980,-2459.8862304688,-152.13926696777,27.652730941772,0,356,0);
        objects[2] = CreateObject(980,-2446.0773925781,-82.466796875,35.984577178955,0,356,0);
    	return 1;
    }
    
    public OnPlayerCommandText(playerid, cmdtext[])
    {
    	if (strcmp("/garage", cmdtext, true, 10) == 0)
    	{
    		MoveObject(objects[0], -2491.1276855469, -129.08126831055, 20, 2);
    		SetTimer("VTimer", 10000, 0);
    		return 1;
    	}
    	return 0;
    }
    
    forward VTimer();
    public VTimer()
    {
    	MoveObject(objects[0], -2491.1276855469, -129.08126831055, 27.397054672241, 2);
    	return 1;
    }

    smith, 23 Июня 2011

    Комментарии (13)
  5. 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)
  6. 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)
  7. 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)
  8. C++ / Говнокод #7027

    +169

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

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

    Комментарии (59)
  9. 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)
  10. 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)