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

    Всего: 8

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

    +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
    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
    public function cutPoly($business_id)
        {
            $done = [];
            $red = Isochrone::where('business_id', $business_id)->where('color', 'red')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
            $blue = Isochrone::where('business_id', $business_id)->where('color', 'blue')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
            $green = Isochrone::where('business_id', $business_id)->where('color', 'green')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
            if ($red && $blue) {
                if (!$red['p_path'] || !$blue['p_path']) {
                    $done['red'] = 'already';
                } else {
                    $isoString = 'POLYGON((';
                    $blue_path = $blue['p_path'];
                    $red_path = $red['p_path'];
                    if (!array_key_exists('lat', $blue['p_path'][0])) {
                        $blue_path = $blue['p_path'][0];
                    }
                    if (!array_key_exists('lat', $red['p_path'][0])) {
                        $red_path = $red['p_path'][0];
                    }
                    $isoString .= implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $red_path))
                    . '),('.
                        implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $blue_path))
                        .'))';
                    Isochrone::where('business_id', $business_id)->where('color', 'red')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
                    $done['red'] = 'ok';
                }
            } else if ($red && $green) {
                if (!$red['p_path'] || !$green['p_path']) {
                    $done['red'] = 'already';
                } else {
                    $isoString = 'POLYGON((';
                    $green_path = $green['p_path'];
                    $red_path = $red['p_path'];
                    if (!array_key_exists('lat', $green['p_path'][0])) {
                        $green_path = $green['p_path'][0];
                    }
                    if (!array_key_exists('lat', $red['p_path'][0])) {
                        $red_path = $red['p_path'][0];
                    }
                    $isoString .= implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $red_path))
                    . '),('.
                        implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $green_path))
                        .'))';
                    Isochrone::where('business_id', $business_id)->where('color', 'red')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
                    $done['red'] = 'ok green';
                }
            }
            if ($blue && $green) {
                if (!$blue['p_path'] || !$green['p_path']) {
                    $done['blue'] = 'already';
                } else {
                    $isoString = 'POLYGON((';
                    $green_path = $green['p_path'];
                    $blue_path = $blue['p_path'];
                    if (!array_key_exists('lat', $green['p_path'][0])) {
                        $green_path = $green['p_path'][0];
                    }
                    if (!array_key_exists('lat', $blue['p_path'][0])) {
                        $blue_path = $blue['p_path'][0];
                    }
                    $isoString .= implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $blue_path))
                    . '),('.
                        implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $green_path))
                        .'))';
                    Isochrone::where('business_id', $business_id)->where('color', 'blue')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
                    $done['blue'] = 'ok';
                }
            }
            return $done;
        }

    Он же через час - три дня будет разбиратся что написал

    websbkinfo, 21 Января 2020

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (!$resp || !is_array($resp) || array_key_exists('error', $resp)) {
                    // TODO: what to do?
                } else {
                    Log::channel('caridis')->info("***********************NEW_DELIVERY");
                    Log::channel('caridis')->info([$order]);
                    $order->caridis_id = $resp['data']['id'];
                }

    // TODO: what to do?
    сука????

    websbkinfo, 20 Января 2020

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

    +1

    1. 1
    return Business::find(intval(OptionGroup::find(intval(OptionSet::find($this->attributes['option_set_id'])->first()->option_group_id))->business_id))->first()->

    Eloquent - это пиздец какой то..

    websbkinfo, 14 Января 2020

    Комментарии (19)
  5. JavaScript / Говнокод #25682

    −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
    document.onmousemove = (el) => {
                    if (this.rot) {
                        var s_x = el.pageX, s_y = el.pageY;
                        if (s_x !== o_x && s_y !== o_y){
                            var s_rad = Math.atan2(s_y - o_y, s_x - o_x);
                            s_rad -= Math.atan2(h_y - o_y, h_x - o_x);
    
                            var dgr = (s_rad * (360 / (2 * Math.PI)));
                            element.initPositions.rotateDeg = dgr;
                            element.styles.transform = 'rotate(' + dgr + 'deg)';
                        }
                    }
    };

    А, как я сразу не понял, что это просто ротейт елемента...

    websbkinfo, 20 Июня 2019

    Комментарии (41)
  6. JavaScript / Говнокод #25650

    −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
    95. 95
    <template>
      <div class="side-effects">
        <div class="side-effects__text" v-html="text"></div>
      </div>
    </template>
    
    <script>
        export default {
          name: 'SideEffects',
          data () {
            return {
              text: '<strong>JORNAY PM can cause serious side effects, including: </strong>' +
            '<ul>' +
            '<li>' +
            '<strong>Abuse and dependence.</strong> JORNAY PM contains methylphenidate. JORNAY PM, other methylphenidate-containing products, and\n' +
            'amphetamines have a high chance for abuse and can cause physical and psychological dependence. Your healthcare provider should check\n' +
            'you or your child for signs of abuse and dependence before and during treatment with JORNAY PM.' +
            '<ul>' +
            '<li>Tell your healthcare provider if you or your child has ever abused or been dependent on alcohol, prescription medicines, or street\n' +
            'drugs. </li>' +
            '<li> Your healthcare provider can tell you more about the differences between physical and psychological dependence and drug addiction. </li>' +
            '</ul>' +
            '</li>' +
            '<li>' +
            '<p class="mb-0"><strong>Heart-related problems, including:</strong></p>' +
            '<ul>' +
            '<li>sudden death, stroke, and heart attack in adults</li>' +
            '<li>sudden death in children who have heart problems or heart defects</li>' +
            '<li> increased blood pressure and heart rate </li>' +
            '</ul>' +
            '</li>' +
            '</ul>' +
            'Your healthcare provider should check you or your child carefully for heart problems before starting JORNAY PM. Tell your healthcare provider\n' +
            'if you or your child has any heart problems, heart defects, or high blood pressure.' +
            ' <p>Your healthcare provider should check your or your child’s blood pressure and heart rate regularly during treatment with JORNAY PM. </p>' +
            '<p><strong>Call your healthcare provider right away or go to the nearest hospital emergency room right away if you or your child has any signs of\n' +
            'heart problems such as chest pain, shortness of breath, or fainting during treatment with JORNAY PM. </strong></p>' +
            '<ul>' +
            '<li>' +
            '<strong>Mental (psychiatric) problems, including:</strong>' +
            '<ul>' +
            '<li>new or worse behavior and thought problems</li>' +
            '<li>new or worse bipolar illness</li>' +
            '<li>new psychotic symptoms (such as hearing voices, or seeing or believing things that are not real) or new manic symptoms </li>' +
            '</ul>' +
            '</li>' +
            '</ul>' +
            'Tell your healthcare provider about any mental problems you or your child has, or about a family history of suicide, bipolar illness, or\n' +
            'depression. ' +
            '<p><strong>Call your healthcare provider right away if you or your child have any new or worsening mental symptoms or problems during treatment\n' +
            'with JORNAY PM, especially hearing voices, seeing or believing things that are not real, or new manic symptoms</strong></p>' +
            '<strong>JORNAY PM can cause other serious side effects, including:</strong>' +
            '<ul>' +
            '<li>See <strong>“What is the most important information I should know about JORNAY PM?” </strong></li>' +
            '<li><strong>Painful and prolonged erections (priapism). </strong>Priapism has happened in males who take products that contain methylphenidate. If you or\n' +
            'your child develops priapism, get medical help right away</li>' +
            '<li>' +
            '<strong>Circulation problems in fingers and toes (peripheral vasculopathy, including Raynaud’s phenomenon). Signs and symptoms may\n' +
            'include:</strong>' +
            '<ul>' +
            '<li>fingers or toes may feel numb, cool, or painful</li>' +
            '<li> fingers or toes may change color from pale, to blue, to red </li>' +
            '</ul>' +
            '</li>' +
            '</ul>' +
            'Tell your healthcare provider if you or your child has numbness, pain, skin color change, or sensitivity to temperature in the fingers or toes. ' +
            '<strong>Call your healthcare provider right away if you or your child has any signs of unexplained wounds appearing on fingers or toes during\n' +
            'treatment with JORNAY PM.</strong>' +
            '<ul>' +
            '<li>' +
            '<strong>Slowing of growth (height and weight) in children</strong> Children should have their height and weight checked often during treatment with\n' +
            'JORNAY PM. JORNAY PM treatment may be stopped if your child is not gaining weight or height. ' +
            '</li>' +
            '</ul>' +
            '<strong>The most common side effects of methylphenidate products in children, adolescents, and adults with ADHD include:</strong>' +
            '<ul>' +
            '<li>decreased appetite</li>' +
            '<li>stomach pain</li>' +
            '<li>irritability</li>' +
            '<li>trouble sleeping</li>' +
            '<li>weight loss</li>' +
            '<li>mood swings (affect lability)</li>' +
            '<li>nausea</li>' +
            '<li>anxiety</li>' +
            '<li>increased heart rate</li>' +
            '<li>vomiting</li>' +
            '<li>dizziness</li>' +
            '<li>increased blood pressure</li>' +
            '<li>indigestion</li>' +
            '</ul>' +
            '<strorg>The most common side effects of JORNAY PM in children age 6 to 12 with ADHD include: </strorg>';
            }
          }
        }
    </script>

    Так вот зачем нужна data и v-html (VueJS)

    websbkinfo, 30 Мая 2019

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

    0

    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
    public function passes($attribute, $hostname)
        {
            if (!mb_stripos($hostname, '.')) {
                return false;
            }
    
            $domain = explode('.', $hostname);
            $allowedChars = ['-'];
            $extenion = array_pop($domain);
    
            foreach ($domain as $value) {
                $fc = mb_substr($value, 0, 1);
                $lc = mb_substr($value, -1);
    
                if (
                    hash_equals($value, '')
                    || in_array($fc, $allowedChars)
                    || in_array($lc, $allowedChars)
                ) {
                    return false;
                }
    
                if (!ctype_alnum(str_replace($allowedChars, '', $value))) {
                    return false;
                }
            }
    
            if (
                !ctype_alnum(str_replace($allowedChars, '', $extenion))
                || hash_equals($extenion, '')
            ) {
                return false;
            }
    
            if (filter_var($hostname, FILTER_VALIDATE_DOMAIN) === false) {
                return false;
            }
    
            return true;
        }

    валидация домена...

    websbkinfo, 09 Февраля 2019

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

    +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
    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
    EventBus.$on('drag-element', (element) => {
                    if (element.type !== 'form') {
                        setTimeout(() => {
                            this.dragging = true
                        }, 1000)
                    }
                }),
                EventBus.$on('change-element-order', data => {
                    this.manageElementOrder(data, this.page.elements)
                });
                EventBus.$on('change-removed-powered-by', data => {
                    this.isRemovedPoweredBy = this.theme.isRemovedPoweredBy;
                });
                EventBus.$on('select-element', (element, flags = {}) => {
                    let isElExist = false;
    
                    if (isElExist) return;
    
                    if (element.type !== 'form' || flags.isFormCreated) {
    
                        EventBus.$emit('update-email-form', element);
    
                        if (flags.isFormCreated) {
                            EventBus.$emit('add-form')
                        }
    
                        setTimeout(() => {
                            this.dragging = true
                        }, 1000)
                    } else {
                        EventBus.$emit('open-modal');
                        EventBus.$emit('set-modal-data', 'email-providers');
                    }
                });
                EventBus.$on('remove-element', element => {
                    if (!this.page.elements) return;
    
                    if (element.type == 'form') {
                        EventBus.$emit('reset-email-provide-list-fields')
                    }
    
                });
                EventBus.$on('updateBackground', (data) => {
                    this.backgroundImage = data.image;
                });
                this.$root.$on('onSetPopupPosition', this.setPopupPosition);

    VueJS
    Центральное хранилище - не, не слышал!

    websbkinfo, 07 Февраля 2019

    Комментарии (18)
  9. SQL / Говнокод #25360

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    CREATE TABLE `test` (
        `id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
         `parent` INT(10) unsigned NOT NULL DEFAULT '0',
          `name` VARCHAR(50),
         PRIMARY KEY (`id`)
        ) ENGINE=InnoDB;
    INSERT INTO test (id, parent, name) values (1, 0, '10'),(2, 1, '21'),(4, 3, '43'),(5, 0, '50'),(6, 5, '65'),(7, 6, '76'),(8, 7, '87'),(9, 8, '98');
    SELECT t1.name AS lev1, t2.name as lev2, t3.name as lev3, t4.name as lev4, t5.name as lev5, t6.name as lev6, t7.name as lev7 FROM `test` AS t1 LEFT JOIN test AS t2 ON t2.`parent` = t1.`id`  LEFT JOIN test AS t3 ON t3.`parent` = t2.`id`  LEFT JOIN test AS t4 ON t4.`parent` = t3.`id` LEFT JOIN test AS t5 ON t5.`parent` = t4.`id` LEFT JOIN test AS t6 ON t6.`parent` = t5.`id` LEFT JOIN test AS t7 ON t7.`parent` = t6.`id`;

    взять последнего парента с седьмого колена!
    я просто похлопаю :)

    websbkinfo, 07 Февраля 2019

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