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

    Всего: 33

  2. Си / Говнокод #27941

    +3

    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
    buf = malloc(8 * 1024);
    
    snprintf(buf, 8 * 1024,
         "{\n"
         "\t\"tilejson\": \"2.0.0\",\n"
         "\t\"schema\": \"xyz\",\n"
         "\t\"name\": \"%s\",\n"
         "\t\"description\": \"%s\",\n"
         "\t\"attribution\": \"%s\",\n"
         "\t\"minzoom\": %i,\n"
         "\t\"maxzoom\": %i,\n"
         "\t\"tiles\": [\n",
         tile_config->xmlname, (tile_config->description ? tile_config->description : ""), tile_config->attribution, tile_config->minzoom, tile_config->maxzoom);
    
    for (i = 0; i < tile_config->noHostnames; i++) {
        strncat(buf, "\t\t\"", 8 * 1024 - strlen(buf) - 1);
        strncat(buf, tile_config->hostnames[i], 8 * 1024 - strlen(buf) - 1);
        strncat(buf, tile_config->baseuri, 8 * 1024 - strlen(buf) - 1);
        strncat(buf, "{z}/{x}/{y}.", 8 * 1024 - strlen(buf) - 1);
        strncat(buf, tile_config->fileExtension, 8 * 1024 - strlen(buf) - 1);
        strncat(buf, "\"", 8 * 1024 - strlen(buf) - 1);
    
        if (i < tile_config->noHostnames - 1) {
            strncat(buf, ",", 8 * 1024 - strlen(buf) - 1);
        }
    
        strncat(buf, "\n", 8 * 1024 - strlen(buf) - 1);
    }
    
    strncat(buf, "\t]\n}\n", 8 * 1024 - strlen(buf) - 1);
    len = strlen(buf);
    
    /*
     * Add HTTP headers. Make this file cachable for 1 week
     */
    md5 = ap_md5_binary(r->pool, (unsigned char *)buf, len);
    apr_table_setn(r->headers_out, "ETag",
               apr_psprintf(r->pool, "\"%s\"", md5));
    ap_set_content_type(r, "application/json");
    ap_set_content_length(r, len);
    apr_table_mergen(t, "Cache-Control",
             apr_psprintf(r->pool, "max-age=%" APR_TIME_T_FMT,
                      maxAge));
    timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
    apr_rfc822_date(timestr, (apr_time_from_sec(maxAge) + r->request_time));
    apr_table_setn(t, "Expires", timestr);
    ap_rwrite(buf, len, r);
    free(buf);

    https://github.com/openstreetmap/mod_tile/blob/master/src/mod_tile.c#L1212

    ISO, 10 Января 2022

    Комментарии (6)
  3. Куча / Говнокод #27861

    +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
    RUN apt install -y apache2
    RUN apt install -y php
    RUN apt install -y php-mysql
    RUN apt install -y libapache2-mod-php
    RUN apt install -y curl
    RUN apt install -y php-mbstring
    RUN apt install -y php-mysql
    RUN apt install -y php7.4-sqlite3
    RUN apt install -y php-gd
    RUN apt install -y php-intl
    RUN apt install -y php-xml
    RUN apt install -y php-curl
    
    #RUN apt install -y php7.0-ffmpeg
    
    RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.4/apache2/php.ini
    RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.4/cli/php.ini
    
    RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
    RUN echo "IncludeOptional /var/www/*.conf" >> /etc/apache2/apache2.conf
    #RUN sed -i "s/<\/VirtualHost>/Проверка\n<\/VirtualHost>" /etc/apache2/apache2.conf
    RUN sed -i "s/<\/VirtualHost>/\n\t<Directory \/var\/www\/html>\n\t<\/Directory>\n<\/VirtualHost>/g" /etc/apache2/sites-available/000-default.conf
    RUN sed -i "s/<\/Directory>/\tOptions Indexes FollowSymLinks MultiViews\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
    RUN sed -i "s/<\/Directory>/\tAllowOverride All\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
    RUN sed -i "s/<\/Directory>/\tOrder allow,deny\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
    RUN sed -i "s/<\/Directory>/\tAllow from all\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
    RUN sed -i "s/<\/Directory>/\tRequire all granted\n\t<\/Directory>/g" /etc/apache2/sites-available/000-default.conf
    RUN mv /etc/apache2/sites-enabled/000-default.conf /tmp
    RUN cd /etc/apache2/sites-enabled/; ln -s ../sites-available/000-default.conf 000-default.conf
    RUN a2enmod php7.4
    RUN a2enmod rewrite
    #RUM apt install -y certbot
    #RUN a2enmod python-certbot-apache
    #RUN a2enmod ssl
    EXPOSE 80
    EXPOSE 22
    
    #        <Directory /var/www/html>
    #                Options Indexes FollowSymLinks MultiViews
    #                AllowOverride All
    #                Order allow,deny
    #                Allow from all
    #                Require all granted
    #        </Directory>
    
    RUN wget -O /var/www/html/index.phar https://github.com/mpak2/mpak.su/raw/master/phar/index.phar
    RUN wget -O /var/www/html/.htaccess https://github.com/mpak2/mpak.su/raw/master/.htaccess
    RUN wget -O /var/www/html/.htdb https://github.com/mpak2/mpak.su/raw/master/.htdb
    RUN chown www-data /var/www/html/.htdb
    RUN chown www-data /var/www/html
    RUN mkdir /var/www/html/include
    RUN mkdir /var/www/html/include/images
    RUN chmod 0777 /var/www/html/include/images
    RUN rm /var/www/html/index.html

    https://github.com/mpak2/mpak.su/blob/654b7daf0b7d4f3c83385c0ca35fcab6a1ec45f7/phar/docker/www/Dockerfile

    ISO, 07 Декабря 2021

    Комментарии (21)
  4. bash / Говнокод #27769

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #!/usr/bin/env bash
    
    URL=https://foo.bar/baz.zip
    PATH=/home/foo/bar/baz.zip
    
    wget -O "$PATH" "$URL"

    И только потом до мена дошло…

    ISO, 26 Октября 2021

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