changeset 150:52350ed97775

urllog: Cleanups, rename/move some global variables.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 27 May 2014 07:12:59 +0300
parents fc2654064339
children 8bf27e277672
files urllog.tcl
diffstat 1 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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 -- "<meta.\*\?content=\"text/html.\*\?charset=(\[^\"\]*)\".\*\?/>" $udata umatches uenc_doc]} {
+    if {[regexp -nocase -- "<meta.\*\?content=\"text/html.\*\?charset=(\[^\"\]*)\".\*\?/\?>" $udata umatches uenc_doc]} {
       # Found old style HTML meta tag with character set information
-    } elseif {[regexp -nocase -- "<meta.\*\?charset=\"(\[^\"\]*)\".\*\?/>" $udata umatches uenc_doc]} {
+    } elseif {[regexp -nocase -- "<meta.\*\?charset=\"(\[^\"\]*)\".\*\?/\?>" $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]