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.

Generate a template file for php / html output

Old posts that have not been replied to for several years.
Locked
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Generate a template file for php / html output

Post by GodOfSuicide »

I'm currently trying to publish some of my bot's global var's to a php / html page on my shell, but i dont know how to replace the strings in there.

i tried to copy the template -> output file, open it, replace the vars and close it again, but this way kinda suxx.

does anybody know how it would be easy and fast to generate template files for html output ?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You could... write a script for eggdrop that listens for requests for the value of the given variable, and then in php use the socket functions to connect to your script and query whatever values you want and set them as php vars.

But what's wrong with the way you're doing it now?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

that i had to use "exec" -> bot is blocked, that i got to use regsub for each var, etc...
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I don't get it heh. What kind of template are you talking about? Why do you have to use exec? All you're doing is copying the file, use tcl's "file copy" command. Or why don't you have eggdrop create a file with the variables in it, like one per line, and then read it in php?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Ok, the template is for a static web page..

Code: Select all

Bot's nick : <mybotnick>
would be a posibility for example. i used "exec cp $startfile $targetfile", i dont know the TCL commands for copying files.

the targetfile would be for example "output.txt", and in there the <botnick> from the template should have been replaced by $botnick variable.
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

Code: Select all

file copy -force <old file> <new file>
Wcc
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

and how would you do the replacements wcc ?
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

set code "put your code in here"
set code [lreplace [split $code] [lsearch [split $code] "<mybotnick>"] [lsearch [split $code] "<mybotnick>"] $botnick]
puts somefile $code
Elen sila lúmenn' omentielvo
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

GodOfSuicide wrote:and how would you do the replacements wcc ?
There are many ways to do it. One way to do it is make a file with on each line the keyword (i.e. the name of the variable) and its value. Every ten minutes or so you read in the file, get the variable name (the keyword) from each line, and then write back the keyword and its up-to-date value back to file.

Btw, it is a good idea to put all variables you want to display under good scrutiny. Many people have variables which contain passwords etc. for use in scripts. Showing *all* the variables will reveal those passwords.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Papillon wrote:

Code: Select all

set code "put your code in here"
set code [lreplace [split $code] [lsearch [split $code] "<mybotnick>"] [lsearch [split $code] "<mybotnick>"] $botnick]
puts somefile $code
this is how to replace it in one line..
but if the template is longer i would have to check it line by line, and that one i didn't get...it must be something with while not eof $file ...
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

well if you put the whole template into $code then it will replace the first occuranse of "<mybotnick>", if it is more than one place in the template you could use regsub -all "<mybotnick>" $code "$botnick" newcode
$newcode will then hold the updated template
Elen sila lúmenn' omentielvo
Locked