reCaptcha with smarty
reCaptcha in smarty template file
//php
require_once ('recaptchalib.php');
$mypublickey = "456723345";
$smarty->assign("captcha", recaptcha_get_html($mypublickey));
//smarty
{$captcha}
AD ยท www.interserver.net/r/240055
Interserver | Standard & VPS Cloud Hosting | $2.50 /Month
Flexible VPS hosting platform to deploy your online projects.
Economical and balanced between processor cores, memory and storage
rated 13 times
(9)
(4)
comments: 1 / hits: 5681
/ 7 years ago, mon, dec 5, 16, 01:47:20
More From
» PHP
Comments
There are no comments for this Snippet yet
Posted
jimmy
Member since Dec 15, 2016
Total Code Snippets: 16
Total Comments: 2
Location: n/a
jimmy snippets
7 years ago, mon, jan 9, 17, 2:50:09
//submit.php
<!DOCTYPE html>
<html>
<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="devCodePro" />
<meta name="ROBOTS" content="All" />
<script src="https://www.google.com/recaptcha/api.js"></script>
<style>
body{background-color:#fff;font-family:tahoma,serif;font-size:15px;color:#555;font-weight:900;width:40%;overflow:hidden;margin:50px auto 0}
.info{padding:15px;text-align:center;background:#6C89B5;color:#fff;margin:0 5px}
pre{background:#F7F7F7;white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;color:#354165;font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,sans-serif;font-size:15px}
</style>
</head>
<body>
<?php
if(isset($_POST['query'])) {
echo "<pre>".var_dump($_POST)."</pre>";
if(isset($_POST['g-recaptcha-response'])) {
$recaptcha = $_POST['g-recaptcha-response'];
} else {
echo "<div class='info'>Please check the the captcha</div>";
die();
}
if(!$recaptcha) {
echo "<div class='info'>Please check the the captcha</div>";
die();
}
$mySecretKey = "----Enter Secret Key----";
$ip = $_SERVER['REMOTE_ADDR'];
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$mySecretKey."&response=".$recaptcha."");
print_r("<pre>".$response."</pre>");
$getResponse = json_decode($response,true);
if(intval($getResponse['success']) !== 1) {
echo "<div class='info'>Error</div>";
} else {
echo "<div class='info'>Thank You</div>";
}
} else {
?>
<form action="submit.php" method="post">
<div class="g-recaptcha" data-sitekey="Enter Site Key"></div>
<div>
<input type="submit" value="Query" name="query" />
</div>
</form>
<?php } ?>
</body>
</html>
comments: 1 / hits: 36009
7 years ago, mon, jan 16, 17, 2:18:41
//stopforumspam.php
<?php
/**
* checkStopForumSpam()
*
* @param mixed $email
* @param mixed $ipse
* @return void
*/
function checkStopForumSpam($email,$ipse) {
libxml_use_internal_errors(true);
@$xml_string = file_get_contents('http://www.stopforumspam.com/api?ip='.$ipse.'&email='.$email.'');
if(!$xml_string) {
echo "Failed loading document. Your host can make remote connection with the DB.";
foreach(libxml_get_errors() as $error) {
}
die('Sorry, your registration could not be processed.');
} else {
$xml_string = file_get_contents('http://www.stopforumspam.com/api?ip='.$ipse.'&email='.$email.'');
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes') {
echo "Sorry, your registration could not be processed.";
$emailto = "Email: ".$email." - IP: ".$ipse."r";
$file = "banlog.log";
@$fh = fopen($file,'a');
@fwrite($fh,$emailto."n");
@fclose($fh);
die();
}
}
}
?>
//usage
require_once ('stopforumspam.php');
$ipse = $_SERVER['REMOTE_ADDR'];
$email = htmlspecialchars($_POST['email']);
checkStopForumSpam($email,$ipse);
comments: 1 / hits: 3447
7 years ago, sat, jan 21, 17, 5:41:42
=======plugin.php=======
<?php
// Copyright 2011 Toby Zerner, Simon Zerner
// This file is part of esoTalk. Please see the included license file for usage information.
if(!defined("IN_ESOTALK"))
exit;
ET::$pluginInfo["BBCode"] = array("name" => "BBCode","description" => "Formats BBCode within posts, allowing users to style their text.","version" => ESOTALK_VERSION,"author" => "esoTalk Team","authorEmail" => "[email protected]","authorURL" => "http://esotalk.org","license" => "GPLv2");
/**
* ETPlugin_BBCode
* @package
* @author devcodepro.com
* @version 2017
* @access public
*/
class ETPlugin_BBCode extends ETPlugin {
public function handler_conversationController_renderBefore($sender) {
$sender->addJSFile($this->resource("bbcode.js"));
$sender->addCSSFile($this->resource("bbcode.css"));
}
public function handler_conversationController_getEditControls($sender,&$controls,$id) {
addToArrayString($controls,"fixed","<a href='javascript:BBCode.fixed(\"$id\");void(0)' title='".T("Code")."' class='control-fixed'><i class='icon-code'></i></a>",0);
addToArrayString($controls,"image","<a href='javascript:BBCode.image(\"$id\");void(0)' title='".T("Image")."' class='control-img'><i class='icon-picture'></i></a>",0);
addToArrayString($controls,"link","<a href='javascript:BBCode.link(\"$id\");void(0)' title='".T("Link")."' class='control-link'><i class='icon-link'></i></a>",0);
addToArrayString($controls,"strike","<a href='javascript:BBCode.strikethrough(\"$id\");void(0)' title='".T("Strike")."' class='control-s'><i class='icon-strikethrough'></i></a>",0);
addToArrayString($controls,"header","<a href='javascript:BBCode.header(\"$id\");void(0)' title='".T("Header")."' class='control-h'><i class='icon-h-sign'></i></a>",0);
addToArrayString($controls,"italic","<a href='javascript:BBCode.italic(\"$id\");void(0)' title='".T("Italic")."' class='control-i'><i class='icon-italic'></i></a>",0);
addToArrayString($controls,"bold","<a href='javascript:BBCode.bold(\"$id\");void(0)' title='".T("Bold")."' class='control-b'><i class='icon-bold'></i></a>",0);
addToArrayString($controls,"color","<a href='javascript:BBCode.color(\"$id\");void(0)' title='".T("Color")."' class='control-b'>COLOR</a>",0);
}
public function handler_format_beforeFormat($sender) {
$hideBlock = create_function('&$blockFixedContents, $contents','
$blockFixedContents[] = $contents;
return "</p><pre></pre><p>";');
$hideInline = create_function('&$inlineFixedContents, $contents','
$inlineFixedContents[] = $contents;
return "<code></code>";');
$this->blockFixedContents = array();
$this->inlineFixedContents = array();
$regexp = "/(.*)^\s*\[code\]\n?(.*?)\n?\[\/code]$/imse";
while(preg_match($regexp,$sender->content)) {
if($sender->inline)
$sender->content = preg_replace($regexp,"'$1' . \$hideInline(\$this->inlineFixedContents, '$2')",$sender->content);
else
$sender->content = preg_replace($regexp,"'$1' . \$hideBlock(\$this->blockFixedContents, '$2')",$sender->content);
}
// Inline-level [fixed] tags will become <code>.
$sender->content = preg_replace("/\[code\]\n?(.*?)\n?\[\/code]/ise","\$hideInline(\$this->inlineFixedContents, '$1')",$sender->content);
}
public function handler_format_format($sender) {
$replacement = $sender->inline?"[image]":"<img src='$1' alt='-image-'/>";
$sender->content = preg_replace("/\[img\](.*?)\[\/img\]/i",$replacement,$sender->content);
$sender->content = preg_replace_callback("/\[url=(\w{2,6}:\/\/)?([^\]]*?)\](.*?)\[\/url\]/i",array($this,"linksCallback"),$sender->content);
$sender->content = preg_replace("|\[b\](.*?)\[/b\]|si","<b>$1</b>",$sender->content);
$sender->content = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/Usi","<span style=\"color:\\1\">\\2</span>",$sender->content);
$sender->content = preg_replace("/\[i\](.*?)\[\/i\]/si","<i>$1</i>",$sender->content);
$sender->content = preg_replace("/\[s\](.*?)\[\/s\]/si","<del>$1</del>",$sender->content);
$replacement = $sender->inline?"<b>$1</b>":"</p><h4>$1</h4><p>";
$sender->content = preg_replace("/\[h\](.*?)\[\/h\]/",$replacement,$sender->content);
}
public function linksCallback($matches) {
return ET::formatter()->formatLink($matches[1].$matches[2],$matches[3]);
}
public function handler_format_afterFormat($sender) {
$sender->content = preg_replace("/<code><\/code>/ie","'<code>' . array_shift(\$this->inlineFixedContents) . '</code>'",$sender->content);
if(!$sender->inline)
$sender->content = preg_replace("/<pre><\/pre>/ie","'<pre>' . array_pop(\$this->blockFixedContents) . '</pre>'",$sender->content);
}
}
=======resources/bbcode.js=======
var BBCode = {
bold: function(id) {
ETConversation.wrapText($("#" + id + " textarea"), "[b]", "[/b]");
},
italic: function(id) {
ETConversation.wrapText($("#" + id + " textarea"), "[i]", "[/i]");
},
strikethrough: function(id) {
ETConversation.wrapText($("#" + id + " textarea"), "[s]", "[/s]");
},
header: function(id) {
ETConversation.wrapText($("#" + id + " textarea"), "[h]", "[/h]");
},
link: function(id) {
ETConversation.wrapText($("#" + id + " textarea"), "[url=http://example.com]", "[/url]", "http://example.com", "link text");
},
image: function(id) {
ETConversation.wrapText($("#" + id + " textarea"), "[img]", "[/img]", "", "http://example.com/image.jpg");
},
fixed: function(id) {
ETConversation.wrapText($("#" + id + " textarea"), "[code]", "[/code]");
},
color: function(id) {
ETConversation.wrapText($("#" + id + " textarea"), "[color=red]", "[/color]");
},
};
comments: 0 / hits: 4612
6 years ago, fri, feb 10, 17, 12:02:07
//First Result
{section name="articles" loop=1 start=0}
{$articles[articles].title}
{/section}
//First and Second Result
{section name="articles" loop=2 start=0}
{$articles[articles].title}
{/section}
//Second Result
{section name="articles" loop=2 start=1}
{$articles[articles].title}
{/section}
comments: 1 / hits: 3119
6 years ago, fri, feb 10, 17, 12:15:34
<?php
//myform.php
function badWordsReplace($censored) {
$words = array("this","tutorial","sucks");
for($i = 0; $i <= sizeof($words); $i++) {
$censored = str_replace(@$words[$i],"-!!censored!!-",$censored);
}
return $censored;
}
if(isset($_POST['submit'])) {
$title = $_POST['title'];
echo badWordsReplace($title);
} else {
?>
<form method="post" action="myform.php">
<input type="text" value="this tutorial sucks" name="title">
<input type="submit" name="submit" value="Submit">
</form>
<?php } ?>
comments: 0 / hits: 2556
6 years ago, tue, feb 28, 17, 9:40:06
<?php
if(isset($_POST['submit'])) {
$gethost = $_POST['gethost'];
$gethost = gethostbyname($gethost);
echo $gethost;
} else {
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
DomainName: <input type="text" name="gethost">
<input type="submit" name="submit" value="Get a domain name IP address">
</form>
<?php } ?>
comments: 0 / hits: 2292
6 years ago, sun, mar 5, 17, 1:51:18
<?php
//$url = 'https://www.youtube.com/watch?v=7JAqDMFmTYE&index=4&list=LL5ptMSzmMcoR0g0hISVnTWw';
//$url = 'https://www.youtube.com/watch?v=NU9JoFKlaZ0&list=PLo6aG-353Cqkrei8GU5adW9ZDbW_5Nl1X';
$url = 'https://www.youtube.com/watch?v=A1OqtIqzScI&index=6&list=PLo6aG-353Cqkrei8GU5adW9ZDbW_5Nl1X&gl=JP&hl=ja';
$youtube = preg_replace("#(^|[\n ])([\w]+?://)(www\.youtube)(\.[\w\.]+?/watch\?v=)([\w-]+)([&][\w=+&;%-_]*)*(^[\t <\n\r\]\[])*#is",'
<div>Real Url: \\2\\3\\4\\5\\6</div><hr />
<div>We don\'t need this part: \\6</div><hr />
<div>Clean Url: https://www.youtube.com/v/\\5</div><hr />
<div>Another Clean Url: https://www.youtube.com/watch?v=\\5</div><hr />
<div>Video ID: \\5</div><hr />
<div>Watch Video<br /><object><param name="movie" value="https://www.youtube.com/v/\\5"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed class="video" src="http://www.youtube.com/v/\\5" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true"></embed></object></div>',
$url);
echo $youtube;
?>
comments: 1 / hits: 6480
6 years ago, thu, mar 16, 17, 5:51:45
$getdata = $_POST['getdata'];
/**
* myFilter()
*
* @return
*/
function myFilter($value) {
global $purifier;
$value = $purifier->purify($value);
return $value;
}
$getdata = array_map("myFilter",$getdata);
print_r($getdata);
comments: 1 / hits: 2455
6 years ago, sun, apr 16, 17, 3:44:59
@namespace "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
* {
font-family:verdana,tahoma;
font-size:12px;
color:#333
}
tabmail {
background-color:#cecece!important
}
toolbox {
background-color:#cecece!important
}
#threadTree treechildren::-moz-tree-row {
border-bottom:1px dotted #ddd!important;
height:26px!important
}
#folderTree treechildren::-moz-tree-row {
height:26px!important
}
#threadTree treechildren::-moz-tree-row(odd) {
-moz-appearance:none!important;
background-image:none!important;
background-color:#f8f8f8!important
}
#threadTree treechildren::-moz-tree-row(selected) {
background-color:-moz-Dialog!important
}
#threadTree treechildren::-moz-tree-row(selected,focus) {
background-color:-moz-Dialog!important
}
#folderTree treechildren::-moz-tree-row(selected) {
-moz-appearance:none!important;
background-image:none!important;
background-color:-moz-Dialog!important
}
#folderTree treechildren::-moz-tree-row(selected,focus) {
-moz-appearance:none!important;
background-image:none!important;
background-color:-moz-Dialog!important
}
#folderTree > treechildren::-moz-tree-cell-text(hasUnreadMessages-true) {
font-weight:400!important;
color:#000!important
}
comments: 1 / hits: 9675