Skip to content

Instantly share code, notes, and snippets.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
define('DS', DIRECTORY_SEPARATOR, TRUE);
class Template {
public $template_dir;
public $template_cache;
public $template_expiry;
// Error
// -----
Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/localhost/www/application/cache/106a6c241b8797f52e1e77317b96a201.tpl on line 3
// Php: home.php
// -------------
$home = $this->template->load('home');
$home->assign('name', 'FOOBAR');
$home->assign('me', array('good'=>'LAKA'));
$home->render();
<?=lang('album', 'album')?>
<select name="album_id">
<?php foreach($user_albums as $user_album): ?>
<option value="<?=$user_album->id?>"><?=$user_album->title?></option>
<?php endforeach ?>
@hemache
hemache / hosted_example.txt
Created December 3, 2012 15:52 — forked from makevoid/hosted_example.txt
JQuery DOM HighLighter (it's a basic "Inspect element" simple implementation to mimic what webkit inspector and firebug do)
http://uploads.makevoid.com/jquery_dom_highlighter.html
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
<?
$num_files = 5;
while($num_files){
echo '<input type="file" name="file[]" /> <br>';
$num_files --;
}
?>
<input type="submit" name="upload" />
@hemache
hemache / gist:4259698
Created December 11, 2012 16:04
redirect after login
/* page.php?xxxx */
$next = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
printf('<a href="login.php?next=%s">login</a>', $next);
/* login.php */
$next = $_GET['next'];
/* ... */
// حول المتسخدم الى الرابط الذي جاء منه
@hemache
hemache / gist:4259741
Created December 11, 2012 16:06
redirect after login
/* page.php?xxxx */
$next = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
session_start();
$_SESSION['next'] = $next;
printf('<a href="login.php">login</a>', $next);
/* login.php */
session_start();
$next = $_SESSION['next'];
/* ... */
@hemache
hemache / .htaccess
Created December 20, 2012 20:11
Codeigniter htaccess
Options -Indexes
Options +FollowSymLinks
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# mod_rewrite rules
RewriteEngine on
@hemache
hemache / filter.py
Last active December 10, 2015 07:18
#!/usr/bin/env python
from time import strftime, strptime, mktime
file_name = 'names.lst'
trash_file_name = 'old_names.lst'
filter_date = strftime('%d-%m-%Y') #'01-01-2012'
def timestamp(strtime, format = '%d-%m-%Y'):
return mktime(strptime(strtime, format))
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\w+)\.php\?id=([0-9]+)$ page-router.php?name=$1&id=$2 [QSA,L]
</IfModule>