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

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
$f=file(substr($_SERVER["SCRIPT_NAME"],1));
if(substr($f[9],1,4)=="url=") {$f[9]='$url=\''.$_POST['def_dir']."';\r\n";}
if(substr($f[10],1,16)=="root_user_login=") {$f[10]='$root_user_login=\''.$_POST['adm_login']."';\r\n";}
if(substr($f[11],1,15)=="root_user_pass=") {$f[11]='$root_user_pass=\''.$_POST['adm_pass']."';\r\n";}
if(substr($f[12],1,12)=="maxfilesize=") {$f[12]='$maxfilesize=\''.$_POST['maxfilesize']."';\r\n";}
if(substr($f[13],1,20)=="delete_confirmation=") {$f[13]='$delete_confirmation='.$_POST['delete_confirmation'].";\r\n";}
fwrite(fopen(substr($_SERVER["SCRIPT_NAME"],1), "w"), join('', $f)); /// the script must be in root folder =( I'm too lazy to fix it

соус ФМа знакомого...strpos для лохов! юзаем substr!=)

Anderson Anderson, (Updated )

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

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

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
$htmlhead='<html><head><meta>..............</head><body>';
$htmlend='</body></html>';
$table['start']='<table style=...><tr><td>'
$table['center']='</td><td>';
$table['end']='</td></tr></table>';
$menu='<a href=.......>main</a>aaa'

[..........]

function serror($error) {
global $htmlhead;
global $table;
global $menu;
global $htmlend;
global $lang;
echo $htmlhead.$table['start'].$menu ......
}

Так грамотно вначале, и тут вдруг...

Anderson Anderson, (Updated )

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

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

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
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
public class StringBufferDbBean {

	public StringBufferDbBean() {
	}

	public String appendString(String string1, String string2) {
		String string = null;
		StringBuffer sb = new StringBuffer(string1);
		sb.append(string2);
		string = sb.toString();
		return string;
	}

	public void appendString(StringBuffer strBuf, String string1, String string2) {
		strBuf.append(string1);
		strBuf.append(string2);
	}

	public void appendString(StringBuffer strBuf, String string1, String string2, String string3) {
		strBuf.append(string1);
		strBuf.append(string2);
		strBuf.append(string3);
	}

	public void appendString(StringBuffer strBuf, String string1, String string2, String string3, String string4) {
		strBuf.append(string1);
		strBuf.append(string2);
		strBuf.append(string3);
		strBuf.append(string4);
	}

	public void appendString(StringBuffer strBuf, String string1, String string2, String string3, String string4,
			String string5) {
		strBuf.append(string1);
		strBuf.append(string2);
		strBuf.append(string3);
		strBuf.append(string4);
		strBuf.append(string5);
	}

	public void appendString(StringBuffer strBuf, String string1, String string2, String string3, String string4,
			String string5, String string6) {
		strBuf.append(string1);
		strBuf.append(string2);
		strBuf.append(string3);
		strBuf.append(string4);
		strBuf.append(string5);
		strBuf.append(string6);
	}

	public void appendString(StringBuffer strBuf, String string1, String string2, String string3, String string4,
			String string5, String string6, String string7) {
		strBuf.append(string1);
		strBuf.append(string2);
		strBuf.append(string3);
		strBuf.append(string4);
		strBuf.append(string5);
		strBuf.append(string6);
		strBuf.append(string7);
	}
}

А вот енто истинное восточное мастерство! Похоже китайцы совсем не в курсе, что строки однако уметь склеиватсо посредством оператора +, и исчо ж ведь есть и String.format. Поентому они создали свой, улучшенный, класс для сцепливания строк. Да в Sun совсем же ничиво не смыслят в етом деле:) Страшно представить функцию для присоединения скажем 50 строк.

