witajcie, skierowano mnie na to forum - podobno zawsze dacie radę smile.gif
mam problem z skryptem który można pobrać z http://www.phpcaptcha.org
Jest tam instrukcja (http://www.phpcaptcha.org/?page_id=8) jak ten skrypt połączyć ze swoją stroną. Używam CutePHP i jest to dla mnie za skomplikowane aby samodzielnie zrobić. Oczywiście z formularzem sobie poradziłem ale mam problem z drugą częścią, która sprawdza przepisane znaki. Bądźcie wyrozumiali - jestem "przedszkolakiem". Będę wdzięczny za pomoc.

Oto część kodu CutePHP gdzie odbywa się zapisywanie komentarza (plik inc/shows.inc.php):

  1. <?PHP
  2. include_once("$cutepath/langdate.php");
  3.  
  4. do{ // Used if we want to display some error to the user and halt the rest of the script
  5.  
  6. $user_query = cute_query_string($QUERY_STRING, array( "comm_start_from","start_from", "archive", "subaction", "id", "ucat"));
  7. $user_post_query = cute_query_string($QUERY_STRING, array( "comm_start_from", "start_from", "archive", "subaction", "id", "ucat"), "post");
  8.  
  9. //##############################
  10. // Add Comment
  11. //##############################
  12.  
  13. if($allow_add_comment){
  14.  
  15. $name = trim($name);
  16. $mail = trim($mail);
  17. $id = (int) $id; // Yes it's stupid how I didn't thought about this :/
  18.  
  19. //----------------------------------
  20. // Check the lenght of comment, include name + mail
  21. //----------------------------------
  22.  
  23. if( strlen($name) > 50 ){
  24. echo"<div style=\"text-align: center;\">Twoja nazwa jest za długa!</div>";
  25. $CN_HALT = TRUE;
  26. break 1;
  27. }
  28. if( strlen($mail) > 50){
  29. echo"<div style=\"text-align: center;\">Twój e-mail jest za długi!</div>";
  30. $CN_HALT = TRUE;
  31. break 1;
  32. }
  33. if( strlen($comments) > $config_comment_max_long and $config_comment_max_long != "" and $config_comment_max_long != "0"){
  34. echo"<div style=\"text-align: center;\">Twój komentarz jest za długi</div>";
  35. $CN_HALT = TRUE;
  36. break 1;
  37. }
  38.  
  39.  
  40. //----------------------------------
  41. // Add The Comment ... Go Go GO!
  42. //----------------------------------
  43.  
  44. $old_comments = file("$comm_file");
  45. $new_comments = fopen("$comm_file", "w");
  46. @flock ($new_comments,2);
  47. $found = FALSE;
  48. foreach($old_comments as $old_comments_line)
  49. {
  50. $old_comments_arr = explode("|>|", $old_comments_line);
  51. if($old_comments_arr[0] == $id)
  52. {
  53. $old_comments_arr[1] = trim($old_comments_arr[1]);
  54. fwrite($new_comments, "$old_comments_arr[0]|>|$old_comments_arr[1]$time|$name|$mail|$ip|$comments||\n");
  55. $found = TRUE;
  56. }else{
  57. fwrite($new_comments, $old_comments_line);
  58. //if we do not have the news ID in the comments.txt we are not doing anything (see comment below) (must make sure the news ID is valid)
  59. }
  60. }
  61. if(!$found){
  62. /* // do not add comment if News ID is not found \\ fwrite($new_comments, "$id|>|$time|$name|$mail|$ip|$comments||\n");*/
  63.  
  64. echo("<div style=\"text-align: center;\">CuteNews nie dodał twojego komentarza, gdyż wyst?pił problem z baz? danych.<br /><a href=\"java script:history.go(-1)\">powrót</a></div>");
  65. $CN_HALT = TRUE;
  66. break 1;
  67. }
  68. @flock ($new_comments,3);
  69. fclose($new_comments);
  70.  
  71. //----------------------------------
  72. // Sign this comment in the Flood Protection
  73. //----------------------------------
  74. if($config_flood_time != "0" and $config_flood_time != "" ){
  75.  
  76. $flood_file = fopen("$cutepath/data/flood.db.php", "a");
  77. @flock ($flood_file,2);
  78. fwrite($flood_file, time()."|$ip|$id|\n");
  79. @flock ($flood_file,3);
  80. fclose($flood_file);
  81. }
  82. //----------------------------------
  83. // Notify for New Comment ?
  84. //----------------------------------
  85.  
  86. if($config_notify_comment == "yes" and $config_notify_status == "active"){
  87. send_mail("$config_notify_email", "CuteNews - Dodano Nowy Komentarz", "Został dodany nowy komentarz przez $name:\n--------------------------$comments");
  88. }
  89.  
  90. echo "<script type=\"text/javascript\">window.location=\"$PHP_SELF?subaction=showfull&id=$id&ucat=$ucat&archive=$archive&start_from=$start_from&$user_query\";</script>";
  91. }


Dzięki!