Skip to content

Instantly share code, notes, and snippets.

@devyfriend
devyfriend / common_helper.php
Last active December 11, 2015 23:58
my Codeigniter common helper
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
function test($x,$exit=0)
{
echo $res = "<pre>";
if(is_array($x) || is_object($x)){
echo print_r($x);
}else{
echo var_dump($x);
}
@devyfriend
devyfriend / fb_updateuser.php
Created February 2, 2013 13:49
Codeigniter function to update facebook user
function update_user($goto = '')
{
$this->load->model('app_m');
try {
$user = $this->facebook->api('me');
$this->apps_m->update_userdata($user);
$this->session->set_userdata('me', $user);
$this->session->set_userdata('fb_access_token', $this->facebook->getAccessToken());
} catch (FacebookApiException $e) {
$code = @$_GET['code'];
@devyfriend
devyfriend / MY_Model.php
Created February 2, 2013 13:52
Codeigniter MY_Model on core folder
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Model extends CI_Model {
public $error_string, $new_id;
function __construct()
{
parent::__construct();
@devyfriend
devyfriend / MY_Encrypt.php
Created February 10, 2013 13:23
Codeigniter custom encryption library with safe uri
<?php
class MY_Encrypt {
private $skey = "SuPerEncKey2013"; // you can change it
public function safe_b64encode($string) {
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
@devyfriend
devyfriend / FB_page.html
Created February 12, 2013 22:20
Facebook sample open graph action page
<html xmlns:fb="http://ogp.me/ns/fb#">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# oghowto: http://ogp.me/ns/fb/oghowto#">
<title>OG Tutorial App</title>
<meta property="fb:app_id" content="256521937796214" />
<meta property="og:type" content="oghowto:demo" />
<meta property="og:title" content="Open Graph HowTo" />
<meta property="og:image" content="http://placehold.it/200x200" />
<meta property="og:description" content="Minimum requirements to get Open Graph objects and actions working" />
<meta property="og:url" content="http://oghowto.herokuapp.com/test.html">
<style type="text/css">
@devyfriend
devyfriend / MY_Security.php
Created February 12, 2013 23:26
Codeigniter white list csrf and custom if for fb apps and jquery csrf snippet
/* sample code on ajax csrf
$.ajax({
type: 'POST',
url: '/action/fetch_more_blog_posts',
data: {
type: 'news', limit: limit, offset: offset,
<?php echo $this->security->get_csrf_token_name(); ?>: '<?php echo $this->security->get_csrf_hash(); ?>' },
success: function(data) {
$(data).appendTo('#more-entries');
$('#older-posts').slideDown();
<!doctype html>
<html itemscope itemtype="http://schema.org/Movie">
<head>
<meta charset="utf-8">
<title>Brad Pitt in WORLD WAR Z | Trailer & Official Movie Site | June 21 2013</title>
<link rel="image_src" type="image/jpeg" href="img/thumb.jpg"/>
<link rel="canonical" href="http://www.worldwarzmovie.com/" />
<link rel="alternate" media="only screen and (max-width: 640px)" href="http://www.WorldWarZMovie.com/mobile/" >
<meta property="og:title" content="Brad Pitt in WORLD WAR Z | Trailer & Official Movie Site | June 21 2013" />
<meta property="og:type" content="movie" />
function _merge_photo($original_image)
{
//test(FCPATH.'assets/loop/img/frame.png',1);
# If you don't know the type of image you are using as your originals.
$image = imagecreatefromstring(file_get_contents(FCPATH.'loop_upload/'.$original_image['file_name']));
$frame = imagecreatefrompng(FCPATH.'assets/loop/img/frame.png');
# If you know your originals are of type PNG.
//$image = imagecreatefrompng($original_image);
//$frame = imagecreatefrompng($frame_image);
Bali
Bangka Belitung
Banten
Bengkulu
DI Yogyakarta
DKI Jakarta
Gorontalo
Jambi
Jawa Barat
Jawa Tengah
@devyfriend
devyfriend / MY_Loader
Created April 21, 2013 07:49
Codeigniter .... application/core/MY_Loader.php, ability do add / edit "views" folder location, good for themes, dynamic "views" location
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/* load the MX_Loader class */
require APPPATH."third_party/MX/Loader.php";
class MY_Loader extends MX_Loader {
function __construct(){
parent::__construct();
}