Guest User

Untitled

a guest
May 20th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.44 KB | None | 0 0
  1. //form per aggiungere un commento
  2. if(@$_GET['action'] == 'comment') {
  3. $code = NULL;
  4.  
  5. for ($i = 0; $i < 3; $i++)
  6. $code .= chr (rand (65,90));
  7.  
  8. for ($i = 0; $i < 4; $i++)
  9. $code .= rand (0,9);
  10.  
  11. $_SESSION['captcha'] = $code;
  12.  
  13. $hash = md5 (rand (0,9999999));
  14.  
  15. $_SESSION['hash'] = $hash;
  16.  
  17. print "\n<br />"
  18. . "\n<form name=\"addcomment\" action=\"viewpost.php?id=".$this->id."&action=send_comment\" method=\"POST\" onSubmit=\"return check();\">"
  19. . "\n<b>".$lang['name'].":</b><br /><input type=\"text\" name=\"name\" /><br /><br />"
  20. . "\n<b>".$lang['commit'].":</b><br /><textarea name=\"comment\" cols=\"30\" rows=\"2\"></textarea><br /><br />"
  21. . "\n<span id=\"captcha\"><img src=\"lib/captcha.php?hash=".$hash."&rnd=".rand(0,9999)."\" /></span> - <a href=\"javascript:reload_captcha('".$hash."');\">Reload Captcha</a><br /><br />"
  22. . "\n".$lang['add_captcha_code'].":<br />"
  23. . "\n<input type=\"text\" name=\"captcha\" id=\"captcha\"><br /><br />"
  24. . "\n<input type=\"submit\" value=\"".$lang['send']."\" />"
  25. . "\n</form>";
  26. }elseif(@$_GET['action'] == 'send_comment') {//aggiunta reale del commento
  27. $key_generate = strtoupper($_SESSION['captcha']);
  28. $captcha = strtoupper($_POST['captcha']);
  29.  
  30. if($captcha != $key_generate)
  31. die( "<script>alert(\"".$lang['no_match_captcha']."\"); window.location=\"viewpost.php?id=".$this->id."&action=comment\";</script>");
  32.  
  33. if(empty($_POST['name']) || empty($_POST['comment'])) //Controllo se i campi sono riempiti oppure no
  34. die( "<script>alert(\"".$lang['fill_camp']."\");</script>");
  35.  
  36. if (strlen($_POST['comment']) > 500)
  37. die( "<script>alert(\"".$lang['long_comment']."\");</script>");
  38.  
  39. $commento = $this->VarProtect( $_POST['comment'] );
  40. $name = $this->VarProtect( $_POST['name'] );
  41. $ip = $_SERVER['REMOTE_ADDR'];
  42.  
  43. //eseguo query di isnerimento
  44. $this->sql->sendQuery("INSERT INTO ".__PREFIX__."comments (blog_id, name, comment, ip) VALUES ('".$this->id."', '{$name}', '{$commento}', '{$ip}')");
  45. header("Location: viewpost.php?id=".$this->id);
  46. }
  47.  
  48. $this->comments = $this->sql->sendQuery("SELECT * FROM ".__PREFIX__."comments WHERE blog_id = '{$id}'");
  49.  
  50. //cascata di commenti per il post
  51. if(mysql_num_rows($this->comments) < 0) {
  52. echo "\n<br /><br />\n<em>".$lang['no_comment']."</em><br />\n";
  53. }else{
  54. while($row = mysql_fetch_array($this->comments)) {
  55. echo "\n<br /><b>".$lang['name'].":</b>".$row['name']."<br />"
  56. ."\n<b> ".$lang['commit'].": </b>".$row['comment']."<br /><br />";
  57. }
  58. }
  59.  
  60. print "\n</div>\n</div>\n";
Add Comment
Please, Sign In to add comment