Skip to content

Instantly share code, notes, and snippets.

@abidibo
abidibo / get_tree_from_table.php
Created November 10, 2011 16:03
Recursion to get a tree from a id-parent sql table
<?php
// I use here Jeff's db methods
public function getTree($registry, $parent=0) {
$child_rows = $registry->db->autoSelect("id", TABLE, "parent='$parent'", "name");
$children = array();
@abidibo
abidibo / fck_editor_chr_counter.js
Created November 9, 2011 14:42
A proof of character counter for fck editor 2.x
// requires mootools-core bind function
function FCKeditor_OnComplete(editorInstance){
editorInstance.EditorDocument.addEventListener('keypress', checkCharacters.bind(editorInstance));
}
function checkCharacters(e) {
@abidibo
abidibo / recreate_session.php
Created November 7, 2011 15:59
Recreate a php session
<?php
define('SESSION_TIMEOUT', '1800'); // 30 minutes
session_name('fuckIE');
session_start();
// ...bla bla
if (isset($_SESSION['last_activity']) && (time() - $_SESSION['last_activity'] > SESSION_TIMEOUT)) {