Просмотр файла forum/addpost.php

Размер файла: 1.97Kb
  1. <?php
  2. include_once "../config.php";
  3. include_once "../inc/inc.php";
  4. include_once "../inc/func.php";
  5. include_once "../inc/user.php";
  6.  
  7. $thema = (int)$thema;
  8. if ($thema == 0) {
  9. header ("Location: index.php?thema=$thema");
  10. exit;
  11. }
  12. if ($kto == 'guest') {
  13. header ("Location: index.php?thema=$thema");
  14. exit;
  15. }
  16. if ($kto == 'user') {
  17. $query = "SELECT tema_nomer FROM " . $pref . "tema WHERE id=" . $thema;
  18. $ids = implode(mysql_fetch_assoc(mysql_query($query)));
  19. if ($ids == '') {
  20. header ("Location: index.php");
  21. exit;
  22. }
  23. $msg = htmlspecialchars(stripslashes($msg));
  24. if (strlen($msg) <= 2) {
  25. header("Location: index.php?thema=$thema");
  26. exit;
  27. }
  28. if (strlen($msg) >= 1025) {
  29. header("Location: index.php?thema=$thema");
  30. exit;
  31. }
  32. $zapros2 = 'INSERT INTO ' . $pref . 'tema_random_' . $ids . ' (login, id_user, data, datatext, msg, ip, brow) VALUES ("' . $login . '", ' . (int)$usdata['id'] . ', ' . time() . ', "' . vrem() . ' - ' . data() . '", "' . $msg . '", "' . ip() . '", "' . brow() . '");';
  33. mysql_query($zapros2);
  34. $query = "SELECT * FROM " . $pref . "tema WHERE id=" . $thema;
  35. $res = mysql_fetch_array(mysql_query($query));
  36. $all_posts = $res['all_post'] + 1;
  37. $in_razd = $res['in_razd'];
  38. $name_tema = $res['name_tema'];
  39. $query = "UPDATE " . $pref . "tema SET all_post=" . $all_posts . ", last_post='" . $login . "', last_post_id=" . (int)$usdata['id'] . ", data_last=" . time() . ", data_last_post=" . time() . " WHERE tema_nomer=" . $ids;
  40. mysql_query($query) or die ('ERROR');
  41. $query = "UPDATE " . $pref . "forum SET last_theme_id=" . $thema . ", last_theme='" . $name_tema . "', last_autor='" . $login . "', last_autor_id=" . (int)$usdata['id'] . ", last_time='" . data() . " - " . vrem() . "' WHERE id=" . $in_razd;
  42. mysql_query($query) or die ('ERROR');
  43. header ("Location: index.php?thema=$thema&info=postok");
  44. exit;
  45. }
  46.  
  47. ?>