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

    +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
    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
    <?
    if( !defined("ADMIN") ) die("Access denied.");
    
    // Получение новых сообщений
    mysql_query('SET NAMES cp1251'); // Чертовы костыли!
    if($messages_count_new>0) {
        $sql = "SELECT * FROM " .PREFIX. "_messages WHERE to_uid = $manager_id AND is_read = 0";
        $result = mysql_query($sql);
        $messages_new = array();
        while ($row = mysql_fetch_assoc($result)) {
            $messages_new[] = $row;
        }    
    }
    // Получение прочитанных сообщений
    $sql = "SELECT * FROM " .PREFIX. "_messages WHERE to_uid = $manager_id AND is_read = 1";
    $result = mysql_query($sql);
    $messages_read = array();
    while ($row = mysql_fetch_assoc($result)) {
        $messages_read[] = $row;
    }
    
    $OUT .= '
    <table>
    <tr><td><h1>Внутренняя почта</h1></td></tr>';
    if(count($messages_new) > 0 OR count($messages_read) > 0):       
        if(count($messages_new) > 0):
            $OUT .= '<tr><td><h2>У вас '.count($messages_new).' новых сообщений</h2></td></tr>        
            <tr><tr>
            <table class="messages_list" width="100%">                  
                <tr><th>Дата</th><th>Тема</th></tr>';
                foreach($messages_new as $key=>$item):
                    $OUT .= '<tr>
                        <td class="date" width=20%">'.date('Y-m-d H:i', $item['created_date']).'</td>
                        <td class="subject"><a href="index.php?page=readmessage&id='.$item['id'].'">'.htmlspecialchars($item['subject']).'</a></td>
                    </tr>';
                endforeach;
            $OUT .= '</td></tr></table>';          
            
        endif;
        if(count($messages_read) > 0):
            $OUT .= '<tr><td><h2>У вас '.count($messages_new).' прочитанных сообщений</h2></td></tr>
            <tr><tr>
            <table class="messages_list" width="100%">                  
                <tr><th>Дата</th><th>Тема</th></tr>';
                foreach($messages_read as $key=>$item):
                $OUT .= '<tr>
                        <td class="date" width=20%">'.date('Y-m-d H:i', $item['created_date']).'</td>
                        <td class="subject"><a href="index.php?page=readmessage&id='.$item['id'].'">'.htmlspecialchars($item['subject']).'</a></td>
                    </tr>';
                endforeach;
            $OUT .= '</td></tr></table>';        
                  
        endif;
    else:
        $OUT .= '<tr><td>У вас нет сообщений</tr></td></table>';
    endif;

    :((((

    azzz, 14 Января 2010

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

    +162.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
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    <?
    /* Для spaw нужно */
      $spaw_root = dirname(__FILE__) . "/spaw/";
      include $spaw_root . 'spaw_control.class.php';
    
      /* Проверка на существование раздела */
      if (count($glb_page->prop))
      {
        load_lib("pw_mod");
        $glb_page->main_out = run_action($glb_page->prop['id_act'],1);
    
        // подключение шаблона
        if (isset($_GET['pw_patt']))  $glb_page->prop['templ'] = $_GET['pw_patt'];
        if (isset($_POST['pw_patt'])) $glb_page->prop['templ'] = $_POST['pw_patt'];
        if (isset($_REQUEST['pw_patt'])) $glb_page->prop['templ'] = $_REQUEST['pw_patt'];
    
        include(pw_Path_templ . $glb_page->prop['templ'] . ".php");
      }
      else
      {
        echo "Раздел не найден";
      }
    ?>

    xXx_totalwar, 14 Января 2010

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

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    switch($_GET['act'])
    {
    	default: break;
    	case 'manageusers':
    		{
    			///......
    		    break;
    		}
    		
    	default:
    	{
    		/// .......

    обнаружил щаз в своем коде 2 месячной давности.....

    nolka4, 14 Января 2010

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

    +180.2

    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
    <?
    include ("config.php");
    srand((double)microtime()*1000000); 
    $randomnumber = rand(0,$howmany);
    if ($randomnumber== "0") {
    include ("ads/ad1.php");
    }
    if ($randomnumber== "1") {
    include ("ads/ad2.php");
    }
    if ($randomnumber== "2") {
    include ("ads/ad3.php");
    }
    /*
      И ТАК ДАЛЕЕ - ПРИМ.АВТ.
    */
    if ($randomnumber== "24") {
    include ("ads/ad25.inc");
    }
    ?>

    Мы уже четвертые разработчики проекта на osCommerce (по умолчанию говнокод, а поскольку мы уже четвертые - вы представьте, что там понаписывали!). Встретил ЭТО.

    elite.sidewinder, 12 Января 2010

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

    +162.5

    1. 1
    2. 2
    $require = 'email|name|phone';
    foreach (explode('|', $required) as $field)

    найдено при рефакторинге

    Stormherz, 12 Января 2010

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

    +153.2

    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
    <?php
    // ---SpyLib---
    function connectToSpy(){
    global $serverName, $userName, $password, $dbName;
    $dbConn = MYSQL_CONNECT($serverName, $userName, $password) OR DIE("Не могу создать соединение ");
    $select=mysql_select_db("$dbName", $dbConn) or die("Не могу выбрать базу данных"); 
    return $dbConn;
    }
    
    function autentID($login, $psw){
    global $dbConn; 
    $query = "SELECT clientsID FROM clients WHERE login='$login' AND psw_md5='$psw'";
    $clientsID = qToTableText($query);
    $_SESSION['lgn']=$login;// регистрируем переменную lgn
    $_SESSION['pswd']=$psw; // регистрируем переменную pswd
    return $clientsID;
    }  
    
    /* выводит инфу из таблицы */				
    function qToTableText($query){
    global $dbConn;
    $output .= "";
    $result = MYSQL_QUERY($query, $dbConn);
    //получить данные строк и сохранить в ассоциативный массив
    while ($row = mysql_fetch_assoc($result)){
    			//просмотреть каждое поле 
    	foreach ($row as $col=>$val){
    		$output .=  "$val";
    	} // завершение цикла foreach
    } // завершение цикла while 
    return $output;
    }
    
    /* по заданному названию таблицы генерирует таблицу HTML, содержащую кнопки добавления, удаления и редактирования */
    function tToEdit($tableName){
    global $dbConn;
    $output="";
    $query="SELECT * FROM `$tableName`";
    $result=mysql_query($query, $dbConn);
    while ($row = mysql_fetch_assoc($result)){
    	$fieldNum=0;
    	foreach($row as $col=>$val){
    		if ($fieldNum=='1'){
    			$field=$col;
    		}//if
    		$fieldNum++;
    	}//foreach
    }//while
    //$query="SELECT * FROM `$tableName` ORDER BY '$field'";
    $query="SELECT * FROM `$tableName` ORDER BY name ASC";
    $result=mysql_query($query, $dbConn);
    $output .="<tr  class='title'>\n";
    $th=0;// считаем количество столбцов
    while ($field = mysql_fetch_field($result)){
    	// если столбец->пирвичный ключ то он уберается
    	if (!$field->primary_key==1){
    		$a=array(
    		"text"=>"Информация","name"=>"Название","cena"=>"Стоимость, руб","bl1"=>"Блюдо 1","bl1_ves"=>"Вес",
    		"bl1_text"=>"Описание",	"bl2"=>"Блюдо 2","bl2_ves"=>"Вес","bl2_text"=>"Описание","bl3"=>"Блюдо 3",
    		"bl3_ves"=>"Вес","bl3_text"=>"Описание","bl4"=>"Блюдо 4","bl4_ves"=>"Вес","bl4_text"=>"Описание",
    		"v_menu"=>"в меню","v_mon"=>"в пон.","v_twu"=>"во вт.","v_wen"=>"в ср.","v_thu"=>"в чет.",
    		"v_fri"=>"в пят.","v_sa"=>"в суб.","date"=>"Дата",);
    		$rename=$a["$field->name"];
    		$output .="<th>$rename</th>\n";
    	}
    	$th++;
    }// заверщение цикла while
    $page="admin";//при запуске с этой страницы мы можем редоктировать БД
    if ($_REQUEST['page']=="$page"){
    	$th=$th+2;
    	// добавить пустой столбец для добавления, редактирования и удаления
    	$output .="<th class=\"frametitle\"></th><th class=\"frametitle\"></th>\n";
    }
    $output .="</tr>\n\n";
    // получить название индексного поля (полагая, что оно является первым)
    $keyField = mysql_fetch_field($result, 0);
    $keyName = $keyField->name;
    
    // настроить форму для вставки, посылающую название таблицы
    if ($_REQUEST['page']=="$page"){
    	$keyVal = $row["$keyName"];
    	$output .=<<<HERE
     <tr><form action = "admin.php?option=addRecord"  method="post">
    	<td class="frametitle" colspan = "$th">
    	<input type = "hidden"	name = "tableName"	value = "$tableName">
    	<input name="add" type="image" src="../img/add.gif" alt="Кнопка добавление записи в таблицу!!!"></td>
    	</form></tr>
    HERE;
    }
    $output .="</table>";
    $output="$output_top"."$output";
    return $output;
    }
    ?>

    xXx_totalwar, 11 Января 2010

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

    +168.5

    1. 1
    2. 2
    3. 3
    while ($char_list = mysql_fetch_array($char_list_query,MYSQL_ASSOC) or die(mysql_error())) {
        echo "<option>{$char_list['name']}</option>";
    }

    POPSuL, 10 Января 2010

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

    +153.2

    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 event_form_alter($form_id, &$form) {
      global $user;
    
      $node = isset($form['#node']) ? $form['#node'] : NULL;
    
      switch ($form_id) {
        // node settings form
        case 'node_type_form':
          $type = (isset($form['old_type']) && isset($form['old_type']['#value'])) ? $form['old_type']['#value'] : NULL;
          $form['workflow']['event_nodeapi'] = array(
            '#type' => 'radios',
            '#title' => t('Show in event calendar'),
            '#default_value' => variable_get('event_nodeapi_'. $type, 'never'),
            '#options' => array('all' => t('All views'), 'solo' => t('Only in views for this type'), 'never' => t('Never')),
            '#description' => t('All views: This content type will be available for display on all calendar views, including with other events.<br />Only in views for this type: This content type will only appear in calendar views specific to this type and never with other events.<br />Never: This content type will not be associated with the events calendar.')
          );
          break;
    #...
     }
    }

    vectoroc, 09 Января 2010

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

    +156.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
    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
    <?php
    session_start();
    $lgn=$_SESSION['lgn'];
    $pswd=$_SESSION['pswd'];
    //  print_r($_GET);
    include_once('spyLib.php');
    $dbConn=connectToSpy();
    mysql_query("SET NAMES cp1251");
    $option=$_REQUEST['option'];
      
    $ID=autentID($lgn, $pswd);
    //$ID='45';
    if ($ID=='8') {
    
      if ($option=='editTable'){
      include_once("bd/editTable.php");
      }elseif($option=="addRecord"){
      include_once( 'bd/addRecord.php' );
      }elseif($option=="processAdd"){
      include_once( 'bd/processAdd.php' );
      }elseif($option=="deleteRecord"){
      include_once( 'bd/deleteRecord.php' );
      }elseif($option=="editRecord"){
      include_once( 'bd/editRecord.php' );
      }elseif($option=="updateRecord"){
      include_once( 'bd/updateRecord.php' );  
      }else{
      
      print <<<HERE
    <link href="./style.css" rel="stylesheet" type="text/css">
      <!-----------главная страница------------------------------------->
    <img src="./img/fonpageleft.png" style="position: absolute; top:50px; left: 50px;" width="670" height="370">
    <div style="position: absolute; top:70px; left: 100px;">
    
    <form action="index.php" method="post">
      <input name="ok" type="image" src="img/admin.gif" class="bulleon" alt="Перейти на сайт">
    </form>
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
      <td valign="top" width="458">
      <div class="text_10">Страница находится в разработке.</div>
      <form action="admin.php">
      <input name="option" type="hidden" value="editTable">
      <input name="page" type="hidden" value="admin">
      <input name="back" type="hidden" value="false">
      <table cellspacing="1" cellpadding="3" width='100%'>
      <tr  class="title">
      <td>
      </td>
      <td class='title2'>
      Выберите таблицу для редактирования
      </td>
      <td>
      </td>
      </tr>
      <tr class='table_top'>
      <td width='30' nowrap="nowrap">
      </td>
      <td  align="left">
      <select name="tableName" size=5>
      <option value="kompleks">комплексы</option>
      <option value="glav">главная страница</option>
      <option value="bulletin">новости</option>
      <option value="forleader">для руководителей</option>
      <option value="lunchoffice">обеды в офис</option>
      <option value="partner">партнеры</option>
      <option value="contact">контакты</option>
      <option value="review">отзывы</option>
      </select>
      </td>
      <td width='30' nowrap="nowrap">
      </td>
      </tr>
      <tr>
      <td colspan='3' align='left'>
      <input name="option2" type="image" value="1" src="./img/ok4.gif" class="bulleon">
      </td>
      </tr>
      </table>
      </form>
      </td>
        </tr>
      </table>
    </div>
    <!---!--------главная страница------------------------------------->
    HERE;
      }//if
    
    }else{
      print "<p class=\"mes_small_error\">Попробуйте ввести пороль и логин еще раз</p>";
    }
    ?>

    что тут комментировать - аффтар даже русский с трудом осилил: "Попробуйте ввести пороль"(sic!)

    xXx_totalwar, 09 Января 2010

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

    +151.7

    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
    /**
    	 * bool _validate_mail(string mail)
    	 * Validate an email address
    	 * @access private
    	 * @param string mail The email address string
    	 * @return bool
    	 */
    	function _validate_mail($mail)
    	{
    		if (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',$mail)){
    			return true;
    		}
    		return $this->_debug(4, $mail);
    	}

    no comments...

    InTech, 09 Января 2010

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