Skip to content

Instantly share code, notes, and snippets.

View SecureCloud-biz's full-sized avatar

Terry DeSimone SecureCloud-biz

View GitHub Profile
@SecureCloud-biz
SecureCloud-biz / ajax_csrf.html
Created July 12, 2014 23:52
Added CSRF token to AJAX calls using Form Serialization
<!-- create form with open_form() -->
<form action="http://testapp.com/login" method="post" accept-charset="utf-8" id="login-form" class="login">
<div style="display:none">
<input type="hidden" name="csrf_test_name" value="80bfb80b356d6d31f4ce4dad0c6cf69e">
</div>
...
...
</form>
<!-- Update AJAX code to post serialized data -->
@SecureCloud-biz
SecureCloud-biz / ajax_csrf.html
Created July 12, 2014 23:53
Added CSRF token to AJAX calls using JavaScript Variable
<!-- add to HEAD -->
<script type="text/javascript">
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
</script>
<!-- Update AJAX code, change csrf_test_name as needed -->
<script type="text/javascript">
$.post( ajax_url, { data: 'value', 'csrf_test_name': csrf_value }, function( response ) {
// response
}, 'json' );
@SecureCloud-biz
SecureCloud-biz / manual_csrf.php
Created July 12, 2014 23:54
Manual CSRF token in CodeIgniter
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
@SecureCloud-biz
SecureCloud-biz / login_form.php
Created July 12, 2014 23:55
CodeIgnitor Form with CSRF token added
<form action="http://testapplication.com/login" method="post" accept-charset="utf-8" id="login-form" class="login">
<div style="display:none">
<input type="hidden" name="csrf_test_name" value="80bfb80b356d6d31f4ce4dad0c6cf69e">
</div>
...
...
</form>
@SecureCloud-biz
SecureCloud-biz / action_links.html
Created July 13, 2014 00:08
ALL-IN-ONE - Facebook PHP SDK 4.0.x
window.fbAsyncInit = function() {
FB.init({
appId : 'xxx', // App ID
channelUrl : 'channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Remove those pesky scrollbars
html, body {
width: 810px;
overflow: hidden;
}
<!-- anchor example -->
<a href="#" onclick="FB.Canvas.scrollTo( 0, 500 );">Click here to enter</a>
<!-- anchor with jQuery dynamic placement example -->
<a href="#" onclick="FB.Canvas.scrollTo( 0, $('.enter-btn').offset().top );">Click here to enter</a>
<!-- page load example -->
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
<div class="well">
<button
class="g-interactivepost btn btn-info"
data-contenturl="https://play.google.com/store/apps/details?id=com.cagecricket.app"
data-contentdeeplinkid=""
data-clientid="xxxxx.apps.googleusercontent.com"
data-cookiepolicy="single_host_origin"
data-prefilltext="Download the Cage Cricket application and easily record your scores for this great urban-friendly version of Cricket."
data-calltoactionlabel="INSTALL_APP"
data-calltoactionurl="https://play.google.com/store/apps/details?id=com.cagecricket.app"
<?php
$appId = 'aaaaaaaaaaaa';
$appSecret = 'bbbbbbbbbbbb';
// init facebook
$facebook = new Facebook( array( 'appId' => $appId, 'secret' => $appSecret ) );
// get user_id, 0 if not logged in
$user = $facebook->getUser();