ЙажаСценарий / Говнокод #2301 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
function sendClicked(F)
{
var binary = document.getElementById("binary");
var binary_file = binary.value;
var binary_len = binary_file.length;
if(binary_file == ""){
binary.focus();
alert('File name can not be empty !');
return false;
}
else {
if(binary_len<=4) {
binary.focus();
alert('File is wrong !');
return false;
}
if(binary_file.charAt(0) != '/') {
if(binary_file.charAt(1) != ':') {
binary.focus();
alert('File is wrong !!');
return false;
}
}
if(binary_file.charAt(binary_len-4) != '.') {
binary.focus();
alert('File is wrong !!');
return false;
}
if(binary_file.charAt(binary_len-3) != 'B') {
if(binary_file.charAt(binary_len-3) != 'b') {
binary.focus();
alert('File is wrong !!');
return false;
}
}
if(binary_file.charAt(binary_len-2) != 'I') {
if(binary_file.charAt(binary_len-2) != 'i') {
binary.focus();
alert('File is wrong !!');
return false;
}
}
if(binary_file.charAt(binary_len-1) != 'N') {
if(binary_file.charAt(binary_len-1) != 'n') {
binary.focus();
alert('File is wrong !!');
return false;
}
}
show_div(true, "progress_div");
progress();
return true;
}
}

</script>

Со странички обновления прошивки DWL-G700AP. Из-за этого говнокода прошивается только из internet explorer.

user.user521 user.user521, (Updated )

Комментарии (14, +14)

Си диез / Говнокод #2299 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
[TestFixture]
    class Program
    {
        static void Main(string[] args)
        {
            .................   
        }
    }

    [TestFixture]
    internal class FileParser
    {
        [Test]
        private static string Replace(string inputValue, string oldWord,string newWord)
        {
            return inputValue.Replace(oldWord, newWord);
        }

        [Test]
        private static string Remove(string inputValue, string word)
        {
            return inputValue.Replace(word, null);
        }

        [Test]
        public string Run(string stringFromFile)
        {
            foreach (var command in _listOfCommands)
            {
                switch (command.IdCommand)
                {
                    case 0:
                        stringFromFile = Replace(stringFromFile, command.OldWord, command.NewWord);
                        break;
                    case 1:
                        stringFromFile = Remove(stringFromFile, command.NewWord);
                        break;
                }
            }
            return stringFromFile;
        }
    }

программист слишком буквально понял TestDrivenDevelopment :)) взято из консольного приложения

explosion_head explosion_head, (Updated )

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

"PHP" / Говнокод #2298 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
$keys = array_keys($_POST);
$vals = array_values($_POST);
for($i=0; $i<=count($keys); $i++)
{
    if($keys[$i]!='act' && $keys[$i]!='mode' && $keys[$i]!='pid')
    {
            $sql->Query('UPDATE `user_services_options` SET `value`=\''.$f->QuoteSql($vals[$i]).'\' WHERE `option`=\''.$f->QuoteSql($keys[$i]).'\' AND `service_id`='.$f->QuoteSql($service_id).' AND user_id='.$f->QuoteSql($user_id));
    }
}

кагбе про foreach($_POST as $key => $value) я тогда и не знал.

nolka4 nolka4, (Updated )

Комментарии (3, +3)

"PHP" / Говнокод #2297 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
if(isset($input['submitted']))	
            	{
                mysql_query("UPDATE modules SET loading = 0");
                $query = mysql_query("SELECT class from modules");
               
                while(list($cl) = mysql_fetch_row($query))
                  {
                   
                   if(strtolower($input[$cl]) == "on")
                   {
                     mysql_query("UPDATE modules SET loading = 1 WHERE class = '".$cl."'");
                   }
                  }
                    mysql_query("UPDATE modules SET loading =1 WHERE class='conf'");
                    print "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=?class=conf&action=control\">";
             	}
              
    	    $query = mysql_query("SELECT class,loading FROM modules");
            while($data = mysql_fetch_row($query)) $load[$data[0]] = $data[1];
            print "<table border=\"1\" style=\"border-style:solid\" cellpadding=\"5\" cellspacing =\"2\">\n";
              print "<form method=\"post\">\n<input type=\"hidden\" name=\"class\" value=\"conf\"><input type=\"hidden\" name=\"action\" value=\"control\">\n<tr><td class=\"text\" align=\"center\"><b>Название</b></td><td class=\"text\" align=\"center\"><b>Описание</b></td><td class=\"text\" align=\"center\"><b>Файлы</b>\n
            </td><td class=\"text\"><b>Загружается</b></td></tr>";
			$query = mysql_query("SELECT * FROM modules") or die(mysql_error());
            while($data = mysql_fetch_array($query))
            {
	    		print "<tr><td class=\"text\">".$data['title']."</td><td class=\"text\">".$data['descr']."</td><td class=\"text\">";
		    	$_f = explode("\n",trim($data['files']));
                $c = count($_f);
    			for($i=0;$i<$c;$i++)print $_f[$i]."<br>\n";
                print "</td><td class=\"text\"><input type=\"checkbox\" name=\"".$data['class']."\" ";
                if($load[$data['class']] == 1) print "CHECKED";
                print " ></td></tr>";
            }
            print "</table>\n";
            print "<input type=\"hidden\" name=\"submitted\" value=\"1\">\n";
            print "<br><input type=\"submit\" value=\"Применить\"></form>";

nolka4 nolka4, (Updated )

Комментарии (2, +2)

Куча говна / Говнокод #2294 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
<html>
    <head>
    </head>
    <body>
        <table class="fon_verstala_mudak" width="939" cellspacing="0" cellpadding="0" border="0" align="center">
        </table>
        <table class="fon2_verstala_mudak" width="939" cellspacing="0" cellpadding="0" border="0" align="center">
        </table>
    </body>
</html>

Как потерять клиента из-за верстальщика-мудака?
Хотел купить телефон, но сначала заглянул как свёрстан сайт... Про то что кроссбраузерность даже на костылях мимо не проходила я промолчу, но код начисто отбил желание отовариваться у них.

VanSanblch VanSanblch, (Updated )

Комментарии (8, +8)

Jawa / Говнокод #2293 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
java.util.Date from = dateFromAndToMap.get("from");
        java.util.Date to = dateFromAndToMap.get("to");
        java.sql.Date fromD;
        java.sql.Date toD;
        Long year2100 = Long.valueOf(64060495200000l);
        if (from != null) {
            fromD = new java.sql.Date(from.getTime());
        } else {
            fromD = new java.sql.Date(0);
        }
        if (to != null) {
            toD = new java.sql.Date(to.getTime());
        } else {
            toD = new java.sql.Date(year2100.longValue());
        }

Год апокалипсиса приложения :) А календарь придумали лузеры, а мы не ищем легких путей ведь перед апокалипсисом все равны

johnsoft johnsoft, (Updated )

Комментарии (2, +2)

"PHP" / Говнокод #2292 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
$dir = $_SERVER['DOCUMENT_ROOT'].'/upload/'.$_GET['ID'].'/';
		$urlz = array();
		if ($dh = opendir($dir))
		{
			clearstatcache();
			while (($file = readdir($dh)) !== false)
				if (strlen($file)>3 && substr($file, -4)!='.flv')
				{
					$FILE_PATH = $_SERVER['DOCUMENT_ROOT'].'/upload/'.$_GET['ID'].'/'.$file;
					$TIME = filemtime($FILE_PATH);
					while (array_key_exists($TIME,$urlz))
						$TIME++;
					if (filesize($FILE_PATH)>0)
						$urlz[$TIME] = $file;
				}
		    closedir($dh);
		    krsort($urlz);
		}
		$i = 0;
		foreach ($urlz as $k=>$v)
			if ($i>2)
				unset($urlz[$k]);
			else
		    {
		    	$i++;
		        $urlz[$k] = 'http://www.'.$_SERVER['HTTP_HOST'].'/upload/'.$_GET['ID'].'/'.$v;
			}

atarix12 atarix12, (Updated )

Комментарии (4, +4)