cheap_chinese cheap_chinese, (Updated )

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

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

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
static {

		ruleNum10 = new HashMap();
		ruleNum10.put("0", "0");
		ruleNum10.put("1", "1");
		ruleNum10.put("2", "2");
		ruleNum10.put("3", "3");
		ruleNum10.put("4", "4");
		ruleNum10.put("5", "5");
		ruleNum10.put("6", "6");
		ruleNum10.put("7", "7");
		ruleNum10.put("8", "8");
		ruleNum10.put("9", "9");

		ruleNum16 = new HashMap();
		ruleNum16.put("0", "0");
		ruleNum16.put("1", "1");
		ruleNum16.put("2", "2");
		ruleNum16.put("3", "3");
		ruleNum16.put("4", "4");
		ruleNum16.put("5", "5");
		ruleNum16.put("6", "6");
		ruleNum16.put("7", "7");
		ruleNum16.put("8", "8");
		ruleNum16.put("9", "9");
		ruleNum16.put("10", "10");
		ruleNum16.put("11", "11");
		ruleNum16.put("12", "12");
		ruleNum16.put("13", "13");
		ruleNum16.put("14", "14");
		ruleNum16.put("15", "15");

	}

Очередной пример китайского героизма во владении копипейстом. Они похоже не знают о существовании цикла for и метода String.valueOf. А что если бы там было 200 елементов хотя бы?

cheap_chinese cheap_chinese, (Updated )

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

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

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
Лучший индусский способ определения текущего трехбуквенного обозначения месяца:

String currentMonth = ((String) monthMap.get(new Integer(today.getMonth()))).substring(0, 3);

где

monthMap:

Map monthMap=new HashMap();	
			
monthMap.put(new Integer(Calendar.JANUARY), Constants.JANUARY);
monthMap.put(new Integer(Calendar.FEBRUARY), Constants.FEBRUARY);
monthMap.put(new Integer(Calendar.MARCH), Constants.MARCH);

zavr zavr, (Updated )

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

Змея / Говнокод #1548 Ссылка на оригинал

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
def main():
  # define subscribe path and subscribers
  subscr=[]
  adrs=[]
  adrs.append("cav")
  sitem={'path':'test','adrs':adrs}
  subscr.append(sitem)

  # checking for correct usage
  changed= []
  if len(sys.argv)>1:
     ...
  else:
    mode="test"
    rev= "test.rev"
    rpath= "test.rpath"
    relpath= "test.relpath"
    webpath= "http:\\test.webpath\\"
    changed= ["test _h.c"]
 
  # search path of subscribe and collect dictionary of address and need files
  sends= {}
  for sitem in subscr:
    send= False
    files= []
    for file in changed:
      needfile= (file.find(sitem['path'])==0)
      send= send or needfile
      if needfile:
        files.append(file)
    if send:
      for adr in sitem['adrs']:
        if sends.has_key(adr):
          files.extend(sends[adr])
        sends.update({adr:files})
  
  #send emails
  for adr in sends.keys():
    #print "Found subscribe for:" + adr
    msg= message(rev,relpath,webpath,sends[adr])
    subj= "Commit rev." + rev + " on SVN server"
    if mode=='test':
      PrintMail(subj, msg, adr)
    else:
      SendMail(subj, msg, adr)

Безбашенная работа со словарями и списками

lolikandr lolikandr, (Updated )

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

Кресты / Говнокод #1547 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
__inline BOOL IsNumeric(LPTSTR lpsBuf)
{
 int i, nSize = _tcslen(lpsBuf);
 for (i = 0; i < nSize; i++)
  if ((lpsBuf[i] < _T('0')) || (lpsBuf[i] > _T('9')))
   return (FALSE);
 return (TRUE);
}

Серъёзный алгоритм.

Exhumer Exhumer, (Updated )

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

Няшная / Говнокод #1546 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
#define DBGLEVEL2 2
#define ER2 if (o.dbglvl>=DBGLEVEL2) fprintf(stderr,

some_fun(int errorcode) 
{
  ER2 " Error %d", errocode);
}

Использование незакрытых скобок внутри #define

lolikandr lolikandr, (Updated )

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

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

0

  1. 1
  2. 2
  3. 3
public void ejbPassivate() throws EJBException, RemoteException {
		return;
	}

Истинный китайский девелопер никогда не доверяет компилятору! Ато если ж в функции тело пустое, мало ли, вдруг она никогда не возвратиться. Какой выход? Написать об ентом явно.

cheap_chinese cheap_chinese, (Updated )

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