PHP - Adding Recaptcha To Php Script
I have been getting a lot of bots spamming this script, and need to add captcha to it. I am new to php and was wondering if someone would help me with this issue. Below is the script, and I really would appreciate the help.
Code: [Select] <?php include "admin/conf.php"; $setting1="SELECT * FROM ".$prefix."settings"; $setting2=mysql_query($setting1) or die("Sorry, Could not select sites table"); $setting=mysql_fetch_array($setting2); include "lang/$setting[lang]/main.php"; print "<title>$lang_reg1</title>"; print "<link rel='stylesheet' href='skin/$setting[style]/style.css' type='text/css'>"; print "<body bgcolor='#FFFFFF'>"; print "<table cellpadding='0' cellspacing='0' align='center' class='outtable'><tr><td>"; /*----------------- Bread ------------------*/ print "<br /><table><tr><td width='100%'><a href='index.php'>$setting[title]</a> > $lang_reg4</td></tr></table><br />"; /*----------------- Bread End ------------------*/ print "<table cellpadding='0' cellspacing='0' align='center' width='100%'><tr><td valign='middle'><img src='skin/$setting[style]/images/pen.gif' style='vertical-align: middle;'></td> <td valign='middle'>$lang_reg1</td></tr></table>"; print "<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td><img src='skin/$setting[style]/images/cat_left_shadow.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/cat_left.gif' style='vertical-align: middle;'></td> <td class='tilecat' width='100%'><img src='skin/$setting[style]/images/tile_back.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/cat_right.gif' style='vertical-align: middle;'></td><td><img src='skin/$setting[style]/images/cat_right_shadow.gif' style='vertical-align: middle;'></td> </tr></table>"; print "<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td class='shadowL'><img src='skin/$setting[style]/images/left_shadow.gif' style='vertical-align: middle;'></td> <td width='100%'>"; print "<form name='topsite' action='source/reguser.php' method='post' onSubmit='return check_it();'>"; print "<table cellspacing='0' cellpadding='2' align='center' class='maintable'>"; print "<tr><td colspan='2' class='titlemedium' style='padding: 3px;' align='center'>$lang_reg4</td></tr>"; print "<tr><td class='tileshadow' colspan='2' align='center'><img src='skin/$setting[style]/images/spacer.gif' width='1' height='3' alt='' /></td></tr>"; print "<tr class='row5'><td nowrap valign='top'>$lang_reg5</td>"; print "<td><input type='text' name='topsiteuser' size='60'></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg6</td>"; print "<td><input type='password' name='password' size='60'></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg7</td>"; print "<td><input type='text' name='email' size='60'></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg8</td>"; print "<td><input type='text' name='title' size='60'></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg9</td>"; print "<td><input type='text' name='url' size='60' value=''></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg10</td>"; print "<td><input type='text' name='button' size='60' value=''> <a href=\"javascript:void(window.open('http://www.imageshack.us/iframe.php?txtcolor=111111&type=blank&size=30','','height=100,width=275,left=0,top=0,toolbar=0,scrollbars=0'))\" target=\"_self\"><font face=\"Arial\" size=\"1\">UPLOAD HERE</font></a></td></tr>"; $selects="SELECT * FROM ".$prefix."categories where 1"; $selects2=mysql_query($selects) or die("Sorry, Could not select"); $selects3=mysql_fetch_array($selects2); if($selects3[ID]<1) {print"";}else { print "<tr class='row5'><td valign='top'>$lang_reg11</td>"; $selectcategory="SELECT * FROM ".$prefix."categories"; $selectcategory2=mysql_query($selectcategory) or die("Sorry, Could not select category"); print "<td><select name='catname'>"; $selectcategory="SELECT * FROM ".$prefix."categories"; $selectcategory2=mysql_query($selectcategory) or die("Sorry, Could not select category"); while($selectcategory3=mysql_fetch_array($selectcategory2)) {print "<option>$selectcategory3[catname]</option>";} print "</select></td></tr>";} print "<tr class='row5'><td width='40%' valign='top'>$lang_reg13<br>$lang_reg12</td>"; print "<td width='60%' ><textarea name='description' rows='5' cols='50'></textarea></td></tr>"; print "</table><br /><br />"; print "</td> <td class='shadowR'><img src='skin/$setting[style]/images/right_shadow.gif' style='vertical-align: middle;'></td> </tr></table>"; print"<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td><img src='skin/$setting[style]/images/mainfoot_left_shadow.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/mainfoot_left.gif' style='vertical-align: middle;'></td> <td class='footer' width='100%'><img src='skin/$setting[style]/images/mainfoot.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/mainfoot_right.gif' style='vertical-align: middle;'></td><td><img src='skin/$setting[style]/images/mainfoot_right_shadow.gif' style='vertical-align: middle;'></td> </tr></table><br />"; print "<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td><img src='skin/$setting[style]/images/cat_left_shadow.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/cat_left.gif' style='vertical-align: middle;'></td> <td class='tilecat' width='100%'><img src='skin/$setting[style]/images/tile_back.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/cat_right.gif' style='vertical-align: middle;'></td><td><img src='skin/$setting[style]/images/cat_right_shadow.gif' style='vertical-align: middle;'></td> </tr></table>"; print "<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td class='shadowL'><img src='skin/$setting[style]/images/left_shadow.gif' style='vertical-align: middle;'></td> <td width='100%'>"; print "<table cellspacing='0' cellpadding='2' align='center' class='maintable'>"; print "<tr><td class='titlemedium' style='padding: 3px;' align='center'>$lang_rul</td></tr>"; print "<tr><td class='tileshadow' align='center'><img src='skin/$setting[style]/images/spacer.gif' width='1' height='3' alt='' /></td></tr>"; print "<tr class='row5'><td nowrap valign='top' align='center'><textarea cols='60' rows='10'>$setting[rules]</textarea></td></tr>"; Print"<tr><td class='subs' colspan='2' align='center'><input type='submit' name='submit' value='$lang_agree'></td></tr></table></form>"; print "</td> <td class='shadowR'><img src='skin/$setting[style]/images/right_shadow.gif' style='vertical-align: middle;'></td> </tr></table>"; print"<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td><img src='skin/$setting[style]/images/mainfoot_left_shadow.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/mainfoot_left.gif' style='vertical-align: middle;'></td> <td class='footer' width='100%'><img src='skin/$setting[style]/images/mainfoot.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/mainfoot_right.gif' style='vertical-align: middle;'></td><td><img src='skin/$setting[style]/images/mainfoot_right_shadow.gif' style='vertical-align: middle;'></td> </tr></table><br />"; print "<table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr><td colspan='$cols' nowrap style='padding: 3px;' id='runtime' ><div><span><center>$setting[magic]</center></span></div></td></tr></table>"; print "</td></tr></table>"; ?> Similar TutorialsI am a php newbie and with help from someone on this forum managed to get my php form working. I am now trying to add recaptcha 3 but can't get it to work. I have added my code to this post and would appreciate some pointers. <?php /* This is the Header PHP file */ ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content="My Name"> <title>My Title</title> <!--Bootstrap Core CSS--> <link href="assets/css/bootstrap.min.css" rel="stylesheet"> <!--Font Awresome Icons--> <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600&display=swap" rel="stylesheet"> <!--Google Fonts--> <link href="assets/css/fontawesome/css/all.min.css" rel="stylesheet"> <!--Adobe Typekit Fonts--> <link href="https://use.typekit.net/jtf1geg.css" rel="stylesheet"> <!--Custom CSS--> <link href="assets/css/custom.css" rel="stylesheet"> <!--Favicon--> <link rel="icon" type="image/png" sizes="32x32" href="assets/img/MyFavicon32WhiteAlt.png"> <!--Google reCaptcha--> <script src="https://www.google.com/recaptcha/api.js"></script> <script> function onSubmit(token) { document.getElementById("contact-form").submit(); } </script> </head> <body> <!--HEADER--> <header class="site-header"> <!--Navbar--> <nav class="navbar"> <!-- Navbar brand --> <div class="navbar-brand"> <img src="assets/img/myLogo.png" id="wd-logo" alt="My Logo"> </div> <!-- Linking Menu Text to Collapse Button --> <div class="menu-button"> <button class="navbar-toggler button" type="button" data-toggle="collapse" data-target="#navbarSupportedContent20" aria-controls="navbarSupportedContent20" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-text">Menu</span> </button> <!-- Collapse Button --> <button class="navbar-toggler button animated-icon" type="button" data-toggle="collapse" data-target="#navbarSupportedContent20" aria-controls="navbarSupportedContent20" aria-expanded="false" aria-label="Toggle navigation"> <span></span> <span></span> <span></span> </button> <!-- Collapse Button End --> </div> <!-- Linking Menu Text to Collapse Button End --> <!-- Collapsible content --> <div class="collapse navbar-collapse" id="navbarSupportedContent20"> <!-- Links --> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="index.php">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="contact.php">About</a> </li> <li class="nav-item"> <a class="nav-link" href="contact.php">Services</a> </li> <li class="nav-item"> <a class="nav-link" href="contact.php">Our Work</a> </li> <li class="nav-item active"> <a class="nav-link" href="contact.php">Contact<span class="sr-only">(current)</span></a> </li> </ul> <!-- Links End --> </div> <!-- Collapsible Content End --> </nav> <!--Navbar End--> </header> <!--Header End--> <hr> <!--Content--> <section class="main"> <?php // This is the contact form // Message Vars $msg = ''; $msgClass = ''; // Check to see if the form has been submitted if(filter_has_var(INPUT_POST, 'submit')) { // Input Data Variables $firstname = htmlspecialchars($_POST['firstname']); $lastname = htmlspecialchars($_POST['lastname']); $phonenumber = htmlspecialchars($_POST['phonenumber']); $email = htmlspecialchars($_POST['email']); $dropdown = htmlspecialchars($_POST['selectdropdown']); $message = htmlspecialchars($_POST['message']); $checkbox = htmlspecialchars($_POST['checkbox'] ?? 0); // Check required fields if(!empty($firstname) && !empty($lastname) && !empty($phonenumber) && !empty($email) && !empty($dropdown) && !empty($message) && !empty($checkbox)) { // If passed, check email address if(filter_var($email, FILTER_VALIDATE_EMAIL) === false) { // If failed, Email address is not valid $msg = 'Please use a valid email address'; $msgClass = 'alert-danger'; } else { // Recipient email address and information to be sent to them $toEmail = 'hello@example.co.uk'; $subject = 'Contact Request from Website'; $body = '<h2>Contact Request</h2> <h4>Name</h4><p>'.$firstname. ' '.$lastname.'</p> <h4>Phone Number</h4><p>'.$phonenumber.'</p> <h4>Email Address</h4><p>'.$email.'</p> <h4>Subject</h4><p>'.$dropdown.'</p> <h4>Message</h4><p>'.$message.'</p>'; // Email Headers $headers = "MIME-VERSION: 1.0" ."\r\n"; $headers .="Content-Type:text/html;charset=UTF-8" ."\r\n"; // Additional Headers $headers .= "From: " .$firstname. "".$lastname." <".$email.">" ."\r\n"; $recaptcha_url = "https://www.google.com/recaptcha/api/siteverify"; $recaptcha_secret ="secrettoken"; $recaptcha_response = $_POST['g-recaptcha-response']; $recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response); $recaptcha = json_decode($recaptcha, true); if($recaptcha['success'] == 1 AND $recaptcha['score'] >= 0.5 AND $recaptcha['action'] == "submit") { if(mail($toEmail, $subject, $body, $headers)) { // Message Sent $msg = 'Verfication successful, your message has been sent'; $msgClass = 'alert-success'; } else { // Message failed $msg = 'Your message has NOT been sent'; $msgClass = 'alert-danger'; } } } } else { // Failed $msg = 'Please fill in all fields'; $msgClass = 'alert-danger'; } } ?> <div class="container clearfix content-container"> <h1 class="section-title">Contact Us</h1> <p>If you have any questions about the services we provide or would like to chat about a new website project, please get in touch using any of the options below. We would love to hear from you!</p> <!--Contact Page Row--> <div class="row"> <div class="col-lg-6 contact-details"> <div class="row"> <div class="col-lg-12"> <img src="assets/img/contact-us.jpg" class="img-responsive d-block contact-image" alt="Contact Us Image"> </div> </div> <div class="row"> <div class="col-lg-12 contact-name"> <span class="d-inline-block contact-inline-block"><i class="fas fa-user fa-2x"> </i></span> <span class="d-inline-block"><p class="contact-details">me</p></span> </div> </div> <div class="row"> <div class="col-lg-12 contact-phone"> <span class="d-inline-block contact-inline-block"><a href="tel:01234 567890"><i class="fas fa-mobile-alt fa-2x"></i></a></span> <span class="d-inline-block"><a href="tel:01234 567890"><p class="contact-details">01234 567890</a></p></span> </div> </div> <div class="row"> <div class="col-lg-12 contact-email"> <span class="d-inline-block contact-inline-block"><a href="mailhandler.php"><i class="fas fa-envelope-square fa-2x"></i></a></span> <span class="d-inline-block"><a href="mailhandler.php"><p class="contact-details">hello@wexample.co.uk</a></p></span> </div> </div> <div class="row"> <div class="col-lg-12 contact-fb"> <span class="d-inline-block contact-inline-block"><a href="https://www.facebook.com/example/" target="_blank"><i class="fab fa-facebook-square fa-2x"></a></i></span> <span class="d-inline-block"><a href="https://www.facebook.com/example/" target="_blank"><p class="contact-details">@example</a></p></span> </div> </div> </div> <!--Contact Form--> <div class="col-lg-6 contact-form d-block"> <?php if($msg != ''): ?> <div class="alert <?php echo $msgClass; ?>"><?php echo $msg; ?></div> <?php endif;?> <form method="post" action="contact.php" role="form" id="contact-form"> <div class=" row form-group"> <div class="col-lg-6"> <label for="firstnameid">First name<span class="asterisk"> *</span></label> <input type="text" name="firstname" class="form-control mb-3" id="firstnameid"> </div> <div class="col-lg-6"> <label for="lastnameid">Last name<span class="asterisk"> *</span></label> <input type="text" name="lastname" class="form-control mb-3" id="lastnameid"> </div> </div> <div class="row form-group"> <div class="col-lg-6"> <label for="phonenumber">Phone number<span class="asterisk"> *</span></label> <input type="tel" name="phonenumber" class="form-control mb-3" id="phonenumberid"> </div> <div class="col-lg-6"> <label for="emailid">Email address<span class="asterisk"> *</span></label> <input type="email" name="email" class="form-control mb-3" id="emailid"> </div> </div> <div class="row form-group"> <div class="col-lg-12"> <label for="subjectid">How can we help<span class="asterisk"> *</span></label> <select class="form-control mb-3" name="selectdropdown" id="subjectid"> <option value="">Please choose an option</option> <option value="I would like to discuss a project">I would like to discuss a project</option> <option value="Existing Web 2 Digital client enquiry">Existing client enquiry</option> <option value="General enquiry">General enquiry</option> </select> </div> </div> <div class="row form-group"> <div class="col-lg-12"> <label for="messageid">Tell us a little bit more<span class="asterisk"> *</span></label> <textarea name="message" class="form-control mb-3" id="messageid" rows="6"></textarea> </div> </div> <div class="row form-group"> <div class="col-lg-12"> <p><span class="asterisk"> *</span> indicates required field</p> </div> </div> <div class="row form-group"> <div class="col-lg-12 form-check"> <input type="checkbox" name="checkbox" class="form-check-input" id="formcheckid"> <label for="formcheckid" class=form-check-label mb-3>By checking this tickbox you have confirmed that we can collect the information in this form for the purposes outlined in our <a href="privacypolicy.php">privacy policy.</a></label> </div> </div> <div class="row form-group"> <div class="col-lg-12"> <button type="submit" name="submit" class="btn btn-primary mt-4 g-recaptcha" data-sitekey="sitetoken" data-callback='onSubmit' data-action='submit'>Send Message </button> </div> </div> </form> </div> <!--Contact Form End--> </div> <!--Contact Page Row End--> </div> <!--Container end--> <?php echo file_get_contents('footer.php'); ?>
Hallo allenmaal,
Weet iemand de moeilijkheidsgraad van deze captcha code. Note! Ik heb een reden waarom ik geen reCaptcha v3 wil gebruiken..
Can someone help me please?.... I'm using this Code: [Select] <form name="form1" method="post" action="create-b.php" enctype="application/x-www-form-urlencoded" style="margin:0px"> <input name="name" value="Anonymous" type="text" MAXLENGTH="15" style="position:absolute;width:650px;left:67px;top:142px;z-index:4"> <input name="subject" value="(No subject)" MAXLENGTH="15" type="text" style="position:absolute;width:650px;left:67px;top:166px;z-index:5"> <textarea name="body" MAXLENGTH="255" type="text" style="position:absolute;left:67px;top:191px;width:650px;height:98px;z-index:6"></textarea> <div id="captcha" style="position:absolute; overflow:hidden; left:10px; top:296px; z-index:8"> <input name="submit" type="submit" value="Create thread" style="position:absolute;left:614px;top:291px;z-index:7"> <?php require_once('captc/recaptchalib.php'); $publickey = "**************************************"; echo recaptcha_get_html($publickey); ?> </form>On the HTML side and this require_once('captc/recaptchalib.php'); $privatekey = "************************"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("<font color='red'><font size='12'><strong><center>The verification code you entered appears to be incorrect!"); } else { CONTENT CONTENT CONTENT CONTENT CONTENT ETC But it always returns "The verification code you entered appears to be incorrect!" Any idea what I'm doing wrong?... I have a webpage which has the following: WEBPAGE <form method="post" action="http://www.xxxx.nz/Scripts/xxxxemail.php" enctype="multipart/form-data"> <div> <input type="hidden" name="redirect" value="http://xxxxxxx.net.nz/xxxxyou.php" /></div> <form> <table border="1"> <tr><td>Company Name (required)</td><td><input type="text" name="Business" /></td></tr> <tr><td>Email Address (required)</td><td><input type="text" name="Email" /></td></tr> <tr><td>Wish To Sign Up For ?</td><td><select size="1" name="xxxxxxx"> <option value="No">No</option> <option value="Yes">Yes</option> xxxxxx xxxxxx xxxxxx <input type="submit" value="Submit for Quote" /></td></tr> xxxxemail.php <?php require '/home/xxxxxz/Includes/connect.php'; /* Assign all variables passed from the form */ $business = mysql_real_escape_string($_POST['Business']); xxxxxx xxxxxx /* Sending email with information to us */ $to = "kerryxxxxx"; $subject = "xxxxx"; $random_hash = md5(date('r', time())); $headers = 'From: xxxxxxx'; $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; ob_start(); ?> --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <!-- Email Content --> <? include '/home/xxxxxx/Includes/laqcquote.inc'; ?> <!-- End of Email Content --> --PHP-alt-<?php echo $random_hash; ?>-- <?php $html = ob_get_contents(); ob_end_clean(); $body = $html; mail($to, $subject, $body, $headers); /* Once Complete return to............*/ header("Location: https://xxxxxxxxxxxxxxxxxxx/qxxxxxyou.php"); ?> if I want to add the recaptcha and have it verify what do i need to do? I have code via recaptcha and it says used a verify.php. If I do that i do not have the web page going through to where I can get the data via email and it does not give me an error message. Can anyone help? This is all new to me and I am struggling to see where I put the recaptcha and to make it work if right and not work if wrong
Hello! I found this code from github. https://github.com/gburtini/Learning-Library-for-PHP and I want to know if its possible to add variables to it and what changes needed to be done to the whole script. $xs and $ys I want replace them and add two more. The whole code is he <?php require_once 'function.php'; function ll_nn_predict($xs, $ys, $row, $k) { $distances = ll_nearestNeighbors($xs, $row); $distances = array_slice($distances, 0, $k); $predictions = array(); foreach($distances as $neighbor=>$distance) { $predictions[$ys[$neighbor]]++; } asort($predictions); return $predictions; } function ll_nearestNeighbors($xs, $row) { $testPoint = $xs[$row]; $distances = _ll_distances_to_point($xs, $testPoint); return $distances; } function _ll_distances_to_point($xs, $x) { $distances = array(); foreach($xs as $index=>$xi) { $distances[$index] = ll_euclidean_distance($xi, $x); } asort($distances); array_shift($distances); return $distances; } and the function.php that is required is this: <?php function ll_transpose($rows) { $columns = array(); for($i=0;$i<count($rows);$i++) { for($k = 0; $k<count($rows[$i]); $k++) { $columns[$k][$i] = $rows[$i][$k]; } } return $columns; } function ll_mean($array) { return array_sum($array)/($array); } function ll_variance($array) { $mean = ll_mean($array); $sum_difference = 0; $n = count($array); for($i=0; $i<$n; $i++) { $sum_difference += pow(($array[$i] - $mean),2); } $variance = $sum_difference / $n; return $variance; } function ll_euclidean_distance($a, $b) { if(count($a) != count($b)) return false; $distance = 0; for($i=0;$i<count($a);$i++) { $distance += pow($a[$i] - $b[$i], 2); } return sqrt($distance); } I just want to know where is the variables in those 2 scripts and add more as I'm not well versed in using PHP. Thank you! I need help adding a feature to the following php script that goes through folders and reads from txt files. Right now it is just grabbing the sub folder name, title and body and exporting it to a csv in columns A B and C respectively. What I need it to do is grab a summary from each txt file as well and added to the 4th column in the csv. I think the best way to do this would be to grab from the beginning of the body, to pre-defined closing }. So If I set it at 25 it will end the summary on the 25th } found in the txt file from the beginning of the body. All the txt is in spintax format like "The {Fox|Bird|Cat} {Stole|Took} The {Food|Water}" Code: [Select] <?php set_time_limit(0); // set unlimited execution time $base_folder = $_POST['base_folder']; $article_to_capture = (int)$_POST['article_to_capture']; $words = explode(',', $_POST['words']); // print_r($words); die(''); if(!is_dir($base_folder)) die('Invalid base folder. Please go <a href="step1.php"><strong>back</strong></a> and enter correct folder.'); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Artcle Scraper Step 2</title> <style type="text/css"> <!-- body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #333333; } --> </style> </head> <body> <h2>Step 2 : Processing the content of the folder. </h2> <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC"> <tr bgcolor="#FFFFFF"> <th width="10%"> </td> <th width="30%">BASE FOLDER NAME</td> <th width="50%"> <?php echo $base_folder;?></td> <th width="10%"> </td> </tr> <?php $subfolder_arr = scandir($base_folder); //print_r($arr1); $total_subfolders = sizeof($subfolder_arr); $subfolder_count = 0; $file_count = 0; $report = ""; $fp = fopen('articles.csv', 'w+'); for($i=0; $i< $total_subfolders; $i++){ $file_name = $subfolder_arr[$i]; if($file_name=='.'||$file_name=='..') continue; $sub_folder_name = $base_folder ."\\". $file_name; $file_type = is_dir($sub_folder_name) ? 'dir' : 'file'; if($file_type=='dir'){ $sub_folder_count++; $rpeort .= "Processing folder $sub_folder_count $sub_folder_name \r\n"; $msg = "Processing folder $sub_folder_count $sub_folder_name \r\n"; ?> <tr bgcolor="#FFFFFF"><td> </td><td colspan="2"> <?php echo $msg;?> </td><td> </td></tr> <tr bgcolor="#FFFFFF"><td> </td><td colspan="2"> <table width="90%" cellpadding="0" cellspacing="0" border="1" bordercolorlight="#0000FF"> <?php // process sub folder $column1 = $file_name; $column2 = '{'; $column3 = '{'; $first = true; $files_arr = scandir($sub_folder_name); $article_processed =0; // article_processed in current sub folder foreach($files_arr as $key=>$val){ if(is_file($sub_folder_name.'\\'.$val) ) { if( substr($val,-4)=='.txt' && (filesize($sub_folder_name.'\\'.$val) <= 35000) && (filesize($sub_folder_name.'\\'.$val) >= 4000)) //file is > 1kb { $size = filesize($sub_folder_name.'\\'.$val); $article_processed++; if($article_to_capture==0 || $article_processed <= $article_to_capture ){ if($first==true) $first=false; else { $column2 .= '|'; $column3 .= '|'; } // read file get title and body $file_content = file($sub_folder_name.'\\'.$val); $file_title = rtrim($file_content[0]); $file_content[0] = ''; $file_arr_size = sizeof($file_content); $words_arr_size = sizeof($words); $t=1; while($t < $file_arr_size){ $file_content[$t] = rtrim($file_content[$t]); //echo $file_content[$t]; //die('inside'); if( $words_arr_size>0 ){ //die('inside'); $temp = str_replace($words, "", $file_content[$t]); $file_content[$t] = $temp; } $t++; //if($t>=3) die('aa'); } $file_body = implode('',$file_content); $column2 .= $file_title; $column3 .= $file_body; ?> <tr><td> <?php //print_r($files_arr); echo $val ."\r\n"; echo round(($size / 1024), 2).' KB'; ?> </td></tr> <?php } //end if .txt } // article processed } // end if is_file } // end foreach ?> </table> </td><td> </td></tr> <?php $column2 .= '}'; $column3 .= '}'; // write to csv / excel file $erro = fputcsv ($fp, array($column1,$column2,$column3) ); } //end if filetype else{ } } // end for fclose($fp); ?> <tr bgcolor="#FFFFFF"> <td> </td> <td colspan=""> File Generated. Download it <a href="articles.csv" target="_blank">HERE</a></td> <td> </td> </tr> </table> </body> </html> So its a virtual pet script I'm making. This script changes the image of the pet with time. It also puts the user's name,in text on the image. For some reason It doesnt turn out too well= http://amiteka.comli.com/viewpet_forum.php?id=1 Can someone tell me what is wrong with the script or how I can make it show something like; Error on line # <?php require_once('./inc/config.php'); function greaterDate($dformat, $beginDate, $endDate) { $subtract = $endDate - $beginDate; if($subtract > 0) { return 1; } else { return 0; } } function check(){ $pid = mysql_real_escape_string($_GET['id']); $result = mysql_query("SELECT * FROM `pets_adopted` WHERE `id` = '{$pid}'"); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $results = mysql_query("SELECT * FROM `pets_list` WHERE `id` = '{$row [petid]}'"); $pet = mysql_fetch_array($results); $results2 = mysql_query("SELECT * FROM `users` WHERE `id` = '{$row [adopter]}'"); $usercc = mysql_fetch_array($results2); if(greaterDate(".", $row[fulldate], date('Ymd')) > 0) { $im = showpet_forum($pet[adulturl]); $image = imagecreatefrompng($im); return imagepng($image); header('Content-type: image/png'); } elseif(greaterDate(".", $row[halfdate], date('Ymd')) > 0 && greaterDate (".", $row[fulldate], date('Ymd')) <= 0){ $im = showpet_forum($pet[teenurl]); $image = imagecreatefrompng($im); return imagepng($image); header('Content-type: image/png'); } elseif(greaterDate(".", $row[halfdate], date('Ymd')) <= 0){ $im = showpet_forum($pet[babyurl]); $image = imagecreatefrompng($im); return imagepng($image); } } } echo check(); ?> Thank you for any help. I found a newsletter script called 'easy newsletter' which allows me to set up a page for users to sign up to a news letter emailing list. There is then another page that a admin can log into and create a simple text email to send out to everyone that has signed up. My problems is i require the email to include a attachment and have no clue how i can add this to the script to get it working. Can anyone help me? The script that sends out the email is included below if this helps: <?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //print header echo $header; ?> <h1><?php echo $title; ?> - Administration</h1> <hr> <?php $pwd = $_GET["pwd"]; //simple login if(isset($pwd) && ($pwd == $password)){ $submit = $_POST["submit"]; $submit_newsletter = $_POST["submit_newsletter"]; $del = $_GET["del"]; //insert new address if(isset($submit)){ $name = $_POST["name"]; $email = $_POST["email"]; @mysql_query("INSERT INTO $db_table (email,name) VALUES ('$email','$name');"); //error occurred if(@mysql_error()){ ?><p>Inserting entry failed: <?php echo @mysql_error(); ?></p> <p><a href="javascript&#058;history.back();">Click here to go back.</a></p><?php //successful }else{ ?><p>Entry has been inserted successfully. <a href="admin.php?pwd=<?php echo $pwd; ?>">Click here to continue.</a></p><?php } //delete an entry }else if(isset($del)){ @mysql_query("DELETE FROM $db_table WHERE id=$del;"); //error occurred if(@mysql_error()){ ?><p>Deleting entry failed: <?php echo @mysql_error(); ?></p> <p><a href="javascript&#058;history.back();">Click here to go back.</a></p><?php //successful }else{ ?><p>Entry has been deleted successfully. <a href="admin.php?pwd=<?php echo $pwd; ?>">Click here to continue.</a></p><?php } //send newsletter }else if(isset($submit_newsletter)){ $sent = 0; $result = @mysql_query("SELECT name,email FROM $db_table ORDER BY email ASC;"); $subject = $_POST["subject"]; $message = $_POST["message"]; ?><p>Sending emails to ...</p> <ul><?php //send emails one by one while($row=@mysql_fetch_array($result)){ $name = $row["name"]; $email = $row["email"]; ?><li><?php echo $name; ?> (<?php echo $email; ?>) ... <?php if(@mail($email,$subject,$message,"From: $admin <$admin>\n")){ ?>sent<?php $sent++; }else{ ?>failed<?php } ?></li><?php } ?></ul> <p><strong><?php echo $sent; ?> emails sent.</strong> <a href="admin.php?pwd=<?php echo $pwd; ?>">Click here to continue.</a></p><?php //print forms }else{ ?><h2>Send newsletter</h2> <form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>?pwd=<?php echo $pwd; ?>"> <table> <tr> <td>Subject:</td> <td><input type="text" name="subject" class="fixedwidth"></td> </tr> <tr> <td valign="top">Message:</td> <td><textarea name="message" cols="60" rows="20" class="fixedwidth"><?php echo $signature; ?></textarea></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit_newsletter" value="Send"></td> </tr> </table> </form> <h2>Add an email address</h2> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>?pwd=<?php echo $pwd; ?>" method="post"> <table> <tr> <td>Name:</td> <td><input type="text" name="name" value="" maxlength="255"></td> </tr> <tr> <td>Email address:</td> <td><input type="text" name="email" value="" maxlength="255"></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Submit"></td> </tr> </table> </form> <h2>Email addresses</h2> <table cellpadding="5" cellspacing="2"> <tr class="header"> <td><strong>Name</strong></td> <td><strong>Email address</strong></td> <td> </td> </tr> <?php $result = @mysql_query("SELECT * FROM $db_table ORDER BY email ASC;"); $colored = false; while($row=@mysql_fetch_array($result)){ $colored = !$colored; ?><tr<?php if($colored){ ?> class="colored"<?php } ?>> <td width="200"><?php echo $row["name"]; ?></td> <td width="200"><?php echo $row["email"]; ?></td> <td><a href="<?php echo $_SERVER["PHP_SELF"]; ?>?pwd=<?php echo $pwd; ?>&del=<?php echo $row["id"]; ?>">remove</a></td> </tr><?php } ?> </table> <?php } }else{ //print login form echo $login; } //print link to news ?><p align="right"><a href="index.php">Newsletter</a></p><?php //print footer echo $footer; //close database connection @mysql_close(); ?> Hi,
I am developing a web application which will be comprised of three columns: (1) Search form, (2) Image gallery, (3) Image details. The site is going to be more like html framesets, but research reveals that framesets are not favourable due to many reasons. I however found an alternative that I want to use instead of html framesets http://www.ironspide...smartframes.htm
I thought it would be easy for me to add rows which should serve as a page header, but I was wrong. I tried adding
document.write('<frameset rows="17%,*" frameborder="no">');
to this part of the code, but row apeared in a wrong place at the bottom:
// Writes frameset document.write('<frameset rows="17%,*" frameborder="no">'); document.write('<frameset cols="25%,75%" frameborder="no">'); document.write('<frame src="' + menuURL + '" name="menu">'); document.write('<frame src="' + contentURL + '" name="content" marginheight="15" marginwidth="50" scrolling="yes">'); // -->The original script for the index.html page is as follows: <!-- /* SmartFrames - Author: Robert Darrell - http://www.ironspider.ca/ */ // Defines variables // REPLACE menu.htm WITH YOUR MENU PAGE // REPLACE page1.htm WITH YOUR INITIAL CONTENT PAGE menuURL = "menu.htm"; contentURL = "page1.htm"; reloadURL = parent.document.URL; orphanURL = reloadURL.substring(reloadURL.indexOf('?')+1, reloadURL.indexOf('&')); frameName = reloadURL.substring(reloadURL.indexOf('&')+1, reloadURL.length); // Reassigns variable according to frame name passed by orphan if (frameName == "menu") { menuURL = orphanURL; } else if (frameName == "content") { contentURL = orphanURL; } // Writes frameset document.write('<frameset cols="25%,75%" frameborder="no">'); document.write('<frame src="' + menuURL + '" name="menu">'); document.write('<frame src="' + contentURL + '" name="content" marginheight="15" marginwidth="50" scrolling="yes">'); // --> </script> <!-- Use the noframes section to help search engines index your site --> <noframes>THIS WEBSITE IS ABOUT...<br><br> <a href="menu.htm">Site Menu</a> </noframes> </frameset>I hope someone will help. Regards. joseph Hello How can i add google recaptcha to this code https://github.com/Tutorialwork/Tutorials/blob/master/PHP Rechtesystem/addnews.php
I am still fairly new to using phpmailer and it works but I have been asked to google recaptcha v2 checkbox into their contact form but unsure how to do that within the phpmailer code, below is what I currently have <?php // PHPMailer classes into the global namespace use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Base files require 'PHPMailer/src/Exception.php'; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; // create object of PHPMailer class with boolean parameter which sets/unsets exception. $mail = new PHPMailer(true); try { //$mail->isSMTP(); // using SMTP protocol $mail->Host = 'hostname'; // SMTP host as gmail $mail->SMTPAuth = true; // enable smtp authentication $mail->Username = 'emailaddress'; // sender gmail host $mail->Password = 'emailpassword'; // sender gmail host password $mail->SMTPSecure = 'ssl'; // for encrypted connection $mail->Port = 587; // port for SMTP $mail->setFrom('emailaddress', "Business Name"); // sender's email and name $mail->addAddress('emailaddress', "Business Name"); // receiver's email and name $mail->Subject = 'New Website Enquiry'; $mail->Body = "A new website enquiry has been made. The enquiry information is below" . "\r\n\r\n" . "Name: " . $_POST["name"] . "\r\n" . "Email: " . $_POST["email"] . "\r\n" . "Subject: " . $_POST["subjectline"] . "\r\n" . "Message: " . $_POST["message"]; $mail->send(); header('Location:enquiry-confirmation.php'); } catch (Exception $e) { // handle error. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } ?>
I've tried two separate captcha options, Securimage and reCaptcha, which is the one I currently have on my page. I got the same error with each code: Quote Warning: Cannot modify header information - headers already sent by (output started at /home/jwrbloom/public_html/metroindybasketball.com/form/dbenter.php:20) in /home/jwrbloom/public_html/metroindybasketball.com/form/dbenter.php on line 101 It's a conflict with the code that moves my User to the 'next step'. Here is the code: (scroll down toward the bottom, just before the email fields) <?php require_once('/home/jwrbloom/public_html/metroindybasketball.com/recaptcha/recaptchalib.php'); $privatekey = "6LetxbwSAAAAAMP2q1q5F5S_tiEcu1sH1_dM3DTl "; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification } ?> <?php /* connect to database */ if(!$con = mysql_connect("localhost","######","######")) { die("Could not connect to database: ".mysql_error()); } mysql_select_db("######_wpMIB", $con); $nameFirst = $_POST['nameFirst']; $nameLast = $_POST['nameLast']; $email = $_POST['email']; $addressHome = $_POST['addressHome']; $cityHome = $_POST['cityHome']; $stateHome = $_POST['stateHome']; $zipHome = $_POST['zipHome']; $phoneHome = $_POST['phoneHome']; $phoneMobile = $_POST['phoneMobile']; $school = $_POST['school']; $grade = $_POST['grade']; $coachSchool = $_POST['coachSchool']; $feet = $_POST['feet']; $inches = $_POST['inches']; /* search for existing row */ $sql = "SELECT id FROM fallLeague10 WHERE nameFirst='".mysql_real_escape_string($nameFirst)."' AND nameLast='".mysql_real_escape_string($nameLast)."' AND school='".mysql_real_escape_string($school)."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } if(mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); /* update existing row */ $sql = "UPDATE fallLeague10 SET confirm='y', email='".mysql_real_escape_string($email)."', addressHome='".mysql_real_escape_string($addressHome)."', cityHome='".mysql_real_escape_string($cityHome)."', stateHome='".mysql_real_escape_string($stateHome)."', zipHome='".mysql_real_escape_string($zipHome)."', phoneHome='".mysql_real_escape_string($phoneHome)."', phoneMobile='".mysql_real_escape_string($phoneMobile)."', coachSchool='".mysql_real_escape_string($coachSchool)."', feet='".mysql_real_escape_string($feet)."', inches='".mysql_real_escape_string($inches)."' WHERE id='".$row['id']."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } } else { /* insert new row */ $sql = "INSERT INTO fallLeague10 SET confirm='y', nameFirst='".mysql_real_escape_string($nameFirst)."', nameLast='".mysql_real_escape_string($nameLast)."', email='".mysql_real_escape_string($email)."', addressHome='".mysql_real_escape_string($addressHome)."', cityHome='".mysql_real_escape_string($cityHome)."', stateHome='".mysql_real_escape_string($stateHome)."', zipHome='".mysql_real_escape_string($zipHome)."', phoneHome='".mysql_real_escape_string($phoneHome)."', phoneMobile='".mysql_real_escape_string($phoneMobile)."', school='".mysql_real_escape_string($school)."', grade='".mysql_real_escape_string($grade)."', coachSchool='".mysql_real_escape_string($coachSchool)."', feet='".mysql_real_escape_string($feet)."', inches='".mysql_real_escape_string($inches)."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } } /* redirect user HERE IS WHERE I AM HAVING MY ERROR */ header("Location:/fall-league/payment"); //exit(); ?> <?php // The message $message = $_POST['nameFirst'] . " " . $_POST['nameLast'] ." has entered the fall league.\n"; $message .= $_POST['feet'] . "'" . $_POST['inches'] ."\", " . $_POST['grade'] . "; " . $_POST['school'] ."\n"; $message .= $_POST['email']; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); $headers = 'From: ' . $_POST['nameFirst'] . " " . $_POST['nameLast'] . " " . $_POST['email']; // Send mail('basketball@metroindybasketball.com', '2010 Fall League Registration', $message, $headers); ?> I have been running Google ReCaptcha v2 on 4 different sites for a very long time without any problem. They were all working fine. Not sure when as I was just recently made aware it, but none of them work anymore ??? Did google change something or is it because I updated php?? The problem is in the response - no matter what I try, I cannot verify that I am human. This is the response code:
[\code] For some reason I am no longer getting a successful response. Any help would be greatly appreciated Thanx
Ok Here is my Problem the following works great except it does not add the $user var to the account_details. As well as outputs md5 wrong it outputs something but its different than the password should be. Heres my PHP code: Code: [Select] <?php session_start(); /** * @author Brian T. Flores * @copyright 2010 - 2014 */ error_reporting(E_ALL); $conn = mysql_connect($db_host, $db_user, $db_pass) or die ('Error connecting to mysql'); mysql_select_db($db_name); if($_GET['goahead']==1){ // If GoAhead Is set if(isset($_GET['user'])){ // If isset GoAhead $user = mysql_real_escape_string($_GET['user']); // Clean User for Transfer. $user_check = mysql_query("SELECT * FROM `account_details` WHERE `username01` = '$user'"); // Check to see if username is taken. $ucount = mysql_num_rows($user_check); // Get Username Check Count if($ucount!=""){ // If Username is Taken. die(3); // Die Error Number 3 } // End If Username is Taken. if(isset($_GET['pass'])){ // If password is set. $pass = mysql_real_escape_string($_GET['pass']); // Clean Password for Transfer. $encPass = md5($pass); // Encrypt Password if(isset($_GET['race'])){// If Race is Set. $race = mysql_real_escape_string($_GET['race']); // Clean Race for Transfer. if(isset($_GET['email'])){ // If Email is set. $email = mysql_real_escape_string($_GET['email']); // Clean Email for Transfer. $email_check = mysql_query("SELECT * FROM `account_details` WHERE `email` = '$email'");// Check to see if Email is Taken. $ecount = mysql_num_rows($email_check); // Get Email Check Count. if($ecount!=""){ // If Email is Taken. die(2); // Die Error Number 2 } // End If Email is Taken. if(isset($_GET['email2'])){ // If email confirmation is set. $email2 = mysql_escape_string($_GET['email2']); // Clean Email Confirmation for Transfer. if($email == $email2){ // If emails match. if(isset($_GET['planet'])){ // If Planet Name is Set. $pname = mysql_real_escape_string($_GET['planet']); // Clean Planet Name for Transfer. if(isset($_GET['security_code'])){ // If Security Code Input is set. $security_code = mysql_real_escape_string($_GET['security_code']); // Clean Security Code. $security_enc = md5($security_code); // Encrypt Security Code. $security_code2 = $_SESSION['image_random_value']; // Get Security Code Session if($security_enc == $security_code2){ // If Codes Match. $randActive = rand(11111111111111111111,99999999999999999999); // Get Activation Link pre-encrypt. $activation_link = md5($randActive); // Get Encrypted Activation Link. $q = "INSERT INTO `account_details` (`username01`, `password01`, `loggedIn`, `currentlyLogged`, `active`, `activelink`, `race`, `email`) VALUES ('$user', '$encPass', 0, 0, 0, '$activation_link', '$race', '$email');"; // ^ Add Account Query. $res = mysql_query($q) or die("Error Detected! <br />".mysql_error()); // ^ Add Account to SQL. $q = mysql_query("SELECT * FROM `account_details` WHERE `username01` = '$user'")or die(mysql_error()); // ^ Get Information from New Account. $newuserinfo = mysql_fetch_array($q);// Get New User Information $id = $newuserinfo['id']; // Set New Account Id. $q="INSERT INTO `planets` (`owner`, `name`, `recource1`, `recource2`, `recource3`, `recource4`, `recource5`, `turns_01`, `untrained_units_01`, `attackers_01`, `defenders_01`, `miners_01`, `covert_01`, `anticovert_01`, `ship_01`, `ship_02`, `ship_03`, `ship_04`, `ship_05`, `ship_06`, `ship_07`, `building01`, `building02`, `building03`, `building04`, `building05`, `building06`, `building07`, `building08`, `building09`) VALUES ('$id', '$pname', 35000, 15000, 12000, 135000, 125000, 220, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0);"; // ^ Add Planet Query. $res2 = mysql_query($q) or die("Error Detected! <br />".mysql_error()); // Add Planet to SQL. $body = " Hello ".$user.", Congradulations! Your account on Ultimate Conquest has been Registed Today! Click the following Link to Activate Account: http://testing.ultimateconquest.net/activate.php?code=".$activation_link." If you have not registered an account and have found this message in error please click the following link to report this error: http://testing.ultimateconquest.net/errorreg.php?account=".$user." Thank you for registering for Ultimate Conquest - ULC, Head Admin Brian Flores AKA Photonic.... "; // Activation Email Information. if (mail($email, "Activate your ULC Ultimate Conquest Account! No-Reply!", $body)) { // If Email Is Sent. die("1"); // Die Error Number 1 } // End Send Email }else{ // If Security Codes do Not Match. die("12"); // Die Error Number 12 } }else{ // If Security Code is Not Set die("11"); // Die Error Number 13 } }else{ // If Planet Name is Not Set. die("10"); // Die Error Number 10. } }else{ // If Emails do not match. die("9"); // Die Error Number 9. } }else{ // If email confirmation is not set. die("8"); // Die Error Number 8. } }else{ // If email is not set. die("7"); // Die Error Number 7. } }else{ // If race is not set. die("6"); // Die Error Number 6. } }else{ // If Password is not set. die("5"); // Die Error Number 5. } }else{ // If Username is not set. die("4"); // Die Error Number 4. } }else{ // If GoAhead is Not Set. die("Go Ahead Not Established By Game System!"); } ?> Here is the Register Function in Javascript: Code: [Select] function regMast(){ var user = document.getElementById('username_client').value; var pass = document.getElementById('password_client').value; var race1 = document.getElementById('races1').value; if(race1 !=""){var race = document.getElementById('races1').value;} var race2 = document.getElementById('races2').value; if(race2 !=""){var race = document.getElementById('races2').value;} var race3 = document.getElementById('races3').value; if(race3 !=""){var race = document.getElementById('races3').value;} var race4 = document.getElementById('races4').value; if(race4 !=""){var race = document.getElementById('races4').value;} var planet_name = document.getElementById('pname').value; var email = document.getElementById('email').value; var email2 = document.getElementById('email2').value; var security_code = document.getElementById('security_code').value; var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var returni = ajaxRequest.responseText; if(returni == "1"){ document.getElementById('reg_error').innerHTML = 'Registration Completed! Check Activation Email for more information.'; } if(returni == "2"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Email Address Already Taken!'; } if(returni == "3"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Username Already Taken!'; } if(returni == "4"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Username Field Empty!'; } if(returni == "5"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Password Field Empty!'; } if(returni == "6"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! You must select a race!'; } if(returni == "7"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Email Field Empty!'; } if(returni == "8"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Email Confirmation Field Empty!'; } if(returni == "9"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Emails did not Match!'; } if(returni == "10"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! Planet Name Field Empty!'; } if(returni == "11"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! You did not Input the Security Code!'; } if(returni == "12"){ document.getElementById('reg_error').innerHTML = 'Registration Incomplete! The Security Code you Inputed did not Match the Image!'; }else{ document.getElementById('reg_error').innerHTML = returni; } } } var queryString = "?goahead=1&user=" + user + "&pass=" + pass + "&race=" + race + "&email=" + email + "&email2=" + email2 + "&security_code=" + security_code + "&planet=" + planet_name; ajaxRequest.open("GET", "register.php" + queryString, true); ajaxRequest.send(null); } Can someone help me add a filter to my script that reads txt files from subfolders, I want it to only read txt files that are <= a certain KB size Code: [Select] 1.<?php 2.set_time_limit(0); // set unlimited execution time 3. 4. 5.$base_folder = $_POST['base_folder']; 6.$article_to_capture = (int)$_POST['article_to_capture']; 7. 8.$words = explode(',', $_POST['words']); 9. 10. 11.// print_r($words); die(''); 12. 13. 14.if(!is_dir($base_folder)) 15. die('Invalid base folder. Please go <a href="step1.php"><strong>back</strong></a> and enter correct folder.'); 16. 17.?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 18.<html> 19.<head> 20.<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 21.<title>Artcle Scraper Step 2</title> 22.<style type="text/css"> 23.<!-- 24.body { 25. font-family: Verdana, Arial, Helvetica, sans-serif; 26. font-size: 12px; 27. color: #333333; 28.} 29.--> 30.</style> 31.</head> 32. 33.<body> 34.<h2>Step 2 : Processing the content of the folder. </h2> 35.<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC"> 36. <tr bgcolor="#FFFFFF"> 37. <th width="10%"> </td> 38. <th width="30%">BASE FOLDER NAME</td> 39. <th width="50%"> <?php echo $base_folder;?></td> 40. <th width="10%"> </td> 41. </tr> 42.<?php 43. 44.$subfolder_arr = scandir($base_folder); 45. 46.//print_r($arr1); 47. 48.$total_subfolders = sizeof($subfolder_arr); 49.$subfolder_count = 0; 50.$file_count = 0; 51.$report = ""; 52. 53.$fp = fopen('articles.csv', 'w+'); 54. 55.for($i=0; $i< $total_subfolders; $i++){ 56. $file_name = $subfolder_arr[$i]; 57. 58. if($file_name=='.'||$file_name=='..') 59. continue; 60. 61. $sub_folder_name = $base_folder ."\\". $file_name; 62. $file_type = is_dir($sub_folder_name) ? 'dir' : 'file'; 63. if($file_type=='dir'){ 64. $sub_folder_count++; 65. $rpeort .= "Processing folder $sub_folder_count $sub_folder_name \r\n"; 66. $msg = "Processing folder $sub_folder_count $sub_folder_name \r\n"; 67.?> 68. <tr bgcolor="#FFFFFF"><td> </td><td colspan="2"> 69. <?php echo $msg;?> 70. </td><td> </td></tr> 71. <tr bgcolor="#FFFFFF"><td> </td><td colspan="2"> 72. <table width="90%" cellpadding="0" cellspacing="0" border="1" bordercolorlight="#0000FF"> 73.<?php 74. // process sub folder 75. $column1 = $file_name; 76. $column2 = '{'; 77. $column3 = '{'; 78. $first = true; 79. $files_arr = scandir($sub_folder_name); 80. $article_processed =0; // article_processed in current sub folder 81. foreach($files_arr as $key=>$val){ 82. 83. if(is_file($sub_folder_name.'\\'.$val) ) 84. { if( substr($val,-4)=='.txt' ) 85. { 86. $article_processed++; 87. 88. if($article_to_capture==0 || $article_processed <= $article_to_capture ){ 89. 90. if($first==true) $first=false; 91. else 92. { $column2 .= '|'; $column3 .= '|'; } 93. 94. // read file get title and body 95. $file_content = file($sub_folder_name.'\\'.$val); 96. $file_title = rtrim($file_content[0]); 97. 98. $file_content[0] = ''; 99. 100. $file_arr_size = sizeof($file_content); 101. $words_arr_size = sizeof($words); 102. $t=1; 103. while($t < $file_arr_size){ 104. $file_content[$t] = rtrim($file_content[$t]); 105. //echo $file_content[$t]; 106. //die('inside'); 107. if( $words_arr_size>0 ){ 108. //die('inside'); 109. $temp = str_replace($words, "", $file_content[$t]); 110. $file_content[$t] = $temp; 111. } 112. $t++; 113. //if($t>=3) die('aa'); 114. } 115. $file_body = implode('',$file_content); 116. 117. $column2 .= $file_title; 118. $column3 .= $file_body; 119. 120. ?> 121. <tr><td> 122. <?php //print_r($files_arr); 123. echo $val ."\r\n"; 124. ?> 125. </td></tr> 126. <?php 127. } //end if .txt 128. } // article processed 129. } // end if is_file 130. } // end foreach 131.?> 132.</table> 133.</td><td> </td></tr> 134.<?php $column2 .= '}'; 135. $column3 .= '}'; 136. 137. // write to csv / excel file 138. $erro = fputcsv ($fp, array($column1,$column2,$column3) ); 139. 140. } //end if filetype 141. else{ 142. 143. } 144.} // end for 145. 146.fclose($fp); 147. 148.?> <tr bgcolor="#FFFFFF"> 149. <td> </td> 150. <td colspan=""> File Generated. 151. Download it <a href="articles.csv" target="_blank">HERE</a></td> 152. <td> </td> 153. </tr> 154.</table> 155.</body> 156.</html> I'm implementing google's reCAPTCHA V2. It works almost perfectly except for the following error located in the recaptchalib.php:
Notice: Use of undefined constant success - assumed 'success' in (script location)
https://github.com/g...ecaptchalib.php
Anyone got an idea how to fix this?
Edited by tork, 28 November 2014 - 04:24 PM. Why am I getting that error on Google reCAPTCHA V2 response? Hello, it's my first time posting here and I'm not good with such stuff as the one I'm posting right now I have been trying to solve this issue for 2 days by now so I could use some help lol This error "Please solve the captcha." is showing even if the captcha is verified so it's showing in the both cases (verified/unverified). Thanks in advance.
<?php require_once 'db/setting.php'; require_once 'db/odbc.php'; session_start(); error_reporting(0); if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https://'; } else { $protocol = 'http://'; } $currentDomain = $protocol.$_SERVER[HTTP_HOST]; $API["secret_key"] = "xx"; $API["api_key"] = "xx"; $API["callback"] = $currentDomain."/vote-reward-tok.php?return={RETURNEDCODE}"; $API["API_Domain"] = "http://api.top-kal.com"; $secretKey = 'xxx'; $captcha = $_POST['g-recaptcha-response']; $ip = $_SERVER['REMOTE_ADDR']; $responseData=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&responseData=".$captcha."&remoteip=".$ip); $responseKeys = json_decode($responseData,true); $config["db_username"] = "sa"; $config["db_password"] = "********"; $config["db_database_account"] = "kal_auth"; $config["db_database_player"] = "kal_db"; $config["db_server"] = "NAME\SQLEXPRESS"; $config["db_driver"] = "SQL Server"; $config["Reward_Name"] = "Vote Coin"; $config["MinLvl_Require"] = 30; $config["Reward_Index"] = 447; $config["Reward_Amount"] = 10; $config["Reward_Bound"] = false;
function insertRewards($account_unique_id){ global $config; $connect = odbc_connect('Driver={'.$config["db_driver"].'};Server='.$config["db_server"].';Database='.$config["db_database_player"].';', $config['db_username'] ,$config['db_password']); if(!$connect) return false; $query = odbc_exec($connect,"SELECT Top 1 [IID] FROM [Item] Where [IID] < 1 order by IID Desc"); if(!$query) return false; $data = odbc_fetch_array($query); if($data && !empty($data) && isset($data["IID"])) odbc_exec($connect,"INSERT INTO [Item] ([PID],[IID],[Index],[Prefix],[Info],[Num])VALUES ($account_unique_id,".($data["IID"]+1).",".$config["Reward_Index"].",0,".(16+($config["Reward_Bound"] ? 128 : 0)).",".$config["Reward_Amount"].")"); } function checkCharacters($accountUID){ global $config; $connect = odbc_connect('Driver={'.$config["db_driver"].'};Server='.$config["db_server"].';Database='.$config["db_database_player"].';', $config['db_username'] ,$config['db_password']); if(!$connect) return array("error" => "failed to connect to database players."); $query = odbc_exec($connect,"SELECT [Level] FROM [Player] WHERE [UID] = $accountUID ORDER BY [Level] DESC"); if(!$query) return array("error" => "failed to find characters in this account id."); while($r = odbc_fetch_array($query)){ if($r["Level"] >= $config["MinLvl_Require"]) return array("success" => $accountUID); } return array("error" => "You should have one character at least higher than level : ".$config["MinLvl_Require"]." to vote."); } function checkAccount($accountID){ global $config; $connect = odbc_connect('Driver={'.$config["db_driver"].'};Server='.$config["db_server"].';Database='.$config["db_database_account"].';', $config['db_username'] ,$config['db_password']); if(!$connect) return array("error" => "failed to connect to database accounts."); $query = odbc_exec($connect,"SELECT TOP 1 [UID] FROM [Login] WHERE [ID] = '$accountID'"); if(!$query) return array("error" => "this account id not exists."); $data = odbc_fetch_array($query); if(!$data || empty($data) || !isset($data["UID"])) return array("error" => "this account id not exists."); if($config["MinLvl_Require"] > 0) return checkCharacters($data["UID"]); return array("success" => $data["UID"]); } >> Submitting Function $response = array("error" => false , "success" => false , 'redirect' => false); function post_content($query){ $query_array = array();foreach( $query as $key => $key_value )$query_array[] = urlencode( $key ) . '=' . urlencode( $key_value );return implode( '&', $query_array ); } global $API; $opts = array('http' => array('method' => 'POST',"header" => "Content-type: application/x-www-form-urlencoded\r\nAuthorization:".base64_encode($API["api_key"].":".$API["secret_key"])."\r\n", "content" => post_content($content)));return stream_context_create($opts); } function submit(){ global $API; if(empty($captcha) || $captcha == '' || !isset($captcha)) return array( "error" => "Please solve the captcha."); if (empty($_POST['account']) || !ctype_alnum($_POST['account'])) return array( "error" => "Invalid account id."); $checkAccount = checkAccount($_POST['account']); if (isset($checkAccount["error"])) return array("error" => $checkAccount["error"]); if (isset($checkAccount["success"])){ $account_unique_id = (isset($_SESSION['kal_id'])) ? $_SESSION['kal_id'] : $checkAccount["success"]; $result = json_decode(file_get_contents($API["API_Domain"] . '/api/generate/vote-rewards-token', false, postParams(array('callback' => $API["callback"],'account_unique_id' => $account_unique_id ))) , true); { echo '<br><center><h3>Please wait...</h3></center>'; } if (!empty($result)){ if (isset($result["response"])){ if (isset($result["response"]["error"])) return array("error" => $result["response"]["error"]); elseif (isset($result["response"]["success"])) return array("redirect" => '<script type="text/javascript">setTimeout(function () { window.location.href = "'.$result["response"]["success"].'";}, 500)</script>'); } } } } if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['account'])){ $response = submit(); if (isset($response['redirect']) && $response['redirect']){ echo $response['redirect']; die; } }elseif (isset($_GET['return'])){ $result = json_decode(file_get_contents($API["API_Domain"] . '/api/verify/vote-rewards-token', false, postParams(array('returned_code' => $_GET['return']))) , true); if (!empty($result)){ if (isset($result["response"])){ if (isset($result["response"]["error"])) $response['error'] = $result["response"]["error"]; elseif (isset($result["response"]["success"])){ insertRewards($result["response"]["account_unique_id"]); $response['success'] = '<b>Thank you, Your vote has been recorded and the server rank will be updated soon.<b><br />You will receive your rewards in storage of your account.<p>Your next vote in : <b>' . $result["response"]["NextVote"] . '</b></p>'; } } } } ?>
<head> <title>Vote Rewards - <?php echo $config['serverName']; ?></title> <link rel="shortcut icon" href=images/favicon.png"> <link rel="stylesheet" href="css/vote.css"> <link rel="stylesheet" href="css/fontawesome.css"> <link rel="stylesheet" href="css/fontawesomeall.css"> <script src='https://www.google.com/recaptcha/api.js'></script> </head> <body> <form class="vote-form" method="post"> <noscript><div class="isa_error">Javascript is not enabled in your browser! Please enable it or change your browser.</div></noscript> <?php if(isset($response['error']) && $response['error']){ ?><div class="isa_error"> <?php echo $response['error'] ;?> </div> <?php } ?> <?php if(isset($response['success']) && $response['success']){ ?><div class="isa_success"> <?php echo $response['success'] ;?> </div> <?php }else{ ?> <label> <span>Account ID :</span> <input type="text" name="account" maxlength="20" <?php echo (isset($_SESSION['kal_username'])) ? 'readonly value="'.$_SESSION['kal_username'].'"' : ""; ?>" /> </label> <div class="g-recaptcha" style="margin:0 auto;" data-sitekey="xxx" data-theme="dark"></div> <label class="label_btn"> <input type="submit" class="button" value="Vote" /> </label> <?php } ?> </form> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> </body> </html> Edited October 13, 2019 by requinix we don't do markdown. please use the Code <> button for code I cannot redirect to other page even I enter correct information and recaptcha in activation form. Anyone who can check what going wrong in my activation script?
Here is my php activation check script:
<?php This topic has teleported to Third Party PHP Scripts. Beam me up, Scotty. http://www.phpfreaks.com/forums/index.php?topic=343682.0 |