Skip to content

Instantly share code, notes, and snippets.

@sotoz
sotoz / sessionfix.php
Created December 14, 2015 12:50
Session fix for codeigniter
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once BASEPATH . '/libraries/Session.php';
class MY_Session extends CI_Session
{
function __construct()
{
parent::__construct();
$this->CI->session = $this;
}
@sotoz
sotoz / fetchimage.php
Created December 14, 2015 12:50
Fetch image with php
private function grab_image($url,$saveto)
{
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$raw=curl_exec($ch);
curl_close ($ch);
if(file_exists($saveto)){