1. Список говнокодов пользователя fork

    Всего: 8

  2. PHP / Говнокод #5390

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if($_GET)
    {
    	$args = explode("&",$_SERVER['QUERY_STRING']);
    	foreach($args as $arg)
    	{
    		$keyval = explode("=",$arg);
    		if($keyval[0] != "page" And $keyval[0] != "ipp") $this->querystring .= "&" . $arg;
    	}
    }

    Уникальный способ получения get параметров....

    fork, 25 Января 2011

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

    +162

    1. 1
    $str = strip_tags(htmlentities($str));

    простовато, но...
    Тэги не пройдут!!!

    fork, 15 Декабря 2010

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

    +178

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function verifyQuery($sql, $con) {
        if (!mysql_query($sql, $con)) {
            echo "Error occured in verifyQuery() in sqlfunctions.php <br>";
            echo "SQL sent : ";
            echo $sql;
            echo "<br>Database report: <br>";
            die('Error: ' . mysql_error());
        }
        return mysql_query($sql, $con);
    }

    fork, 11 Декабря 2010

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

    +168

    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
    function test_file_for_smells( $filename )
       {
       global $MAX_FUNCTION_LINE_COUNT, $MAX_INDENTATION_LEVEL;
       $function_line_count = 0;
       $found_continued_line = 0;
       $line_number = 0;
       $fp = fopen( $filename, "r" );
       if( ! $fp )
         return;
       while( ! feof( $fp ) )
         {
         $line = chop( fgets( $fp, 4096 ) );
         $line_number++;
         while( substr( $line, 0, 9 ) == "function "  &&
                substr( $line, strlen($line) - 1, 1 ) != ')' )
           {
           $line = $line . chop( fgets( $fp, 4096 ) )
           $found_continued_line++;
           }
         if( substr( $line, 0, 9 ) == "function " )
           {
           $function_line_count = 1;
           $function_name = substr( $line, 9, strpos($line, '(') - 9 );
           }
         if( $function_line_count > 0 )
           {
           if( $line == "\t}" )
             {
             $function_line_count = $function_line_count - 3;
             if( $function_line_count > $MAX_FUNCTION_LINE_COUNT )
               print_warning( $filename, $line, $line_number, "$function_name() too long ($function_line_count lines)" );
             $function_line_count = 0;
             }
           else
             $function_line_count++;
           $result = test_line_for_indentation( $line, $MAX_INDENTATION_LEVEL );
           if( ! $result )
             print_warning( $filename, $line, $line_number, "Too much nesting." );
           $result = test_line_for_function_definition( $line, $MAX_NUM_PARAMETERS );
           if( ! $result )
             print_warning( $filename, $line, $line_number, "Too many parameters." );
           if( $found_continued_line > 0 )
             {
             $line_number += $found_continued_line;
             $found_continued_line = 0;
             }
           }
         }
       }

    Детектор говнокода!!!!

    fork, 10 Декабря 2010

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

    +168

    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
    function IsAlphaNumeric($str)
    {
       $old = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
       $new = Array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
       if (str_replace($str, $old, $new) == "")
       {
          return (true);
       }
       else
       {
          return (false);
       }
    }

    говно + валидация = говнодация

    fork, 08 Декабря 2010

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

    +161

    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
    $sec_in_year = 31536000;
    $sec_in_lyear = 31622400;
    $sec_in_28 = 2419200;
    $sec_in_29 = 2505600;
    $sec_in_30 = 2592000;
    $sec_in_31 = 2678400;
    $sec_in_day = 86400;
    $sec_in_hour = 3600;
    $sec_in_min = 60;
    $year_count = 1970;
    $month_count = 0;
    $day_count = 1;
    $hour_count = 0;
    $min_count = 0;
    $lyear_count = 2;                                                // Make an array of seconds per month for ease of use.
    $months = array(2678400, 2419200, 2678400, 2592000, 2678400, 2592000, 2678400, 2678400, 2592000, 2678400, 2592000, 2678400);
    $lmonths = array(2678400, 2505600, 2678400, 2592000, 2678400, 2592000, 2678400, 2678400, 2592000, 2678400, 2592000, 2678400);
    $month_list = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
    
    while($utime >= $sec_in_year) {                        // Count the year since 1970.
            if($lyear_count % 4 == 0) {
              $utime -= $sec_in_lyear;                // Compensate for leap years.
            }
            else {
              $utime -= $sec_in_year;
            }
            $year_count++;
            $lyear_count++;
    }
    while($utime >= $months[$month_count]) {        // Count the months since Jan.
            if($lyear_count % 4 == 0) {
                    $utime -= $lmonths[$month_count];        // Compensate for leap year Feb.
            }
            else {
                    $utime -= $months[$month_count];
            }
            $month_count++;
    }

    И еще куча строк кода.
    Конвертим никсовый временной штамп, в читаемый для человека формат... aka date()

    fork, 07 Декабря 2010

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

    +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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    // To protect MySQL injection
    $username = stripslashes($username);
    $password = stripslashes($password);
    $username = mysqli_real_escape_string($connect, $username);
    $password = mysqli_real_escape_string($connect, $password);
                                                   
    $login = mysqli_query($connect, "SELECT * FROM users WHERE username = '$username'");
    while ($row = mysqli_fetch_assoc($login))
    {
        $db_password = $row['password'];
        if (sha1($password) == $db_password)
            $loginok = TRUE;
        else
            $loginok = FALSE;
    
        if ($loginok == TRUE)
        {
            // Register $username, $password
            $_SESSION["username"] = $username;
            exit();
        }
        else
            die('Feil brukernavn/passord.');
    }

    pastebin временами радует :)
    http://pastebin.com/hW8BbEmt

    fork, 26 Октября 2010

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

    +168

    1. 1
    2. 2
    $Y=date('Y'); $m=date('m'); $d=date('d');$G=date('G');$i=date('i');$s=date('s'); 
    $tdate=mktime($G,$i,$s,$m,$d,$Y);

    fork, 26 Октября 2010

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