Jump to content


Photo

A few questions (may also be mySQL related as well as PHP related).


  • Please log in to reply
6 replies to this topic

#1 Chesso

Chesso
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 31 August 2006 - 08:55 AM

I haven't had a chance to do any heavy searching yet as I need to head off for a bit very soon (but will do so when I get back).

NOTE: Anything striked through I have managed to implement already.

First off, I am considering implementing some form of spam protection both on my custom forums and shoutbox (I made them from scratch myself), I have seen forums use a timer for each user (eg. You cannot make another post for 30 seconds) which seems like a good idea to me, but I have no idea how that would work, I haven't made anything involving a counter like that before.

I would also like to create a web chat accesible from the members page. I suppose I would prefer something that rely's more on the client rather than throttle the server. The only tutorials I have managed to find involve PHP/mySQL only and relying on mySQL or text files on the server for that matter with possible constant messaging seems a bit iffy to me.

Oh yes and possibly a rather larger one. I really don't know what keywords to use to search for this, but when adding a post or modifying a post on my forum I do allow some HTML tags, but I would prefer to have some sort of small bb code implementation (with buttons etc) or atleast some options accesible via a mouse that sticks the html in automatically.

An explanation or link to somewhere that can help me with any of these is greatly appreciated. I have been mostly fixing up my site for XHTML 1.0 Transitional compliance and syntax etc.

Oh and the latest update (my latest updates are still being built and tested locally) you can see on my website, here: http://www.chessoscorner.com, it may give a better idea of what I mean for the Shoutbox/Forum.

Any help is greatly appreciated :).

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 31 August 2006 - 01:01 PM

1. restrict posting based on time - this is a pretty simple thing to do once you have the concept down. basically, you simply record the timestamp and user information of the person posting, you define your time limit, and when the next post is attempted, run a search for comments posted by that user within the last 30 seconds (or however long your timeout is). if there is a record returned, don't let them post it.

2. chat - you'll be best off to check out some AJAX things. instead of refreshing the whole page every time, you can simply request the latest chat content from your web server and update the chatbox area. that way, you can check via javascript the refresh rate, and your server load should be very low since you're only running the one hit each time. if your concern is bandwidth, use mySQL. if your concern is database load, use flat files to keep the current chat stored.

3. bbcode - there are several discussions about bbcode editors, but here's the basic script to allow for [b] and [i] tags. you can go from there to add whatever you want:
<?php
function BBEncode($String) {
  $tags = array(
    "|\[b\](.+?)\[/b\]|ims",
    "|\[i\](.+?)\[/i\]|ims"
  );

  $replace = array(
    '<b>$1</b>',
    '<i>$1</i>'
  );

  return preg_replace($tags, $replace, $String);
}
?>

hope this starts to give you a little insight to your problems. let me know if there's any clarification you need.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 Chesso

Chesso
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 31 August 2006 - 01:16 PM

I have managed the posting restriction for forums and shoutbox, they are all tied together and affected by the same values. 30 seconds isn't exactly long anyway, it's mostly just to prevent insanly mass spamming :P.

I'm still looking up on chat, it really looks like I'm either going to dive deeper into Flash 8 or dive into Java and make an applet for it, depends if I feel it is worth it or not (I know enough programming/scripting languages as it is......, I even get the point that I feel like I'm neglecting half of the, lol).

The BB code thing would be nice. For now I think I will start off just using the allowed HTML tags (any sort of text field has everything that could be funky stripped except plain text and some html tags, like bold, underline, strike, italic etc).

Do you have any advice on the forum/message bit, like how the buttons should work for insertion into the text field (I use a plain html input text field type for now), as I know insertion of things isn't the best and I haven't done any selection manipulation and replacing regarding text fields.

Plenty of that in a programming language but have not done it in a web application, plus I'm not sure on what keywords to use to search for some that information.

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 31 August 2006 - 01:21 PM

javascript is about the only way to go with the manipulation of data in the textarea. i've toyed with it some, but trying to manipulate selected text is something that is extremely difficult since there are about 3 different required methods to go about it for major browsers. the best resource for that would be google. hate to be so vague on that, but in a case like this where there really isn't just one right answer, it will probably be your best friend.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#5 Chesso

Chesso
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 31 August 2006 - 03:13 PM

Hmmmm I can't really find much relevant let alone usefull.

The base of what I am looking for right now is just the method of allowing the user to select text in a textarea control as per usualy but when clicking on one of the buttons (like the editor for this forum) it will slap an open tag for w/e at the start of the selection and slap a close tag for w/e at the end.

I already have the basic function definition where you just feed it string paramater that is the tag you want (eg. b or i) so you call the function from the button etc, and just pass what tag it's for.

Just the selection and modify part (the hard part heh heh) I can't find much information on.

#6 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 31 August 2006 - 03:25 PM

here's a place to start: http://www.netadmint...com/art466.html
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#7 Chesso

Chesso
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 01 September 2006 - 06:27 AM

Ok well the editor for administration pages and forum is all done. Made it extensbile so all I need to do is paste a variable declaration, include and make sure the textarea has id attribute setup and it works heh.

I couldn't manage to get insertion into cursor position though so I had to settle for inserting at the end. Which is kind of gay seen as many, many, many programs even such as word or notepad made in programming languages have the functionality for years and years now but nothing official for the web *shrugs*.

The only thing I'm worried about now is making a web Chat. Still not sure on what way to go, I would prefer to build it all myself rather than rely on a third party one.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users