1. Список говнокодов пользователя tatocaster

    Всего: 3

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

    +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
    function getadminuserid(){
    	global $wpdb;
        //Get all users in the DB
        $wp_user_search = $wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID");
    
        //Blank array
        $adminArray = array();
        //Loop through all users
        foreach ( $wp_user_search as $userid ) {
            //Current user ID we are looping through
            $curID = $userid->ID;
            //Grab the user info of current ID
            $curuser = get_userdata($curID);
            //Current user level
            $user_level = $curuser->user_level;
            //Only look for admins
            if($user_level >= 8){//levels 8, 9 and 10 are admin
                //Push user ID into array
                $adminArray[] = $curID;
            }
        }
        return $adminArray;
    }

    1) Get IDs for all users
    2) Iterate over result set to find admin `get_userdata` function = 1 DB call

    outcome:
    1) full RAM
    2) dead DB

    ===
    official woocommerce plugin by company

    tatocaster, 27 Октября 2017

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

    +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
    <select tabindex="8" id="inputBirthMonth" class="input-small form-control" name="month">
                            <option value="0">--</option>
                            <option
                                value="1" <?php $month = 0;
                            if (isset($specificdata['month'])) {
                                $month = @$specificdata['month'];
                            }
                            if (1 == $month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:january'); ?></option>
                            <option
                                value="2" <?php if (2 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:february'); ?></option>
                            <option
                                value="3" <?php if (3 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:march'); ?></option>
                            <option
                                value="4" <?php if (4 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:april'); ?></option>
                            <option
                                value="5" <?php if (5 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:may'); ?></option>
                            <option
                                value="6" <?php if (6 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:june'); ?></option>
                            <option
                                value="7" <?php if (7 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:july'); ?></option>
                            <option
                                value="8" <?php if (8 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:august'); ?></option>
                            <option
                                value="9" <?php if (9 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:september'); ?></option>
                            <option
                                value="10" <?php if (10 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:october'); ?></option>
                            <option
                                value="11" <?php if (11 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:november'); ?></option>
                            <option
                                value="12" <?php if (12 == @$month) {
                                echo "selected";
                            }
                            ?»<?php echo lang('Main:december'); ?></option>
                        </select>

    Month dropdown select in registration form

    tatocaster, 25 Апреля 2016

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

    +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
    public function getPagination($page, $rows, $limit){
            $pageArray = array();
    
            if ($rows > $limit){
                $allPage = ceil($rows/$limit);
    
                if ($allPage <= 7){
                    for ($i=1;$i<=$allPage;$i++){$pageArray[]=$i;}
                }else{
                    if ($page < 5){
                        for ($i=1;$i<=($page+3);$i++){$pageArray[]=$i;}
                        $pageArray[]=$allPage;
                    }else{
                        if ($allPage <= ($page+3)){
                            $pageArray[]=1;
                            for ($i=($page-3);$i<=$allPage;$i++){$pageArray[]=$i;}
                        }else{
                            $pageArray[]=1;
                            for ($i=($page-3);$i<=($page+3);$i++){$pageArray[]=$i;}
                            $pageArray[]=$allPage;
                        }
                    }
                }
    
                return array(
                    'pages' => $pageArray,
                    'page' => $page
                );
            }else{
                return array(
                    'pages' => 1,
                    'page' => $page
                );
            }
        }

    My friend wrote pagination function. takes current page, number of rows (from query), and limit on each page. function works really good but :D govno kod :D

    tatocaster, 01 Апреля 2014

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