# HG changeset patch # User Matti Hamalainen # Date 1401163979 -10800 # Node ID 52350ed977753ed08b4d72d7b5f5d1987178bff2 # Parent fc2654064339f67fd3327214f633d27b0778df4b urllog: Cleanups, rename/move some global variables. diff -r fc2654064339 -r 52350ed97775 urllog.tcl --- a/urllog.tcl Tue May 27 07:12:01 2014 +0300 +++ b/urllog.tcl Tue May 27 07:12:59 2014 +0300 @@ -281,18 +281,20 @@ } #------------------------------------------------------------------------- -proc urllog_get_short {utime} { - global urllog_shorturl_prefix +set urllog_shorturl_str "ABCDEFGHIJKLNMOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - set ustr "ABCDEFGHIJKLNMOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - set ulen [string length $ustr] +proc urllog_get_short {utime} { + global urllog_shorturl_prefix urllog_shorturl_str + + set ulen [string length $urllog_shorturl_str] set u1 [expr $utime / ($ulen * $ulen)] set utmp [expr $utime % ($ulen * $ulen)] set u2 [expr $utmp / $ulen] set u3 [expr $utmp % $ulen] - return "\[ $urllog_shorturl_prefix[string index $ustr $u1][string index $ustr $u2][string index $ustr $u3] \]" + return "\[ $urllog_shorturl_prefix[string index $urllog_shorturl_str $u1][string index $urllog_shorturl_str $u2][string index $urllog_shorturl_str $u3] \]" +} } @@ -405,8 +407,13 @@ } ### Check now if we have an ShortURL here ... - if {$urllog_shorturl != 0 && [string match "*$urllog_shorturl_prefix*" $urlStr]} { + if {[string match "$urllog_shorturl_prefix*" $urlStr]} { urllog_log "Ignoring ShortURL from $urlNick: $urlStr" + set uud "" + set usql "SELECT id AS uid, url AS uurl, user AS uuser, host AS uhost, chan AS uchan, title AS utitle FROM urls WHERE utime=$uud" + urldb eval $usql { + + } return 0 } @@ -511,9 +518,9 @@ # Found character set encoding information in HTTP headers } - if {[regexp -nocase -- "" $udata umatches uenc_doc]} { + if {[regexp -nocase -- "" $udata umatches uenc_doc]} { # Found old style HTML meta tag with character set information - } elseif {[regexp -nocase -- "" $udata umatches uenc_doc]} { + } elseif {[regexp -nocase -- "" $udata umatches uenc_doc]} { # Found HTML5 style meta tag with character set information } @@ -524,6 +531,9 @@ # KLUDGE! set uencoding $uenc_http2 + putlog "got charsets : http='$uenc_http', doc='$uenc_doc' / sanitized http='$uenc_http2', doc='$uenc_doc2'" + + # Check if the document has specified encoding if {$uenc_doc != ""} { # Does it differ from what HTTP says? @@ -546,6 +556,9 @@ urllog_log "Error in charset conversion: $cerrmsg" } } + +# putlog "xxx: $uencoding : '$urlTitle'" +# return 0 # Convert some HTML entities to plaintext and do some cleanup set utmp [urllog_convert_ent $urlTitle]