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

    +153

    1. 1
    break; break; break; // PLEASE, BREAK!!!!!!

    guest, 28 Июня 2009

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

    +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
    function splitString($inS)
     {
      $k = strlen($inS);
      $res = array();
      for($i=0;$i<$k;$i++)
       {
        $res[$i] = $inS{$i};
       };
      return($res);
     };
    
    function toTranslit($text)
     {
      $outS = '';
      $data = splitString(trim($text,' -_')); //str_split($text);
      foreach($data as $ch)
       {
        switch($ch)
         {
          case 'А' : $rc = 'a'; break;
          case 'Б' : $rc = 'b'; break;
          case 'В' : $rc = 'v'; break;
    //тут очень, очень много букафф... все какие есть...
          case '8' : $rc = '8'; break;
          case '9' : $rc = '9'; break;
          case '0' : $rc = '0'; break;
          case '-' : $rc = '-'; break;
          case '_' : $rc = '_'; break;
          case ' ' : $rc = '-'; break;
          default : $rc = '';
         };
        $outS .= $rc;
       };
      $outS = str_replace('_','-',$outS);
      while(strpos('--',$outS)) { $outS = str_replace('--','-',$outS); };
      return($outS);
     };

    ещё из просеивания, пара функций преобразующая введённую пользователем строчку в транслит
    уходит корнями в 2002й год -- продержалась в ядре CMS-ки аж 7 лет, исправно при этом работая.
    ...и ведь опять я сам писал, заразу...

    guest, 27 Июня 2009

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

    +144.1

    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
    <?php
    //много кода
      if(($ln > 0) && ($ln <= $limit))
    //обработка строчки $ln
       } elseif($ln < 1) {
        echo("Нельзя вводить пустую строку!<BR>\n");
       } elseif($ln > $limit) {
        echo("Вы ввели слишком много<BR>\n");
       } else {
        echo("Невыясненный облом<BR>\n");
       };
    //дальше много кода
    ?>

    при апе major версии нашей CMS контролирую тщательное просеивание старого кода.
    иногда находятся такие хохмочки...
    ...эту я сам писал, лет уже не помню сколько назад, она уже 3 версии зараза пережила... только сейчас заметил.

    guest, 27 Июня 2009

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

    +134

    1. 1
    фак

    Бугагга

    guest, 27 Июня 2009

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if ($quantity >=2) {
        $bid = print_money($row["bid"]*$quantity);
    } else {
        $bid = print_money($row["bid"]);
    }

    Из одного индусского проэкта.
    Они боятся умножать на 1.

    guest, 27 Июня 2009

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

    +146

    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
    <?php
    
    class db {
    
    function db_conn ($host,$user,$pass,$db) {
    	if(!($this->link = @mysqli_connect($host,$user,$pass)))
    		{
    		echo "<font color=\"red\">Error:</font> connect to host: $host";
    		//exit();
    		}
    	if(!mysqli_select_db($this->link,$db))
    		{
    		echo "<font color=\"red\">Error:</font> select database $db";
    		exit();
    		}
    	return $this->link;
    	}
    
    function sql_query ($query) {
    	
    	$result = mysqli_query($this->link, $query);
    		if (!$result)
    			{
    			$this->error_msg = mysqli_error ($result);
    			return $this->error_msg;
    			}
    	return $result;
    	}
    
    function sql_fetch_assoc ($query) {
    		$res=$this->sql_query($query);
    		//$array = array();
    		$row = mysqli_fetch_array($res);
    		mysqli_free_result($res);
    		return $row;
    	}
    }
    
    ?>

    guest, 26 Июня 2009

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

    +148

    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
    <?php
    
    class db {
    
    function db_conn ($host,$user,$pass,$db) {
    	if((!$this->link = @mysqli_connect($host,$user,$pass)))
    		{
    		echo "<font color=\"red\">Error:</font> connect to host: $host";
    		exit();
    		}
    	if(!mysqli_select_db($this->link,$db))
    		{
    		echo "<font color=\"red\">Error:</font> select database $db";
    		exit();
    		}
    	}
    
    function sql_query ($query) {
    	$this->link = mysqli_query($this->link, $query);
    		if (!$this->link)
    			{
    			$this->error_msg = mysqli_error ($this->link);
    			return $this->error_msg;
    			}
    	return $this->link;
    	}
    
    function sql_fetch_assoc ($query) {
    		$res=$this->sql_query($query);
    		$array = array();
    		$row = mysqli_fetch_array($res);
    			/*{
    			$array[]=$cur;
    			}*/
    		mysqli_free_result($res);
    		return $row;
    	}
    }
    
    ?>

    guest, 26 Июня 2009

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?
        $sess_del ="NEWCONTENT";
        $sd_flag  =base64_encode($sess_del);
    ?>
    <td width="127"><a href="createeflyer.php?s_flag=<?=$sd_flag?>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','images/navig-ovr_12.jpg',1)"><img src="<?=$imagesrc2?>" alt="createflyer" name="Image12" width="127" height="39" border="0" id="Image12" /></a></td>

    Продолжение индийского эпоса (#1244-#1245, #1248-#1251)

    -Назовем это "Операция Ы"!
    -Почему "Ы"?
    -Чтобы никто не догадался

    guest, 26 Июня 2009

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

    +61.5

    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
    global $scan, $scan1, $scan2, $pri1, $pri2, $host, $i1, $hits;
    global $server1, $server2;
    global $item;
    global $use_1, $term_1, $trun1, $bop_1;
    global $use_2, $term_2, $trun2, $bop_2;
    global $use_3, $term_3, $trun3, $bop_3;
    global $use_4, $term_4, $trun4, $bop_4;
    global $use_5, $term_5, $trun5, $bop_5;
    $ver1=ord(substr(phpversion(),0,1))-48;
    $ver2=ord(substr(phpversion(),2,1))-48;
    $ver=$ver1*10+$ver2;
    #echo $ver;
    if ($ver>42)extract($_REQUEST);
    if ($format == "1.2.840.10003.5.109.10") {
    	$pri2=1;
    	$pri1=1;
    	$pxml=0;
    }
     
    if (($scan==tounicode("список"))||($scan1==tounicode("список"))||($scan2==tounicode("список")))
       {
            if (strlen($term_2)>0)
                 {
                    $term_1=$term_2;
                    $use_1=$use_2;
                 }
            if (strlen($term_3)>0)
                 {
                    $term_1=$term_3;
                    $use_1=$use_3;
                 }
            include("func.php");
            $target=$host[0];
            $field1="@attr 1=" . $use_1;
            $term1=$term_1;
            if (strlen($term1)==0)
    /*            {
                  echo "<title>z39.50</title><BODY bgcolor=FFFFE6 TEXT=000000 LINK=brown VLINK=brown topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><center><table width=70% border=1 cellpadding=25 cellspacing=0><td valign=top><font face='arial,helvetica' size=6 color=#333333>Шлюз Z39.50</font><hr><font color=brown><p><b>Для просмотра списка введите, пожалуйста, первую букву поискового терма<p><br><a href='javascript:history.back()'><img src=back.gif border=0></A></td></table>";
                  exit;
                }  */
                  {
                    $term_1='0';
                    $term1=$term_1;
                  }
            $syntax="RUSMarc";
            $element="F";
            $number=15;
    ?>

    guest, 25 Июня 2009

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

    +139.8

    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
    unction int2hex($intega){
       $Ziffer = "0123456789ABCDEF";
    return $Ziffer[($intega%256)/16].$Ziffer[$intega%16];
    }
    
    function url_encode($text){
       $text = urlencode($text);
       if(!strpos($text,"%C3"))
           for($i=129;$i<255;$i++){
               $in = "%".int2hex($i);
               $out = "%C3%".int2hex($i-64);
               $text = str_replace($in,$out,$text);
           }
    return $text;
    }
    
    function tounicode ($string){
    $unistring="";
    for($i=0;$i<strlen($string);$i++){
    	$current=$string[$i];
    	$codcurrent=ord($current);
    	if($codcurrent>255):
           		$unicurrent=utf8_encode($current);
    		$unistring=$unistring.$unicurrent;
    	elseif($codcurrent<192):
    		if($codcurrent==184):
                           $unicurrent=chr(209).chr($codcurrent-39);
                           $unistring=$unistring.$unicurrent;
    		elseif($codcurrent==168):
                           $unicurrent=chr(208).chr($codcurrent-39);
                           $unistring=$unistring.$unicurrent;
    		elseif($codcurrent==147):
    				$unicurrent=utf8_encode("\"");
                            $unistring=$unistring.$unicurrent;
    		elseif($codcurrent==148):
    				$unicurrent=utf8_encode("\"");
                            $unistring=$unistring.$unicurrent;
    		elseif($codcurrent==151):
    				$unicurrent=utf8_encode("-");
                            $unistring=$unistring.$unicurrent;
    		
    		else:
                  		$unicurrent=utf8_encode($current);
                   		$unistring=$unistring.$unicurrent;
    		endif;
    	
    	else:
    		if ($codcurrent<240):
    			$unicurrent=chr(208).chr($codcurrent-48);
    			$unistring=$unistring.$unicurrent;
    		else:
    			$unicurrent=chr(209).chr($codcurrent-112);
    			$unistring=$unistring.$unicurrent;
    		endif;
    		
    	endif;
    }
    return $unistring;
    }

    guest, 25 Июня 2009

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