This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

looking for a html script

Old posts that have not been replied to for several years.
Locked
l
lsn
Voice
Posts: 25
Joined: Mon Jul 19, 2004 8:11 am

looking for a html script

Post by lsn »

hy

i need a script who can read from a file (my case noreg.txt) and make a web page
here is the script who write in noreg.txt
set qchan "#somechan"
set qfile noreg.txt
set cmdpfix
if { ![info exists toolbox_loaded] } {
source scripts/alltools.tcl
}

bind pub n ${cmdpfix}noreg add_noreg
bind pub n ${cmdpfix}noreglist list_noreg

#######################################
############ PROCS ####################
#######################################


proc add_noreg {nick uhost hand chan arg} {
if {[string tolower $chan] != [string tolower $::qchan]} {
putserv "NOTICE $nick :You're not in the good channel, try it in $::qchan"
return 0
}
if { $arg == "" } {
putserv "NOTICE $nick :$nick Usage: !noreg #channel"
return 0
}
set file [open $::qfile a]
puts $file "Channel: $arg - Added: [ctime [unixtime]] by: $hand, noreg expires in 14 days !!!"
close $file
putserv "NOTICE $nick :$nick Added noreg chan: $arg"
return 1
}


proc list_noreg {nick host handle channel var} {
global qfile botnick qchan
set fd [open $qfile r]
set abuselist { }
while {![eof $fd]} {
set tmp [gets $fd]
if {[eof $fd]} {break}
set abuselist [lappend abuselist [string trim $tmp]]
}
close $fd
if {[llength $abuselist] == 0} {
putserv "notice $nick :No channel in database."
return 0
}
putserv "notice $nick :List Of NoReg Channels\n"
foreach tmp $abuselist {
putserv "notice $nick :- $tmp"
}
putserv "notice $nick : End of NoReg Channels\n"
return 0
}
my noreg.txt looks like this
Channel: #chan1 - Added: Tue Jul 20 10:04:28 2004 by: lsn, noreg expires in 14 days !!!
Channel: #chan2 - Added: Tue Jul 20 10:31:02 2004 by: lsn, noreg expires in 14 days !!!
Channel: #chan3 - Added: Tue Jul 20 10:49:33 2004 by: lsn, noreg expires in 14 days !!!
Channel: #chan4 - Added: Tue Jul 20 11:41:42 2004 by: lsn, noreg expires in 14 days !!!
etc .....
can you help me whit this ?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

bind pub n !generate noreg:generate

proc noreg:generate {nick uhost hand chan text} {
  if {![file exists "web.txt"]} {
    putserv "PRIVMSG $chan :Sorry, the file seems not to exist." 
    return
  }
  set r [open "result.html" w]
  puts $r "\
  <html>
  <head>
  <meta http-equiv=\"Content-Language\" content=\"en-us\">
  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">
  <title>NoReg</title>
  </head>
  <body>
  <p><b><font face=\"Verdana\">NoReg</font></b></p>
  <table border=\"0\" width=\"50%\" id=\"table1\"><tr>
  <td bgcolor=\"#e6e6e6\" width=\"3%\"><font face=\"Verdana\" size=\"2\"><b>No.</b></font></td>
  <td bgcolor=\"#e6e6e6\" width=\"15%\"><font face=\"Verdana\" size=\"2\"><b>Channel</b></font></td>
  <td bgcolor=\"#e6e6e6\" width=\"60%\"><font face=\"Verdana\" size=\"2\"><b>Date added<b></font></td>
  <td bgcolor=\"#e6e6e6\" width=\"22%\"><font face=\"Verdana\" size=\"2\"><b>Added by</b></font></td>
  </font></tr>
  <tr>"
  set i 0 
  set f [open "web.txt" r] 
  while {[gets $f line]>-1} { 
    incr i 
    regsub -all -- {\002|,} $line "" line
    set channel [lindex $line 1]
    set date [lrange $line 4 8]
    set by [lindex $line 10]
    puts $r "\
    <tr>
    <td bgcolor=\"#f9f9f9\" width=\"3%\"><font face=\"Verdana\" size=\"2\">$i.</font></td>
    <td bgcolor=\"#f9f9f9\" width=\"15%\"><font face=\"Verdana\" size=\"2\">$channel</font></td>
    <td bgcolor=\"#f9f9f9\" width=\"60%\"><font face=\"Verdana\" size=\"2\">$date</font></td>
    <td bgcolor=\"#f9f9f9\" width=\"22%\"><font face=\"Verdana\" size=\"2\">$by</font></td>
    </tr>
    "
  }
  puts $r "\
  </tr>
  </table>
  </body>
  </html>"
  close $f
  close $r
  if {$i} {
    putserv "PRIVMSG $chan :Page generated." 
    } {
    putserv "PRIVMSG $chan :Sorry, the file seems to be empty." 
    set r [open "result.html" w]
    puts $r "\
    <html>
    <head>
    <meta http-equiv=\"Content-Language\" content=\"en-us\">
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">
    <title>NoReg</title>
    </head>
    <body>
    <p><b><font face=\"Verdana\">Sorry, the file seems to be empty.</font></b></p>
    "
    close $r
  }
}
also, replace inside your script from to \002 if you want it with bold. Anyway, the page generated dosen't have bold on it. I've done it cos I'm borred and as an example so use it as one. Change it to suit your needs. :mrgreen:
Once the game is over, the king and the pawn go back in the same box.
l
lsn
Voice
Posts: 25
Joined: Mon Jul 19, 2004 8:11 am

Post by lsn »

yep. its working :mrgreen:
Locked