Quote database webapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637
  1. <?PHP
  2. function showTags($quote) {
  3. echo '<p class="tags">';
  4. $sql = 'SELECT tag_text, COUNT(*) FROM tags WHERE quote_id = ' . $quote . ' GROUP BY tag_text';
  5. $res = mysql_query($sql);
  6. if (mysql_num_rows($res) == 0) {
  7. echo 'This quote has not been tagged yet';
  8. }
  9. while ($row = mysql_fetch_assoc($res)) {
  10. echo ' <a href="', BASE, 'tag?tag=', htmlentities($row['tag_text'], ENT_QUOTES, 'UTF-8'), '">';
  11. echo htmlentities($row['tag_text'], ENT_QUOTES, 'UTF-8'), '</a>';
  12. }
  13. echo '</p>';
  14. }
  15. function addAutoTags($id) {
  16. $sql = 'SELECT quote_quote FROM quotes WHERE quote_id = ' . $id;
  17. $res = mysql_query($sql);
  18. $text = mysql_result($res, 0);
  19. preg_match_all('/^(?:\[.*?\]|.*?\\|)?\s*<(?:[@+])?([^\s]*?)>/m', $text, $matches);
  20. foreach ($matches[1] as $user) {
  21. mysql_query('INSERT INTO tags (quote_id, tag_text, user_id) VALUES (' . $id . ', \'@' . m($user) . '\', 0)');
  22. }
  23. }
  24. ?>