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

    Всего: 1

  2. bash / Говнокод #3294

    −142

    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
    #!/bin/bash
    #   
    #   program file name: urlmin.sh
    #   program version: 0.4
    
    _help()
    {
    
    prg=$(basename $0)
    cat << EOF
    
    options:
       -h      See this page
       -l      Viewed all names of minifer sites
       -s      
       	  lb.vg
       	  minify.me
       	  is.gd
       -r      Random mode of minifiers
       -u      url link
    examples:
       random mode     - minifiers: ${prg} -r -u 'http://wikimapia.org/#lat=36.7923994&lon=53.1100881&z=18&l=1&m=b'
       only 1 minifier - is.gd minifier: ${prg} -s is.gd -u 'http://wikimapia.org/#lat=36.7923994&lon=53.1100881&z=18&l=1&m=b'
       or lb.vg minifier: ${prg} -s lb.vg -u 'http://wikimapia.org/#lat=36.7923994&lon=53.1100881&z=18&l=1&m=b'
       and other
    
    EOF
    
    exit 0
    }
    
    [ ! -f "$(which curl)" ] && { echo "Установите утилиту curl" ; exit 1 ;}
    
    _user_agent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.4) Gecko/20100503 Firefox/3.6.4"
    _sets_minifiers=( "lb.vg" "is.gd" "minify.me" )
    
    _e()         { echo -e "${*}" ;}
    _get_page()  { curl -s -A "$USER_AGENT" ${1} | tr -d '\n' || { clear ; echo -e "${B_T}${RC}Error${CRS}! curl in function _get_page has exited abnormaly: ${1}" ; exit 1 ;} ;}
    _post_page() { curl -s -A "$USER_AGENT" -d "${2}" "${1}" | tr -d "\n" || { clear ; echo -e "${B_T}${RC}Error!${CRS} curl in function _post_page has exited abnormaly: ${1} -> ${2}" ; exit 1 ;} ;}
    _urlencode() { LANG=C awk 'BEGIN { EOL = "%0A" ; split ("1 2 3 4 5 6 7 8 9 A B C D E F", hextab, " ") ; hextab [0] = 0 ; for ( i=1; i<=255; ++i ) ord [ sprintf ("%c", i) "" ] = i + 0 } ; { encoded = "" ; for ( i=1; i<=length ($0); ++i ) { c = substr ($0, i, 1) ; if ( c ~ /[a-zA-Z0-9.-]/ ) { encoded = encoded c } else if ( c == " " ) { encoded = encoded "+" } else { lo = ord [c] % 16 ; hi = int (ord [c] / 16); encoded = encoded "%" hextab [hi] hextab [lo] } } ; printf ("%s", encoded EOL) } END { }' "$@" | sed 's|%0A||g' ;}
    _random()    { [ -n "${1}" ] && { while :; do zz=$(y=0;for ((x=${1};x>=y;y++)) ; do [ "$y" == "${RANDOM[@]:2:1}" ] && [ -n "$y" ] && { echo $y ; break ;} ; done ) ; [ -n "$zz" ] && { echo "$zz" ; break ;} ; done ;} ;}
    
    # sets
    while getopts "hu:s:rl" option ; do case $option in
    		h) _help                ;;
    		u) url_path="$OPTARG"   ;;
    		s) _set_min="$OPTARG"    ; set_min_num=$(j=0 ; for x in ${_sets_minifiers[*]} ; do [ "${x}" == "${_set_min}" ] && _e "${j}" ; ((j++)) ; done) ;;
    		r) mode_random="yes"     ; set_min_num="$(_random $((${#_sets_minifiers[*]}-1)) )" ;;
    		l) list_mins="yes"      ;;
    		v) set_verbose="-v"     ;;
    esac ; done
    
    case $set_min_num in
    0) 
       _url_enc=$(_e "${url_path}" | _urlencode)
       _url_host="${_sets_minifiers[$set_min_num]}"
       _obtained=$(_post_page "http://${_url_host}/default.asp" "Orig_URL=${_url_enc}&show_ve=1&Categ=Humor" | egrep -o "http://${_url_host}/[a-Z0-9]+'" | sort -u | sed "s|'||g;s|http://||g") ;;
    1)
       _url_enc=$(_e "${url_path}" | _urlencode)
       _url_host="${_sets_minifiers[$set_min_num]}"
       _obtained=$(_post_page "http://${_url_host}/create.php" "URL=${_url_enc}" | egrep -o "http://${_url_host}/[a-Z0-9]+\" target" | sed 's|\" target||g;s|http://||g') ;;
    2) 
       _url_enc=$(_e "${url_path}" | _urlencode)
       _url_host="${_sets_minifiers[$set_min_num]}"
       _obtained=$(_post_page "http://${_url_host}/create.php" "url=${_url_enc}" | egrep -o "http://${_url_host}/\?[a-Z0-9]+" | sed 's|http://||g') ;;
    esac
    
    [ -z "$1"           ] && _help
    [ -n "$set_min_num" ] && _e "Link: ${_obtained}"
    [ -n "$list_mins"   ] && _e "Minifiers:\n\n$(for i in ${_sets_minifiers[*]} ; do _e "  ${i}" ; done)\n"
    
    # eof urlmin.sh

    url minifier

    # typical define:
    -=>> ./urlmin.sh -s is.gd -u 'http://wikimapia.org/#lat=36.7923994&lon=53.1100881&z=18&l=1& m=b'
    Link: is.gd/ckjsg

    # random minifier:
    -=>> ./urlmin.sh -r -u 'http://wikimapia.org/#lat=36.7923994&lon=53.1100881&z=18&l=1& m=b'
    Link: minify.me/?qkvbp2

    pp--, 22 Мая 2010

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