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 / 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 / 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 / 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 / cover_photo_upload.php
Created July 12, 2014 23:51
Script to upload a photo and set it as the cover image for a Facebook Page
<?php
// include Facebook PHP SDK
include "facebook/facebook.php";
// init Facebook SDK with app settings
$facebook = new Facebook( array( 'appId' => APP_ID, 'secret' => APP_SECRET ) );
// enable file upload support
$facebook->setFileUploadSupport( true );
@SecureCloud-biz
SecureCloud-biz / cover_image_url.php
Created July 12, 2014 23:50
Script to upload a photo and set it as the cover image for a Facebook Page
<?php
// Script to upload a photo by URL (i.e. remote resource) Use Above Script
// upload a photo to facebook by URL, will return id of uploaded photo
$photo_uploaded = $facebook->api( $page_id . "/photos", "POST", array(
'url' => 'http://healthhub.co/wp-content/uploads/2014/02/Group-Slider.jpg', // remote URL to image
'no_story' => true // suppress automatic image upload story, optional
) );
@SecureCloud-biz
SecureCloud-biz / console_message.js
Created July 12, 2014 23:48
Leave a message for those pesky developers who like inspecting websites
var Util = {
is_webkit: function() {
return navigator.userAgent.indexOf("AppleWebKit") > -1;
},
message: function() {
if ( typeof console == "object" ) {
if ( Util.is_webkit() ) {
console.log( "%cHey! Why are you looking here for?\nDeveloped by SecureCloud http://www.securecloud.biz", "color: #359AD8; font-size: 18px; font-family: 'Trebuchet MS', Helvetica, sans-serif;" );
} else {
console.log( "Hey! Why are you looking here for?\nDeveloped by SecureCloud http://www.securecloud.biz" );
@SecureCloud-biz
SecureCloud-biz / photo_comment.php
Created July 12, 2014 23:43
Adding a comment with a photo to Facebook
<?php
include "facebook/facebook.php";
$facebook = new Facebook( array( 'appId' => APP_ID, 'secret' => APP_SECRET ) );
// enable upload support
$facebook->setFileUploadSupport( true );
// set access token for user / page here (not needed if you intend to use the login flow beforehand)
@SecureCloud-biz
SecureCloud-biz / php_action_link.php
Created July 12, 2014 23:42
Adding actions to Facebook Posts
@SecureCloud-biz
SecureCloud-biz / action_links.html
Created July 12, 2014 23:42
Adding action links to posts using JavaScript and the FB.UI Feed dialog.
@SecureCloud-biz
SecureCloud-biz / fb_4.0.x.php
Created July 12, 2014 23:41
Facebook PHP SDK 4.0.0 Example
<?php
// include required files form Facebook SDK
// added in v4.0.5
require_once( 'Facebook/FacebookHttpable.php' );
require_once( 'Facebook/FacebookCurl.php' );
require_once( 'Facebook/FacebookCurlHttpClient.php' );
// added in v4.0.0