Null Disquisition

In Mother Russia, Thesis writes You!

Archive for the ‘php’ tag

Naruto easy player

without comments

Well. Damn. Not much to update about my thesis. Been working on a 1d solution to the diffusion equation with a drift potential (see Fokker-Planck). When I get some pretty pictures for that I’ll post them.

In the mean time, I made an awesome time-saving app for watching Naruto. Took me about 5 mins (granted I’ve been doing a lot of PHP programming lately). Goes like this:

  • cURL request to MySpaceTV for “Naruto Episode ###”
  • uses preg_match to find the first result
  • strips out the video id and pastes it into a flash embed

Check out the source or watch an episode yourself!

-David

Written by david

October 9th, 2008 at 3:59 am

Posted in General

Tagged with , ,

CodeIgniter Session id

with 3 comments

Just a quick blurb. I had a problem with CodeIgniter regenerating the session id all willy-nilly.

Here’s a snip from the config.

$config['sess_cookie_name'] = ‘ci_session’;
$config['sess_expiration'] = 54000;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = ’sessions’;
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent']  = TRUE;
$config['sess_time_to_update'] = 300;

Turns out, CodeIgniter will regenerate the session id every time it updates the session table in the database. So, by default the session id gets regenerated every 5 mins (300 seconds). Instead of changing the sess_time_to_update value, I dug around in the code for a bit.

Here’s the culprit. (In basedir/system/libraries/Session.php)

$old_sessid = $this->userdata['session_id'];
$new_sessid = “”;
while (strlen($new_sessid) < 32)
  $new_sessid .= mt_rand(0,mt_getrandmax());
$new_sessid = md5(uniqid($new_sessid,True));

Talk about entropy…

Quick hack: comment out these lines and set $new_sessid = $this->userdata['session_id'];

Bang. Zoom. Straight to the Moon.

Written by david

June 23rd, 2008 at 7:45 pm

Posted in Code Igniter

Tagged with , , ,