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

    +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
    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
    <?php
    	class Cache
    {
    		var $secret;
    		function create($timexpire, $data, $catalog="cache/"){
    			$filename = $catalog.$this->cache().".cache";
    			$data = "$timexpire\n$data";
    			$fo = fopen($filename, "w");
    			fwrite($fo, $data);
    			fclose($fo);
    		}
    		function read($catalog = "cache/"){
    			$filename = $catalog.$this->cache().".cache";
    			if(file_exists($filename)){
    				$content = file($filename);
    				if(trim($content[0]) < time()){
    					return 0;
    				}
    				unset($content[0]);
    				return ltrim(implode('', $content));
    			}
    			return 0;
    		}
    		function clean($catalog = "cache/"){
    			if($data = glob($catalog."*")){
    				foreach($data as $o){
    					if(is_dir($o)){
    						$this->clean($o);
    					}else{
    						unlink($o);
    					}
    				}
    			}
    			rmdir($catalog);
    		}
    		function cache(){
    				$filename = $_SERVER['REQUEST_URI'];
    				if(isset($_POST)){
    					$filename .= implode('',$_POST);
    				}
    				return md5($this->secret.$filename);
    		}
    }
    ?>

    Мой класс для кеширования.
    Писал давно.

    snet, 21 Сентября 2011

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

    +163

    1. 1
    2. 2
    3. 3
    if (is_null($var) === false) {
    // не важно что
    }

    Встретил такой код в примерах одного Merchant-сервиса.
    Вот что значит простое сделать сложным.

    darth_ixis, 21 Сентября 2011

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

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if ( $fldType[$i] == 10) { 
          eval("\$fldValue[\$i] = \$f_".$fld[$i].";");
        }
        else if ( $fldType[$i] != 6 )  {
          eval("\$fldValue[\$i] = trim((is_array(\$f_".$fld[$i].")?\$_FILES['f_".$fld[$i]."']['tmp_name']:stripslashes(\$f_".$fld[$i].")));");
        }
          
    		if ($fldType[$i]==8) {
    			eval("if (\$f_".$fld[$i]."_day || \$f_".$fld[$i]."_month || \$f_".$fld[$i]."_year || \$f_".$fld[$i]."_hours || \$f_".$fld[$i]."_minutes || \$f_".$fld[$i]."_seconds) \$fldValue[\$i] = sprintf(\"%04d-%02d-%02d %02d:%02d:%02d\",\$f_".$fld[$i]."_year,\$f_".$fld[$i]."_month,\$f_".$fld[$i]."_day,\$f_".$fld[$i]."_hours,\$f_".$fld[$i]."_minutes,\$f_".$fld[$i]."_seconds);");
    		}

    NetCat, я это даже прокомментировать не могу

    nex2hex, 20 Сентября 2011

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

    +166

    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
    <select name="ctrlCompareSearchFrame:lstDuration" id="ctrlCompareSearchFrame_lstDuration" class="inputStyle">
    			<option <?php save_dur(1);?>value="1">1 week</option>
    			<option <?php save_dur(2);?>value="2">2 weeks</option>
    			<option <?php save_dur(3);?>value="3">3 weeks</option>
    			<option <?php save_dur(4);?>value="4">4 weeks</option>
    			<option <?php save_dur(5);?>value="5">6 weeks</option>
    			<option <?php save_dur(6);?>value="6">2 months</option>
    			<option <?php save_dur(7);?>value="7">3 months</option>
    			<option <?php save_dur(8);?>value="8">4 months</option>
    			<option <?php save_dur(9);?>value="9">5 months</option>
    			<option <?php save_dur(10);?>value="10">6 months</option>
    			<option <?php save_dur(11);?>value="11">9 months</option>
    			<option <?php save_dur(12);?>value="12">12 months</option>
    		</select>

    "зачем мне цикл ,если платят за обьем кода" думал программер

    Rubaka, 20 Сентября 2011

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

    +164

    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
    function Parsing($raw)
    {
    
    	$RawProperty=array();
    	$Property=array();
    	$raw=str_ireplace("\n","",$raw);
    	$raw=str_replace("\r","<br/>",$raw);
    
    	preg_match_all("|<Policy>(.*)</Policy>|U",$raw,$RawProperty,PREG_OFFSET_CAPTURE);
    //print_r($RawProperty);
    	for ($k=0;$k<count($RawProperty[0]);$k++){
    
    		$Property[$k]['Insurer']=str_cut_btw_substrs("<InsurerLogoURL>","</InsurerLogoURL>",$RawProperty[0][$k][0]);
    		$Property[$k]['InsurerName']=str_cut_btw_substrs("<InsurerName>","</InsurerName>",$RawProperty[0][$k][0]);
    		$Property[$k]['Underwriter']=str_cut_btw_substrs("<UnderwriterName>","</UnderwriterName>",$RawProperty[0][$k][0]);
    		$Property[$k]['LinkURL']=str_cut_btw_substrs("<LinkURL>","</LinkURL>",$RawProperty[0][$k][0]);
    		$Property[$k]['Productname']=str_cut_btw_substrs("<ProductName>","</ProductName>",$RawProperty[0][$k][0]);
    		$Property[$k]['PremiumText']=str_cut_btw_substrs("<PremiumText>","</PremiumText>",$RawProperty[0][$k][0]);
    		$Property[$k]['PremiumEXText']=str_cut_btw_substrs("<PremiumEXText>","</PremiumEXText>",$RawProperty[0][$k][0]);
    		$Property[$k]['ExcessText']=str_cut_btw_substrs("<ExcessText>","</ExcessText>",$RawProperty[0][$k][0]);
    		$Property[$k]['LuggageText']=str_cut_btw_substrs("<LuggageText>","</LuggageText>",$RawProperty[0][$k][0]);
    		$Property[$k]['MedicalText']=str_cut_btw_substrs("<MedicalText>","</MedicalText>",$RawProperty[0][$k][0]);
    		$Property[$k]['CancelationText']=str_cut_btw_substrs("<CancelationText>","</CancelationText>",$RawProperty[0][$k][0]);
    		$Property[$k]['LiabilityText']=str_cut_btw_substrs("<LiabilityText>","</LiabilityText>",$RawProperty[0][$k][0]);
    		$Property[$k]['AdditionalFeatures']=str_cut_btw_substrs("<AdditionalFeatures>","</AdditionalFeatures>",$RawProperty[0][$k][0]);
    
    		//add fields "ExplanationText" and "IsShaded"
    		$Property[$k]['IsShaded']=str_cut_btw_substrs("<IsShaded>","</IsShaded>",$RawProperty[0][$k][0]);
    		$Property[$k]['ExplanationText']=str_cut_btw_substrs("<ExplanationText>","</ExplanationText>",$RawProperty[0][$k][0]);
    		$Property[$k]['IsBasicCover']=str_cut_btw_substrs("<IsBasicCover>","</IsBasicCover>",$RawProperty[0][$k][0]);
    		$Property[$k]['IsComprCover']=str_cut_btw_substrs("<IsComprCover>","</IsComprCover>",$RawProperty[0][$k][0]);
    
    								}
    	return $Property;
    }

    разбор xml ответа от сервера

    Rubaka, 20 Сентября 2011

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

    +178

    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
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    <?
    $g_menu=0;
    if(isset($_GET['A']))
     {
    	// это реализация ЧПУ - бля, работает...
       if($_GET['A']=='oi'){$i=1;}
        if($_GET['A']=='po'){$i=2;}
          if($_GET['A']=='pt'){$i=3;}
            if($_GET['A']=='ko'){$i=5;}
         if($_GET['A']=='sl'){$i=9;}
          if($_GET['A']=='ml'){$i=11;}
          if($_GET['A']=='pd'){$i=12;}
            if($_GET['A']=='da'){$i=13;}
            if($_GET['A']=='sa'){$i=14;}
            if($_GET['A']=='na'){$i=15;}
            if($_GET['A']=='da'){$i=16;}
            if($_GET['A']=='dn'){$i=17;}  
            if($_GET['A']=='dk'){$i=18;} 
            if($_GET['A']=='im'){$i=6;} 
          if($_GET['A']=='articles'){$i=19;}   
    	  if($_GET['A']=='du'){$i=20;}   
    	   if($_GET['A']=='dz'){$i=21;}  
    	   if($_GET['A']=='ii'){$i=22;}  
    	   if($_GET['A']=='dy'){$i=23;}
    	    if($_GET['A']=='ct'){$i=24;}
    	    if($_GET['A']=='ti'){$i=25;}  
      }
    else
    {
      if (!isset($_GET['i'])){$i=0;}
      else
      {
      $i=$_GET['i'];
      if($i!=1 && $i!=2 && $i!=3  && $i!=4 && $i!=5 && $i!=6 && $i!=7 && $i!=8 && $i!=9 && $i!=11 && $i!=12 && $i!=13 
      && $i!=14 && $i!=15 && $i!=16 && $i!=17 && $i!=18 && $i!=19 && $i!=20 && $i!=21 && $i!=22 && $i!=23 && $i!=24 && $i!=25    ){$i=0;}
      }
     }
    print"
    <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
    <html>
    <head>
    ";
    print"
    <META http-equiv=Content-Type content='text/html; charset=windows-1251'>
    ";
      if($i==1 || $i==0)
    {
    print"
    <title>xxx</title>
    <meta name=Description content='xxx'>
    <meta name=Keywords content='xxx'>
    ";
    }
     if($i==2)
    {
    print"
    <title>yyy</title>
    <meta name=Description content='yyy'>
    <meta name=Keywords content='yyy'>
    ";
    }
     if($i==3)
    {
    print"
    <title>zzz</title>
    <meta name=Description content='zzz'>
    <meta name=Keywords content='zzz'>
    ";
    } 
    // далее сокращу
    if($i==5)
    {
    print"...";
    }
     if($i==9)
    {
    print"...";
    }
     if($i==11)
    {
    print"...";
    }
     if($i==12)
    {
    print"...";
    }
    // много говна, числа иногда не по порядку: реализует титлы, кейвордс и дескрипшн
     if($i==25)
    {
    print"...";
    }
    //  внезапно
    if($i==7 || $i==8 || $i==3)
    {
    print"...";
    }
    /* дальше хтмл-говно со вставками типа: <? if($g_menu==1) { print"блок хтмл-говна"; } ?> */

    Открыл я значит исходники одного сайта...

    deep, 20 Сентября 2011

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

    +170

    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
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    $email = strip_tags($email);
    $email = str_replace("’", "", $email);
    $email = str_replace("(", "", $email);
    $email = str_replace(")", "", $email);
    $email = str_replace(";", "", $email);
    $email = str_replace(":", "", $email);
    $email = str_replace("<", "", $email);
    $email = str_replace("'", "", $email);
    $email = str_replace("UNION", "", $email);
    $email = str_replace("SELECT", "", $email);
    $email = str_replace("WHERE", "", $email);
    $email = str_replace("LIKE", "", $email);
    $email = str_replace("FROM”", "", $email);
    $email = str_replace("UPDATE", "", $email);
    $email = str_replace("INSERT", "", $email);
    $email = str_replace("ORDER", "", $email);
    $email = str_replace("GROUP", "", $email);
    $email = str_replace("ALTER", "", $email);
    $email = str_replace(" OR ", "", $email);
    $email = str_replace(" or ", "", $email);
    $email = str_replace("=", "", $email);
    
    $email1 = str_replace("’", "", $email1);
    $email1 = str_replace("(", "", $email1);
    $email1 = str_replace(")", "", $email1);
    $email1 = str_replace(";", "", $email1);
    $email1 = str_replace(":", "", $email1);
    $email1 = str_replace("<", "", $email1);
    $email1 = str_replace("'", "", $email1);
    $email1 = str_replace("UNION", "", $email1);
    $email1 = str_replace("SELECT", "", $email1);
    $email1 = str_replace("WHERE", "", $email1);
    $email1 = str_replace("LIKE", "", $email1);
    $email1 = str_replace("FROM”", "", $email1);
    $email1 = str_replace("UPDATE", "", $email1);
    $email1 = str_replace("INSERT", "", $email1);
    $email1 = str_replace("ORDER", "", $email1);
    $email1 = str_replace("GROUP", "", $email1);
    $email1 = str_replace("ALTER", "", $email1);
    $email1 = str_replace(" OR ", "", $email1);
    $email1 = str_replace(" or ", "", $email1);
    $email1 = str_replace("=", "", $email1);
    
    $location = str_replace("’", "", $location);
    $location = str_replace("(", "", $location);
    $location = str_replace(")", "", $location);
    $location = str_replace(";", "", $location);
    $location = str_replace(":", "", $location);
    $location = str_replace("<", "", $location);
    $location = str_replace("'", "", $location);
    $location = str_replace("UNION", "", $location);
    $location = str_replace("SELECT", "", $location);
    $location = str_replace("WHERE", "", $location);
    $location = str_replace("LIKE", "", $location);
    $location = str_replace("FROM”", "", $location);
    $location = str_replace("UPDATE", "", $location);
    $location = str_replace("INSERT", "", $location);
    $location = str_replace("ORDER", "", $location);
    $location = str_replace("GROUP", "", $location);
    $location = str_replace("ALTER", "", $location);
    $location = str_replace(" OR ", "", $location);
    $location = str_replace(" or ", "", $location);
    $location = str_replace("=", "", $location);
    
    $cinsiyet = str_replace("’", "", $cinsiyet);
    $cinsiyet = str_replace("(", "", $cinsiyet);
    $cinsiyet = str_replace(")", "", $cinsiyet);
    $cinsiyet = str_replace(";", "", $cinsiyet);
    $cinsiyet = str_replace(":", "", $cinsiyet);
    $cinsiyet = str_replace("<", "", $cinsiyet);
    $cinsiyet = str_replace("'", "", $cinsiyet);
    $cinsiyet = str_replace("UNION", "", $cinsiyet);
    $cinsiyet = str_replace("SELECT", "", $cinsiyet);
    $cinsiyet = str_replace("WHERE", "", $cinsiyet);
    $cinsiyet = str_replace("LIKE", "", $cinsiyet);
    $cinsiyet = str_replace("FROM”", "", $cinsiyet);
    $cinsiyet = str_replace("UPDATE", "", $cinsiyet);
    $cinsiyet = str_replace("INSERT", "", $cinsiyet);
    $cinsiyet = str_replace("ORDER", "", $cinsiyet);
    $cinsiyet = str_replace("GROUP", "", $cinsiyet);
    $cinsiyet = str_replace("ALTER", "", $cinsiyet);
    $cinsiyet = str_replace(" OR ", "", $cinsiyet);
    $cinsiyet = str_replace(" or ", "", $cinsiyet);
    $cinsiyet = str_replace("=", "", $cinsiyet);

    Большой проект. Часть переменных на турецком. Смесь из php с html. Файлы проекта сохранены в разных кодировках. Mysql конфиги иногда подключаются include'ом, иногда прямо в текущем файле.

    zorbis, 20 Сентября 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if($total>1) {
        Error_Reporting(E_ALL & ~E_NOTICE);
        echo "<tr><td colspan='4'><div align='center'> <br />";
        echo $pervpage.$page5left.$page4left.$page3left.$page2left.$page1left.'<b>'.$p.'</b>'.$page1right.$page2right.$page3right.$page4right.$page5right.$nextpage;
        echo "</div></tr></td>";
    }

    И это все к конце скрипта

    cephuo, 19 Сентября 2011

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

    +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
    <?php
    
    error_reporting(E_ALL);
    
    require_once '../app/config.php';
    require_once systemConfig::$pathToSystem . '/index.php';
    require_once '../app/application.php';
    
    $application = new application();
    $application->run();
    
    ?>

    http://code.google.com/p/govnokod/source/browse/trunk/govnoquoter/www/index.php
    Шел 2011-й год...

    alexoy, 18 Сентября 2011

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

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <tr>
            <?php if (cmsCountModules("left")) { ?>
               <td><?php cmsModule("left"); ?></td>
            <?php } ?>
           <?php if (cmsCountModules("top")) { ?>
               <td><?php cmsModule("top"); ?></td>
           <?php } ?>    
           <?php if (cmsCountModules("right")) { ?>
               <td><?php cmsModule("right"); ?></td>
           <?php } ?>
         </tr>

    Здравствуй ГК!
    Сегодня я печалюсь про похапэ.

    da4ever, 18 Сентября 2011

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