1. Поиск говнокода

    Этот поиск практически ничего не может найти! Но вы всё-таки попытайтесь, вдруг повезет.

    Найдено: 29

  2. PHP / Говнокод #5802

    +32

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // trololo protection
      if (count($nodes) > ADVIMAGE_GALLERY_MAX_IMAGES_IN_GALLERY) {
        $result = array(
          'jsonrpc' => '2.0', 
          'result' => 'error',
          'error_token' => t(
            'You try add more than !count images to gallery', 
            array('!count' => ADVIMAGE_GALLERY_MAX_IMAGES_IN_GALLERY) 
          ),
        );
        die(drupal_to_js($result) );
      }

    хрясь... JSON такой JSON. на случай хитровыебаных любителей отлаживать JS )

    brainstorm, 25 Февраля 2011

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

    −982

    1. 1
    SELECT * FROM `club_node` WHERE date_format(FROM_UNIXTIME(`created`),'%Y-%m-%d') = date_format(FROM_UNIXTIME(UNIX_TIMESTAMP() + ${поправка на пояс} ),'%Y-%m-%d')

    так пхпкодеры с drupal.ru решают вопрос временных зон. знание матчасти - бляпиздец.
    http://drupal.ru/node/57305

    brainstorm, 13 Февраля 2011

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

    +36

    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
    /**
     * Implementation of hook_access().
     *
     * Node modules may implement node_access() to determine the operations
     * users may perform on nodes. This example uses a very common access pattern.
     */
    function node_example_access($op, $node, $account) {
      if ($op == 'create') {
        return user_access('create example content', $account);
      }
    
      if ($op == 'update') {
        if (user_access('edit any example content', $account) || (user_access('edit own example content', $account) && ($account->uid == $node->uid))) {
          return TRUE;
        }
      }
    
      if ($op == 'delete') {
        if (user_access('delete any example content', $account) || (user_access('delete own example content', $account) && ($account->uid == $node->uid))) {
          return TRUE;
        }
      }
    }

    http://api.drupal.org/api/examples/node_example--node_example.module/6/source
    тут еще много.
    но факт что те кто это пишут таки нужные люди. сама документация достаточно достоверна

    brainstorm, 02 Февраля 2011

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

    +158

    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
    class Relay {
      protected $_data = array();
      protected $_devices;
      static protected $_db_fields = array();
    
      function getId() {
        return $this->_data['id'];
      }
      static function load($id) {
        if ($id) {
          $select = db_select('relay', 'r');
          $select->fields('r');
          $select->condition('r.id', $id);
          $relay = $select->execute()->fetchObject(__CLASS__);
          return $relay;
        }
      }
      function save() {
        foreach (array_diff(array_keys($this->_data), self::_getPureDbFields('relay')) as $field) {
          $this->_data['data'] = $this->_data[$field];
        }
    
        if ($this->getId()) {
          drupal_write_record('relay', $this->_data, array('id'));
        }
        else {
          drupal_write_record('relay', $this->_data);
        }
        $this->_saveDevices();
      }
      protected function _saveDevices() {
        if ($this->getId()) {
          $delete = db_delete('relay_devices');
          $delete->condition('relay_id', $this->getId());
          $delete->execute();
    
          foreach ((array)$this->_devices as $device) {
            $device = (array) $device;
            foreach (array_diff(array_keys($device), self::_getPureDbFields('relay_devices')) as $field) {
              $device['data'] = $device[$field];
            }
    
            drupal_write_record('relay_devices', $device);
          }
        }
      }
      function getDateFrom() {
        return $this->_data['date_from'];
      }
      function getDateDuration(){
        return $this->_data['date_duration'];
      }
      function getDateTo(){
        return $this->getDateFrom() + $this->getDateDuration();
      }
      function getDevices(){
        $this->_ensureDevicesLoaded();
        return $this->_devices;
      }
      protected function _ensureDevicesLoaded() {
        if (!is_array($this->_devices)) {
          $select = db_select('relay_devices', 'rd');
          $select->fields('rd');
          $select->condition('rd.relay_id', $this->getId());
          $query = $select->execute();
    
          $this->_devices = array_map('drupal_unpack', $query->fetchAll());
        }
        return is_array($this->_devices);
      }
      function __construct($data = NULL) {
        if (is_array($data)) {
          foreach ($data as $key => $value) {
            $this->_data[$key] = $value;
          }
        }
        elseif (is_string($this->_data['data']) && !empty($this->_data['data'])) {
          drupal_unpack($this);
        }
      }
      function __set($name, $value) {
        return $this->_data[$name] = $value;
      }
      function __get($name) {
        return $this->_data[$name];
      }
      static protected function _getPureDbFields($table) {
        if (!isset(self::$_db_fields[$table])) {
          $schema = drupal_get_schema($table);
          $fields = $schema['fields'];
          unset($fields['data']);
          self::$_db_fields[$table] = array_keys($fields);
        }
    
        return self::$_db_fields[$table];
      }
    }

    vectoroc, 26 Января 2011

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

    +35

    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
    <?php
    include_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    module_load_include('inc', 'node', 'node.pages'); 
    
    $queryPopQueue = "select * from custom_contact_insert where drupal_node_id is null limit 50";
    $queryResult =  db_query($queryPopQueue);
    while ($data = db_fetch_object($queryResult)){
        $node->type = 'contact';
        node_object_prepare($node);
        $node->uid = 1;
        $node->title = $data->field_contact_first_name_value . ' ' . $data->field_contact_last_name_value;
        $node->body = "";
        $node->teaser = "";
        $node->filter = variable_get('filter_default_format', 1);
        $node->format = FILTER_FORMAT_DEFAULT;
        $node->language = '';
        $node->revision = 0;
        $node->promote = 0;
        $node->created = time();
        $node->comment= 0;
        
        $node->taxonomy = array('tags' => array('11' => ($data->categories)));
        $node->field_contact_first_name[0]['value'] = $data->field_contact_first_name_value;
        $node->field_contact_last_name[0]['value'] = $data->field_contact_last_name_value;
        $node->field_contact_job_title[0]['value'] = $data->field_contact_job_title_value;
        $node->field_contact_organization[0]['value'] = $data->field_contact_organization_value;
        $node->field_contact_organization_r['nid']['nid'] = '463'; //this is a sample hard coded value
        $node->field_contact_account_sfid[0]['value'] = $data->field_contact_account_sfid_value;
        $node->field_contact_sfid[0]['value'] = $data->field_contact_sfid_value;
        
        $node->field_contact_email_optout[0]['value'] = 'false';
        $node->field_contact_phone_optout[0]['value'] = 'false';
        
        $node->field_contact_add1_city[0]['value'] = $data->field_contact_add1_city_value;
        $node->field_contact_add1_country[0]['value'] = $data->field_contact_add1_country_value;
        $node->field_contact_add1_zipcode[0]['value'] = $data->field_contact_add1_zipcode_value;
        $node->field_contact_add1_state[0]['value'] = $data->field_contact_add1_state_value;
        $node->field_contact_add1_street[0]['value'] = $data->field_contact_add1_street_value;
        $node->field_contact_add1_type[0]['value'] = 'Work';
        
        $node->field_contact_add2_city[0]['value'] = $data->field_contact_add2_city_value;
        $node->field_contact_add2_country[0]['value'] = $data->field_contact_add2_country_value;
        $node->field_contact_add2_zipcode[0]['value'] = $data->field_contact_add2_zipcode_value;
        $node->field_contact_add2_state[0]['value'] = $data->field_contact_add2_state_value;
        $node->field_contact_add2_street[0]['value'] = $data->field_contact_add2_street_value;
        $node->field_contact_add2_type[0]['value'] = 'Home';
        
        $node->field_contact_mobile_phone[0]['value'] = $data->field_contact_mobile_phone_value;
        $node->field_contact_home_phone[0]['value'] = $data->field_contact_home_phone_value;
        $node->field_contact_work_phone[0]['value'] = $data->field_contact_work_phone_value;
        $node->field_contact_asst_phone[0]['value'] = $data->field_contact_asst_phone_value;
        
        $node->field_contact_email1[0]['value'] = $data->field_contact_email1_email;
        $node->field_contact_email2[0]['value'] = $data->field_contact_email2_email;
        $node->field_contact_email_asst[0]['value'] = $data->field_contact_email_asst_email;
        
        $node->field_contact_assistant[0]['value'] = $data->field_contact_assistant_value;
        $node->field_contact_notes[0]['value'] = $data->notes;
          
        node_save($node);
        $nid = $node->nid;
        unset($node);
        
        //update status and drupalid in the queue
        $queryUpdate = "update custom_contact_insert set drupal_node_id = '$nid', status = '1' where id = '" . $data->id . "'";
        db_query($queryUpdate);
    }
    ?>

    вот вам высер. не мой на этот раз :)

    brainstorm, 14 Января 2011

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

    +161

    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
    function render_menu_item($tag,$value,$css=null){
    $length=strlen($tag);
       
        //Validate the tags
          if($tag[0]=='<' && $tag[$length-1]=='>'){
            $closingtag=str_replace('<','</',$tag);
            if($css)
                $tag=str_replace('>',' class="'.$css.'">',$tag);        
          }
          else{
            if($css){       
            $classtag='<'.$tag.' class="'.$css.'">';
            $tag='<'.$tag.'>';
            $closingtag=str_replace('<','</',$tag);
            $tag=$classtag;
            }
            else{
            $tag='<'.$tag.'>';
            $closingtag=str_replace('<','</',$tag);
            }
          }  
      return $tag.$value.$closingtag;
    }

    Вот так пишут доблестные Drupal-разработчики из Иордании. Сохранено оригинальное форматирование.

    UncleAli, 13 Мая 2010

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

    +163

    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
    require_once(HTML2PS_DIR.'utils_array.php');
    require_once(HTML2PS_DIR.'utils_graphic.php');
    require_once(HTML2PS_DIR.'utils_url.php');
    require_once(HTML2PS_DIR.'utils_text.php');
    require_once(HTML2PS_DIR.'utils_units.php');
    require_once(HTML2PS_DIR.'utils_number.php');
    require_once(HTML2PS_DIR.'value.color.php');
    require_once(HTML2PS_DIR.'config.parse.php');
    require_once(HTML2PS_DIR.'flow_context.class.inc.php');
    require_once(HTML2PS_DIR.'flow_viewport.class.inc.php');
    require_once(HTML2PS_DIR.'output._interface.class.php');
    require_once(HTML2PS_DIR.'output._generic.class.php');
    require_once(HTML2PS_DIR.'output._generic.pdf.class.php');
    require_once(HTML2PS_DIR.'output._generic.ps.class.php');
    require_once(HTML2PS_DIR.'output.pdflib.old.class.php');
    require_once(HTML2PS_DIR.'output.pdflib.1.6.class.php');
    require_once(HTML2PS_DIR.'output.fpdf.class.php');
    require_once(HTML2PS_DIR.'output.fastps.class.php');
    require_once(HTML2PS_DIR.'output.fastps.l2.class.php');
    require_once(HTML2PS_DIR.'output.png.class.php');
    // require_once(HTML2PS_DIR.'output.pcl.class.php');
    
    require_once(HTML2PS_DIR.'stubs.common.inc.php');
    require_once(HTML2PS_DIR.'media.layout.inc.php');
    require_once(HTML2PS_DIR.'box.php');
    require_once(HTML2PS_DIR.'box.generic.php');
    require_once(HTML2PS_DIR.'box.generic.formatted.php');
    require_once(HTML2PS_DIR.'box.container.php');
    require_once(HTML2PS_DIR.'box.generic.inline.php');
    require_once(HTML2PS_DIR.'box.inline.php');
    require_once(HTML2PS_DIR.'box.inline.control.php');
    require_once(HTML2PS_DIR.'font.class.php');
    require_once(HTML2PS_DIR.'font_factory.class.php');
    
    require_once(HTML2PS_DIR.'box.br.php');
    require_once(HTML2PS_DIR.'box.block.php');
    require_once(HTML2PS_DIR.'box.page.php');
    require_once(HTML2PS_DIR.'box.page.margin.class.php');
    require_once(HTML2PS_DIR.'box.body.php');
    require_once(HTML2PS_DIR.'box.block.inline.php');
    require_once(HTML2PS_DIR.'box.button.php');
    require_once(HTML2PS_DIR.'box.button.submit.php');
    require_once(HTML2PS_DIR.'box.button.reset.php');
    require_once(HTML2PS_DIR.'box.checkbutton.php');
    require_once(HTML2PS_DIR.'box.form.php');
    require_once(HTML2PS_DIR.'box.frame.php');
    require_once(HTML2PS_DIR.'box.iframe.php');
    require_once(HTML2PS_DIR.'box.input.text.php');
    require_once(HTML2PS_DIR.'box.input.textarea.php');
    require_once(HTML2PS_DIR.'box.input.password.php');
    require_once(HTML2PS_DIR.'box.legend.php');
    require_once(HTML2PS_DIR.'box.list-item.php');
    require_once(HTML2PS_DIR.'box.null.php');
    require_once(HTML2PS_DIR.'box.radiobutton.php');
    require_once(HTML2PS_DIR.'box.select.php');
    require_once(HTML2PS_DIR.'box.table.php');
    require_once(HTML2PS_DIR.'box.table.cell.php');
    require_once(HTML2PS_DIR.'box.table.cell.fake.php');
    require_once(HTML2PS_DIR.'box.table.row.php');
    require_once(HTML2PS_DIR.'box.table.section.php');
    
    require_once(HTML2PS_DIR.'box.text.php');
    require_once(HTML2PS_DIR.'box.text.string.php');
    require_once(HTML2PS_DIR.'box.field.pageno.php');
    require_once(HTML2PS_DIR.'box.field.pages.php');
    ........
    и так до 284й строки включительно...

    в самописном модуле к Drupal нашел сий шедевр

    kemerov4anin, 27 Апреля 2010

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

    +158

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru"> 
    <head> 
    ...
    <?php
    if( !isset($page['header']['links']) || empty($page['header']['links']) )
    {
    ?>
    <link rel="shortcut icon" href="/sites/all/themes/deco/favicon.ico" type="image/x-icon" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/poll/poll.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/user/user.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/cck/theme/content-module.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/filefield/filefield.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/geshifilter/geshifilter.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/quote/quote.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/tagadelic/tagadelic.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/vote_up_down/vote_up_down.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/comment/comment.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/pr_cy/pr_cy.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/openid/openid.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/deco/style.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/examples/tagnetic/tags.css?t" /> 
    <link type="text/css" rel="stylesheet" media="print" href="/sites/all/themes/deco/print.css?t" /> 
    <script type="text/javascript" src="/misc/jquery.js?t"></script> 
    <script type="text/javascript" src="/misc/drupal.js?t"></script> 
    <script type="text/javascript" src="/files/languages/ru_5530db2a4478b35f94b4da1e2062c5fb.js?t"></script> 
    <script type="text/javascript" src="/sites/all/modules/vote_up_down/ajax_vote_up_down.js?t"></script> 
    <script type="text/javascript" src="/sites/all/themes/deco/jquery.tagnetic.js?t"></script> 
    <script type="text/javascript" src="/sites/all/themes/deco/jquery.tagnetic.settings.js?t"></script> 
    <script type="text/javascript" src="/modules/comment/comment.js?t"></script> 
    <script type="text/javascript" src="/misc/textarea.js?t"></script> 
    <script type="text/javascript" src="/sites/all/modules/pr_cy/pr_cy.js?t"></script> 
    <script type="text/javascript" src="/modules/openid/openid.js?t"></script>
    <?php
    }
    else
    {
    echo $page['header']['links'];
    }
    ?>

    Я, конечно, понимаю, что это необходимо, но такие хеды у меня всегда вызывают улыбку)

    greevex, 12 Сентября 2009

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

    +153

    1. 1
    2. 2
    3. 3
    function db_encode_blob($data) {
     return $data;
    }

    Drupal

    guest, 27 Января 2009

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