Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // script example to be pasted to ExecutePHP plugin's section, for this topic: http://gpeasy.com/Special_Forum?show=t920
- global $page,$config,$langmessage,$title, $dataDir;
- $addon_key = gpPlugin::AddonFromId(62);
- $addonPathCode = $dataDir.'/data/_addoncode/'.$addon_key;
- $addonPathData = $dataDir.'/data/_addondata/'.$addon_key;
- $addonRelativeCode = common::GetDir('/data/_addoncode/'.$addon_key);
- $addonRelativeData = common::GetDir('/data/_addondata/'.$addon_key);
- echo '<script src="'.$addonRelativeCode.'/form_validator.min.js" type="text/javascript"></script>
- <script type="text/javascript"> var RecaptchaOptions = { lang : '; echo common::ConfigValue('recaptcha_language',''); echo '\', theme : \'red\' }; </script>';
- $rhc_string='Antispam test passed!'; // REVERSE HONEYPOT CAPTCHA OK STRING ~ Antispam test passed! Humanity confirmed! :-)
- if (file_exists($addonPathData.'/scf_style.css'))
- $page->css_user[] = $addonRelativeData.'/scf_style.css';
- else
- $page->css_user[] = $addonRelativeCode.'/scf_style.css';
- echo '
- <div class="simplecontactform">
- <noscript><p>Unfortunately, JavaScript is currently disabled by this browser. Please enable JavaScript for full functionality.</p></noscript>';
- if (isset($_POST["submitForm"]) && $_POST["url"]=='') {
- require_once($addonPathCode.'/class.phpmailer.php');
- $mail = new PHPMailer();
- $mail->SetLanguage("sk");
- $mail->IsHTML(false);
- $mail->WordWrap = 50;
- $mail->CharSet = "utf-8";
- $mail->IsSMTP();
- $mail->SMTPDebug = false;
- $mail->SMTPAuth = true;
- $mail->SMTPSecure="ssl";
- $mail->Host="smtp.gmail.com";
- $mail->Port="465";
- $mail->Username=$config['smtp_user'];
- $mail->Password=$config['smtp_pass'];
- echo '<i>Your data that will be posted in the email:</i><br/>';
- echo '<b>Your name:</b> ';
- if (isset($_POST['item1']))
- {
- echo $_POST['item1'].'<br/>';
- }
- else
- echo '-<br/>';
- echo '<b>Your phone:</b> ';
- if (isset($_POST['item2']))
- {
- echo $_POST['item2'].'<br/>';
- }
- else
- echo '-<br/>';
- echo '<b>Your e-mail:</b> ';
- if (isset($_POST['item3']))
- {
- echo $_POST['item3'].'<br/>';
- }
- else
- echo '-<br/>';
- echo '<b>Subject:</b> ';
- if (isset($_POST['item4']))
- {
- echo $_POST['item4'].'<br/>';
- }
- else
- echo '-<br/>';
- echo '<b>Message:</b> ';
- if (isset($_POST['item5']))
- {
- echo $_POST['item5'].'<br/>';
- }
- else
- echo '-<br/>';
- echo '<b>file attachment:</b> ';
- if ($_FILES['item6']['name']!='')
- echo '<i>'.$_FILES['item6']['name'].'</i>';
- else
- echo '-';
- if ($_FILES['item6']['error']!=0 && $_FILES['item6']['error']!=4)
- echo ' <i>error</i> <a href="http://php.net/manual/en/features.file-upload.errors.php" target="_blank">'.$_FILES['item6']['error'].'</a>';
- echo ' <br/>';
- $send = true;
- if (!isset($_POST["item1"]) || $_POST["item1"]=='')
- {
- printf($langmessage['OOPS_REQUIRED'],'Your name');
- echo '<br/>';
- $send = false;
- }
- if (!isset($_POST["item3"]) || $_POST["item3"]==''
- || !preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $_POST["item3"]))
- {
- echo $langmessage['invalid_email'].'<br/>';
- $send = false;
- }
- if (!isset($_POST["item4"]) || $_POST["item4"]=='')
- {
- printf($langmessage['OOPS_REQUIRED'],'Subject');
- echo '<br/>';
- $send = false;
- }
- if (!isset($_POST["item5"]) || $_POST["item5"]=='')
- {
- printf($langmessage['OOPS_REQUIRED'],'Message');
- echo '<br/>';
- $send = false;
- }
- if (!$send)
- {
- echo '<br/><b>Message not sent. Please correct invalid fields and try again.</b> <a href="'.common::GetUrl($title).'" target="_blank">'.common::GetLabel($title).'</a></div>';
- return;
- }
- $_name = $_POST["item1"];
- $_email = $_POST["item3"];
- $_subject = $_POST["item4"];
- $_message = $_POST["item5"];
- $_body = '';
- $_body .= 'Your name'.': ';
- if (isset($_POST['item1']))
- {
- $_body .= $_POST['item1'].PHP_EOL.PHP_EOL;
- }
- else
- $_body .= '-'.PHP_EOL.PHP_EOL;
- $_body .= 'Your phone'.': ';
- if (isset($_POST['item2']))
- {
- $_body .= $_POST['item2'].PHP_EOL.PHP_EOL;
- }
- else
- $_body .= '-'.PHP_EOL.PHP_EOL;
- $_body .= 'Your e-mail'.': ';
- if (isset($_POST['item3']))
- {
- $_body .= $_POST['item3'].PHP_EOL.PHP_EOL;
- }
- else
- $_body .= '-'.PHP_EOL.PHP_EOL;
- $_body .= 'Subject'.': ';
- if (isset($_POST['item4']))
- {
- $_body .= $_POST['item4'].PHP_EOL.PHP_EOL;
- }
- else
- $_body .= '-'.PHP_EOL.PHP_EOL;
- $_body .= 'Message'.': ';
- if (isset($_POST['item5']))
- {
- $_body .= $_POST['item5'].PHP_EOL.PHP_EOL;
- }
- else
- $_body .= '-'.PHP_EOL.PHP_EOL;
- if ($_FILES['item6']['error']==0)
- $mail->AddAttachment($_FILES['item6']['tmp_name'],$_FILES['item6']['name']); // attachment
- $mail->AddAddress($config['toemail'],$config['toname']); // e-mail address of receiver
- //$mail->AddAddress("another.mail@another.address.com"); // e-mail address of another receiver.....
- $mail->FromName = $_name; // Sender's full name
- $mail->From = $_email; // sender's e-mail address
- $mail->Return = $_email; // if email will not be delivered, notice will return here
- $mail->Subject = 'Message from my website: '.$_subject;
- $mail->Body .= $_body;
- $sent = $mail->Send();//via smtp or phpmail
- if($sent)
- {echo '<br/><br/><b>Thank You!</b><br/>Your message was successfully sent!☺<br/>We\'ll get back to you as soon as possible.';}
- else
- {echo '<br/><br/><b>Sorry</b><br/>We encountered an error, when sending your message ☹';}
- echo '<br/><br/>';
- }
- if (isset($_POST["submitForm"]) && $_POST['url']!='')
- { echo 'Spam was detected. Message was not send. (Honeypot Captcha)';}
- $op='+-*ab';
- $op=$op[(rand()%strlen($op))];
- if ($op=='a' || $op=='b') { $n = 66+rand()%24; } else { $n1 = rand()%10; $n2 = rand()%10; }
- echo '
- <div id="scf_jsContentWrapper" style="display:none;">
- <div>Contact Form</div><br/>
- <form enctype="multipart/form-data" action="" method="post" name="special_contact_form" class="scf">
- <fieldset>
- <label><b>Your name</b>
- <input id="item1" name="item1" type="text" value="" />
- *(required)
- <span class="error_strings" id="special_contact_form_item1_errorloc"> </span> </label>
- <label><b>Your phone</b>
- <input id="item2" name="item2" type="text" value="" />
- *(recommended)
- <span class="error_strings" id="special_contact_form_item2_errorloc"> </span> </label>
- <label><b>Your e-mail</b>
- <input id="item3" name="item3" type="text" value="" />
- *(required)
- <span class="error_strings" id="special_contact_form_item3_errorloc"> </span> </label>
- <label><b>Subject</b>
- <select name="item4">
- <option value="Appointment">Appointment</option>
- <option value="Acknowledgment">Acknowledgment</option>
- <option value="Complaint">Complaint</option>
- </select>
- <span class="error_strings" id="special_contact_form_item4_errorloc"> </span> </label>
- <label><b>Message</b>
- <textarea id="item5" name="item5" cols="50" rows="5" style="height:20em; width:98%; border:1px solid #ccc;"></textarea>
- <span class="error_strings" id="special_contact_form_item5_errorloc"> </span> </label>
- <label><b>file attachment</b>
- (The maximum size of an uploaded file: 128MB)
- <input id="item6" name="item6" type="file" value="" style="margin-right:90px"/>
- <span class="error_strings" id="special_contact_form_item6_errorloc"> </span> </label>
- <label for="check"><b>Antispam protection</b>
- <span style="float:left">Please enter the result '; if ($op=='+') echo $n1.' + '.$n2; if ($op=='-') echo $n1+$n2.' - '.$n1; if ($op=='*') echo $n1.' * '.$n2; if ($op=='a') { $tempstring='the letter between %a and %c'; echo ' '.str_replace(array('%a','%c'),array(chr($n-1),chr($n+1)),$tempstring); }
- if ($op=='b') { echo 'unique letter in '; $rc=65+rand()%26; if($rc==$n) $rc=($n==65?90:65); $pos=1+rand()%5; for($rs=0;$rs<7;$rs++) echo ($rs==$pos)?chr($n):chr($rc); }
- echo ' : </span>
- <input id="check" name="check" type="text" value="" class="scf_input" />
- </label>
- <input class="scf_submit" name="submitForm" type="submit" value="Send" />
- <input id="url" name="url" type="text" value="" style="display:none" />
- <input id="website" name="website" type="text" value="" style="display:none" />
- <span class="error_strings" id="special_contact_form_check_errorloc"> </span>
- </fieldset>
- </form>
- </div>';
- if (!isset($_POST["submitForm"]))
- { echo '<script type="text/javascript">$(\'#scf_jsContentWrapper\').removeAttr(\'style\'); </script>'.PHP_EOL; }
- echo '
- <script type="text/javascript">
- var frmvalidator = new Validator("special_contact_form");
- frmvalidator.EnableOnPageErrorDisplay();
- frmvalidator.addValidation("item1","req","Please enter the required field - Your name");
- frmvalidator.addValidation("item1","minlength=2","The entered value is too short for this field - Your name");
- frmvalidator.addValidation("item1","maxlength=50","The entered value is too long for this field - Your name");
- frmvalidator.addValidation("item2","maxlength=30","The entered value is too long for this field - Your phone");
- frmvalidator.addValidation("item3","req","Please enter the required field - Your e-mail");
- frmvalidator.addValidation("item3","email","Please enter your email address");
- frmvalidator.addValidation("item4","req","Please enter the required field - Subject");
- frmvalidator.addValidation("item4","minlength=2","The entered value is too short for this field - Subject");
- frmvalidator.addValidation("item5","req","Please enter the required field - Message");
- frmvalidator.addValidation("url","maxlen=0","This field must be empty. You must be a bot.");
- frmvalidator.addValidation("check","req","Please check the antispam field and try again.");';
- if ($op=='+') echo '
- frmvalidator.addValidation("check","numeric","Please check the antispam field and try again.");
- frmvalidator.addValidation("check","greaterthan='.($n1+$n2-1).'","Please check the antispam field and try again.");
- frmvalidator.addValidation("check","lessthan='.($n1+$n2+1).'","Please check the antispam field and try again.");';
- if ($op=='-') echo '
- frmvalidator.addValidation("check","numeric","Please check the antispam field and try again.");
- frmvalidator.addValidation("check","greaterthan='.($n2-1).'","Please check the antispam field and try again.");
- frmvalidator.addValidation("check","lessthan='.($n2+1).'","Please check the antispam field and try again.");';
- if ($op=='*') echo '
- frmvalidator.addValidation("check","numeric","Please check the antispam field and try again.");
- frmvalidator.addValidation("check","greaterthan='.($n1*$n2-1).'","Please check the antispam field and try again.");
- frmvalidator.addValidation("check","lessthan='.($n1*$n2+1).'","Please check the antispam field and try again.");';
- if ($op=='a' || $op=='b') echo '
- frmvalidator.addValidation("check","alpha","Please check the antispam field and try again.");
- frmvalidator.addValidation("check","regexp=['.chr($n).']|['.chr($n+32).']","Please check the antispam field and try again.");';
- echo ' </script>
- </div>
- ';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement