PHP – regular expression get filename and extension
//this function will return extension of file name supplied
function getFilename($filename){
preg_match("/^(.+?)(\.([^\.]*))?$/", $f, $matches);
return $matches;
}
//how to use
print_r(getFilename('test.txt'));
/* output
array('text.txt', 'test', '.txt', 'txt');
*/
Flexigrid and Codeigniter with Advanced Searching (with example)
Original site http://flexigrid.eyeviewdesign.com
New Features:
– multiple searching criteria
– customization input type (text, select, or date)
All feedback, improvements, etc are very welcome.. 🙂
this is development version, you can download example here
Requirements:
– codeigniter 1.7.2 (Download)
– jquery-1.4.2.min.js
– jquery-ui.min.js
– flexigrid.js (added new custom script, include in download package)
– jquery-ui.css
– flexigrid.css
Install:
– extract .rar to CI folder
– open your contoller (ie: CI_Folder\system\application\controllers\flexigrid.php)
– configure flexigrid helper, and customize variable $colModel, example:
// $this->load->model('ajax_model');
// $records = $this->ajax_model->get_select_countries();
// $options is result set, generate from database
$options = Array (
Array ( 'code' => 'AFG', 'name' => 'AFG' ),
Array ( 'code' => 'DZA', 'name' => 'DZA' ),
Array ( 'code' => 'ASM', 'name' => 'ASM' ),
Array ( 'code' => 'AND', 'name' => 'AND' ),
Array ( 'code' => 'AGO', 'name' => 'AGO' )
);
// create select option string format
foreach( $records as $v ) {
$options .= $v['code'] .':'. $v['name'] . ';';
}
$options = substr($options, 0, -1);
/*
* 0 - display name
* 1 - width
* 2 - sortable
* 3 - align
* 4 - searchable (2 -> yes and default, 1 -> yes, 0 -> no.)
* 5 - option for search type and select option (type = text, date, select, default type is text)
*/
$colModel['id'] = array('ID',40,TRUE,'center',2);
$colModel['iso'] = array('ISO',40,TRUE,'center',0);
$colModel['name'] = array('Name',180,TRUE,'left',1);
$colModel['printable_name'] = array('Printable Name',120,TRUE,'left',1,'options' => array('type' => 'date'));
$colModel['iso3'] = array('ISO3',130, TRUE,'left',1, 'options' => array('type' => 'select', 'edit_options' => $options));
$colModel['numcode'] = array('Number Code',80, TRUE, 'right',1, 'options' => array('type' => 'select', 'edit_options' => ":All;AND:AND;KK:KK;RE:RE"));
$colModel['actions'] = array('Actions',80, FALSE, 'right',0);
Screenshoot:
MySQL – convert string to auto increment number
SELECT
concat(
REPEAT( ‘0’ , ( LENGTH(‘00000’) – LENGTH(CAST(00009 AS UNSIGNED) + 1 ))),
CAST(00009 AS UNSIGNED) + 1
) as str;
Travian attack builder for 3.5 server bug fix
This scripts does ‘t work anymore,… you may follow this link
ok, before you following this guide, you must install greasemonkey and Travian attack builder for 3.5 server first
in this update:
- fixed error unable get active village (for multiple village)
- fixed delay in arrival time
note: this script has been tested on s1.travian.co.id
(step by step)
- in firefox, open Tools->Greasemonkey->Manage user scripts.
- after opening new window, select “Tavian attack builder for 3.5 server” script, and click edit button.
- download and extract file update.zip
- open file update2.txt with your favorite editor like (notepad, kate or gedit)
- replace and save the original script with update script.
- enjoy it..
this is for the test…
if arrival time equals with your time, this information will show in the bottom of your page




