Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Smilies parser (php)
#11
:o Didn't know you could make a tagboard with javascript...anyway, it's a lot simpler with php! :wink:
PHP never ceases to amaze me...
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#12
Untested:

Code:
$htmlbody = '
<html>
  <head>
  </head>
  <body>
   :) ;)
  </body>
</html>';

$smilie = array(

':)' => '<img src = "smilie01.gif">',
';)' => '<img src = "smilie02.gif">'

// and so on

);

while (list($name, $value) = each($smilie)) {

str_replace($name, $value, $htmlbody);

}

ECHO $htmlbody;
B 4 EVER
Reply
#13
You can do most everything in Javascript (before I learned perl I even once wrote a multi-field searchable member database in it), but I wouldnt unless you want it calculated client-side. For instance, realtime stuff should be Javascript but "do once" stuff should be your CGI program.

Now, you might want to replace less than and greater than tags with this:

"&#60"; for "<"
"&#62"; for ">"

as to ensure browser compatbility.

also, dont forget to replace ampersands themselves, before you do carrots:

"&" for "&"

after that, you should be clear to go.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#14
Can you access server-side files with Javascript?
Anyway, this doesn't seem to work:
Code:
preg_match ("/\:\)/g","<img src='smile.gif'>",$message);
There's an error on the g...
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#15
no. that's the point, Javascript is a small script that runs within your html file. The only external files it can access are other .js files, or files already loaded by the html page.

the error is becasue you're using preg_match. use preg_replace, if you want to replace something. preg_match only checks to see if the patter exists within the string, so the "g" is useless.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#16
Righty-O. Thanks.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#17
Quote::o Didn't know you could make a tagboard with javascript
hehe. Ya can't. That's why I gave up :p
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#18
Lol. :wink:
Because...you need file i/o or database accessing, right?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#19
Quote:Lol. :wink:
Because...you need file i/o or database accessing, right?
Yep.
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)