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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    $str="'".trim(iconv("cp866","UTF-8",$row['P_NOMER']))."','".trim(iconv("cp866","UTF-8",$row['P_DATA']))."','".trim(iconv("cp866","UTF-8",$row['V_NOMER']))."','".trim(iconv("cp866","UTF-8",$row['V_DATA']))."','".trim(iconv("cp866","UTF-8",$row['PL_NOMER']))."','".trim(iconv("cp866","UTF-8",$row['PL_DATA']))."',".$row['PL_SUMMA'].",'".trim(iconv("cp866","UTF-8",$row['SODER']))."','".trim(iconv("cp866","UTF-8",$row['NA_SOGL']))."','".trim(iconv("cp866","UTF-8",$row['N_RAY']))."','".trim(iconv("cp866","UTF-8",$row['KOD_PRED']))."','".trim(iconv("cp866","UTF-8",$row['NAME_1']))."','".trim(iconv("cp866","UTF-8",$row['TIP_TY']))."','".trim(iconv("cp866","UTF-8",$row['KOD_TY']))."','".trim(iconv("cp866","UTF-8",$row['REG_PRIM']))."',".$row['P_NAG_1'].",'".trim(iconv("cp866","UTF-8",$row['DATA_REG']))."','".trim(iconv("cp866","UTF-8",$row['NOMER_REG']))."','".trim(iconv("cp866","UTF-8",$row['NOMER_TY']))."','".trim(iconv("cp866","UTF-8",$row['GOD_TY']))."',".$row['G_M'].",'".trim(iconv("cp866","UTF-8",$row['INN']))."',".$row['KOD_SPRIP1'].",".$row['KOD_SPRIP2'].",".$row['KOD_SPRIP3'].",'".trim(iconv("cp866","UTF-8",$row['PL_NOMER2']))."','".trim(iconv("cp866","UTF-8",$row['PL_DATA2']))."',".$row['PL_SUMMA2'].",'".trim(iconv("cp866","UTF-8",$row['PL_NOMER3']))."','".trim(iconv("cp866","UTF-8",$row['PL_DATA3']))."',".$row['PL_SUMMA3'].",'".trim(iconv("cp866","UTF-8",$row['USER_PF']))."','".trim(iconv("cp866","UTF-8",$row['N_TIP']))."','".trim(iconv("cp866","UTF-8",$row['N_USEL']))."','".trim(iconv("cp866","UTF-8",$row['EDIN_TY']))."','".trim(iconv("cp866","UTF-8",$row['IST_EL']))."','".trim(iconv("cp866","UTF-8",$row['NAME_2']))."',"; 
    ...
    ...
    $sql="INSERT INTO table (p_nomer,p_data,v_nomer,v_data,pl_nomer,pl_data,pl_summa,soder,na_sogl,n_ray,kod_pred,name_1,tip_ty,kod_ty,reg_prim,p_nag_1,data_reg,nomer_reg,nomer_ty,god_ty,g_m,inn,kod_sprip1,kod_sprip2,kod_sprip3,pl_nomer2,pl_data2,pl_summa2,pl_nomer3,pl_data3,pl_summa3,user_pf,n_tip,n_usel,edin_ty,ist_el,name_2,) VALUES ('".trim(iconv("cp866","UTF-8",$row['P_NOMER']))."','".trim(iconv("cp866","UTF-8",$row['P_DATA']))."','".trim(iconv("cp866","UTF-8",$row['V_NOMER']))."','".trim(iconv("cp866","UTF-8",$row['V_DATA']))."','".trim(iconv("cp866","UTF-8",$row['PL_NOMER']))."','".trim(iconv("cp866","UTF-8",$row['PL_DATA']))."',".$row['PL_SUMMA'].",'".trim(iconv("cp866","UTF-8",$row['SODER']))."','".trim(iconv("cp866","UTF-8",$row['NA_SOGL']))."','".trim(iconv("cp866","UTF-8",$row['N_RAY']))."','".trim(iconv("cp866","UTF-8",$row['KOD_PRED']))."','".trim(iconv("cp866","UTF-8",$row['NAME_1']))."','".trim(iconv("cp866","UTF-8",$row['TIP_TY']))."','".trim(iconv("cp866","UTF-8",$row['KOD_TY']))."','".trim(iconv("cp866","UTF-8",$row['REG_PRIM']))."',".$row['P_NAG_1'].",'".trim(iconv("cp866","UTF-8",$row['DATA_REG']))."','".trim(iconv("cp866","UTF-8",$row['NOMER_REG']))."','".trim(iconv("cp866","UTF-8",$row['NOMER_TY']))."','".trim(iconv("cp866","UTF-8",$row['GOD_TY']))."',".$row['G_M'].",'".trim(iconv("cp866","UTF-8",$row['INN']))."',".$row['KOD_SPRIP1'].",".$row['KOD_SPRIP2'].",".$row['KOD_SPRIP3'].",'".trim(iconv("cp866","UTF-8",$row['PL_NOMER2']))."','".trim(iconv("cp866","UTF-8",$row['PL_DATA2']))."',".$row['PL_SUMMA2'].",'".trim(iconv("cp866","UTF-8",$row['PL_NOMER3']))."','".trim(iconv("cp866","UTF-8",$row['PL_DATA3']))."',".$row['PL_SUMMA3'].",'".trim(iconv("cp866","UTF-8",$row['USER_PF']))."','".trim(iconv("cp866","UTF-8",$row['N_TIP']))."','".trim(iconv("cp866","UTF-8",$row['N_USEL']))."','".trim(iconv("cp866","UTF-8",$row['EDIN_TY']))."','".trim(iconv("cp866","UTF-8",$row['IST_EL']))."','".trim(iconv("cp866","UTF-8",$row['NAME_2']))."',)"; //запрос

    это часть кода для импорта данных из dbf

    crs, 03 Марта 2011

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

    +158

    1. 1
    2. 2
    3. 3
    function sqlemptydate($test) {
      return (!$test || ($test == '0000-00-00') || ($test == '0000-00-00 00:00:00'));
    }

    ilyamx, 03 Марта 2011

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

    +160

    1. 1
    $VAR['server'] = trim(str_replace("www.","",strtolower($_SERVER['SERVER_NAME'])));

    Угадайте что этот код должен делать, и что он делает на самом деле. Да, это ужас. Это один из многих ужасов, доставшихся мне от предыдущего программиста. До этого самым большим был explode имени файла через точку и подставление второго элемента как расширение.

    BiSe_Trojanov, 02 Марта 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ($type=='input') $params['class'] = 'styleInput';
    if ($type=='password') $params['class'] = 'stylePassword';
    if ($type=='checkbox') $params['class'] = 'styleCheckBox';
    if ($type=='select') $params['class'] = 'styleSelect';
    if ($type=='multipleSelect') $params['class'] = 'styleMultipleSelect';
    if ($type=='textarea') $params['class'] = 'styleTextarea';
    if ($type=='groupSelect') $params['class'] = 'styleGroupSelect';

    Конкатенация - враг! Учитесь трудолюбию!

    ifeya, 02 Марта 2011

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

    +169

    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
    <?php
    	exit
    	(
    		empty($_POST['key']) ||
    		empty($_POST['time']) ||
    		empty($_POST['email']) ||
    		(int)$_POST['time'] != $_POST['time'] ||
    		strlen((int)$_POST['time']) != strlen($_POST['time']) ||
    		!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $_POST['email']) ||
    		($_SERVER['REQUEST_TIME'] - $_POST['time']) > 60 * 60 ||
    		md5(str_rot13(md5($_POST['time']))) != $_POST['key']
    		?'-':'+'
    	);
    ?>

    Вот Ajax ответ

    wyand, 02 Марта 2011

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

    +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
    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
    $url=$_SERVER['REQUEST_URI'];
    $url9=substr($url,0,9);
    $url8=substr($url,0,8);
    $url14=substr($url,0,14);
    $url10=substr($url,0,10);
    $url5=substr($url,0,5);
    if ($url9=='/calendar') {
    printf('<!-- (C)2000-2010 Gemius SA - gemiusAudience / sitecom / Calendar -->
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    var pp_gemius_identifier = new String(\'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\');
    //--><!]]>
    </script>
    <script type="text/javascript" src=" http://site.com/gemius/xgemius.js"></script>');
    }elseif ($url8=='/content'){
    printf('<!-- (C)2000-2010 Gemius SA - gemiusAudience / sitecom / Content -->
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    var pp_gemius_identifier = new String(\'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\');
    //--><!]]>
    </script>
    <script type="text/javascript" src=" http://site.com/gemius/xgemius.js"></script>');
    }
    elseif ($url14=='/forum_arch'){
    printf('<!-- (C)2000-2010 Gemius SA - gemiusAudience / sitecom / Forum archiv -->
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    var pp_gemius_identifier = new String(\'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\');
    //--><!]]>
    </script>
    <script type="text/javascript" src=" http://site.com/gemius/xgemius.js"></script>');
    }
    elseif ($url10=='/forum/'){
    printf('<!-- (C)2000-2010 Gemius SA - gemiusAudience / sitecom / Forum pages -->
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    var pp_gemius_identifier = new String(\'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\');
    //--><!]]>
    </script>
    <script type="text/javascript" src=" http://site.com/gemius/xgemius.js"></script>');
    }
    elseif ($url5=='/news'){
    printf('<!-- (C)2000-2010 Gemius SA - gemiusAudience / sitecom / News -->
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    var pp_gemius_identifier = new String(\'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\');
    //--><!]]>
    </script>
    <script type="text/javascript" src=" http://site.com/gemius/xgemius.js"></script>');
    }
    else {
    printf('<!-- (C)2000-2010 Gemius SA - gemiusAudience / sitecom / Glavnaja stranitsa sajta -->
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    var pp_gemius_identifier = new String(\'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\');
    //--><!]]>
    </script>
    <script type="text/javascript" src=" http://site.com/gemius/xgemius.js"></script>');
    }

    Вместо xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx в коде оригинальные id счетчиков. Это всё чудо лежит в базе и выполняется через eval()

    nergalic, 01 Марта 2011

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

    +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
    function _getConditionWithCategoryConj( $condition, $categoryID ) //fetch products from current category
    {
      $category_condition = "";
      $q = db_query("select productID from ".
                CATEGORIY_PRODUCT_TABLE." where categoryID=".(int)$categoryID);
      $icounter = 0;
      while( $product = db_fetch_row( $q ) )
      {
        if ( $icounter == 0 )
          $category_condition .= " productID IN ('";
        if ( $icounter > 0 )
          $category_condition .= ", ";
        $category_condition .= (int)$product[0];
        $icounter++;
      }
      if ( $icounter>0 ) {
        $category_condition .= "')";
      }

    shopcms.
    нет слов больше.

    zealotous, 01 Марта 2011

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

    +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
    <?
    function FindTag($Tag,$Page,$Offset=0) // Ищет тег $Tag в странице $Page от символа с номером $Offset
    {
    	$Tag=strtoupper($Tag);
    	$Page=strtoupper($Page);
    	$Pos=array(0,0,0,0);
    	$Pos[0]=StrPos($Page,'<'.$Tag,$Offset);
    	
    	if ($Pos[0]<$Offset) {return False;}
    	
    	if ((Empty($Pos[0])==True)and(SubStr($Page,0,StrLen('<'.$Tag))!='<'.$Tag)) {return False;}
    	$Pos[1]=StrPos($Page,'>',$Pos[0]);
    	
    	if (Empty($Pos[1])==False) {$Pos[1]=$Pos[1]+1;} else {return False;}
    	$Pos[2]=StrPos($Page,'</'.$Tag.'>',$Pos[1]);
    	$Pos[3]=$Pos[2]+StrLen('</'.$Tag.'>');
    	if ((SubStr($Page,$Pos[0]+StrLen('<'.$Tag),1)!=' ')and(SubStr($Page,$Pos[0]+StrLen('<'.$Tag),1)!='>')) {$Pos=FindTag($Tag,$Page,$Pos[1]);}
    	if ((Empty($Pos[1])==False)and($Pos[0]<$Pos[1])) {return $Pos;} else {return False;}
    }
    ?>

    Вот такой пример поиска тегов я нашел по поисковику, автор этих строк явно не знаком с регулярными выражениями...

    Android991, 01 Марта 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    /*	Адаптация под оперу	*/
    if ( stristr($_SERVER['HTTP_USER_AGENT'], 'Opera') )
    	echo "<input type=hidden value='file_ok' name='action'><br><input type=\"image\" src=\"".$url."images/buttons/button_file_ok.png\">";
    else 
    	echo "<br><input type=\"image\" src=\"".$url."images/buttons/button_file_ok.png\" value=\"file_ok\" name=\"action\">";

    особый говнокод для Оперы
    http://my.opera.com/russian/forums/topic.dml?id=918821

    xxx, 28 Февраля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
     $Options = file("OPTIONS.txt");
     foreach ($Options as $opt)
            {
            $opt = trim($opt);
            eval("$".$opt.";");
            }

    qbasic, 28 Февраля 2011

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