Skip to content

Instantly share code, notes, and snippets.

View rajvanshipradeep15's full-sized avatar

Pradeep Rajvanshi rajvanshipradeep15

  • India
View GitHub Profile
@rajvanshipradeep15
rajvanshipradeep15 / last query executed
Created May 24, 2013 08:11
codeigniter: last query executed
$this->db->last_query();
Returns the last query that was run (the query string, not the result). Example:
$str = $this->db->last_query();
// Produces: SELECT * FROM sometable....
@rajvanshipradeep15
rajvanshipradeep15 / gist:5642958
Created May 24, 2013 11:47
website: phishing attack
phishing attack
What to be done if your website is under phishing attack
1) http://www.semanticoverload.com/2009/03/17/if-your-site-has-been-compromised-with-phishing-attack- code/index.html
2) http://google-gruyere.appspot.com/
@rajvanshipradeep15
rajvanshipradeep15 / gist:5696434
Created June 3, 2013 06:36
joomla: include jfactory class in external php file
Include Jfactory class in external php file
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ] );
... then you need to include three files, like:
require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
@rajvanshipradeep15
rajvanshipradeep15 / gist:5705284
Created June 4, 2013 11:34
php : importing csv file to mysql
<?php
/*$connect = mysql_connect('localhost','root','12345');
if (!$connect) {
die('Could not connect to MySQL: ' . mysql_error());
}*/
// $cid =mysql_select_db('test',$connect);
// supply your database name
@rajvanshipradeep15
rajvanshipradeep15 / countrycodes
Created June 17, 2013 08:28
Country codes: countrycodes
$country_array = array(
"AA" => "Please select country",
"AFG" => "Afghanistan" ,
"ALB" => "Albania" ,
"DZA" => "Algeria" ,
"ASM" => "American Samoa" ,
"AND" => "Andorra" ,
"AGO" => "Angola" ,
"AIA" => "Anguilla" ,
"ATA" => "Antarctica" ,
// to calculate age
$interval = date_diff(date_create(), date_create('2008-01-01 10:30:00'));
echo $interval->format("You are %Y Year, %M Months, %d Days, %H Hours, %i Minutes, %s Seconds Old");
About Date
/* $startYear=strtotime(date("Y-04-1"));
$startYear = date('Y-m-d', $startYear);
// echo "startyear : ". $startYear;
// $startYear = DateTime::createFromFormat('Y-m-d', $startYear);
@rajvanshipradeep15
rajvanshipradeep15 / zipfile upload
Created August 19, 2013 07:20
upload a zip file and unzip inserver
if($_FILES["zip_file"]["name"]) {
$filename = $_FILES["zip_file"]["name"];
$source = $_FILES["zip_file"]["tmp_name"];
$type = $_FILES["zip_file"]["type"];
$name = explode(".", $filename);
$accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
foreach($accepted_types as $mime_type) {
if($mime_type == $type) {
$okay = true;
break;
$db =& JFactory::getDBO();
$db->setQuery( $query );
$db->query();
To get the last insert id:
$db->insertid();
To get Number of rows fetched
$db->getNumRows();
echo JHTML::_('calendar','value', 'start', 'id', $format = '%d-%m-%Y', array('class'=>'inputbox', 'size'=>'25', 'maxlength'=>'19'));
@rajvanshipradeep15
rajvanshipradeep15 / checkbox code
Created September 8, 2013 15:07
php checkboxes code
$('#' + id).is(":checked")
that gets if the checkbox is checked.
for an array of checkboxes with the same name you can get the list of checked ones by
var boxes = $('input[name=thename]:checked');
then to loop through them and see what's checked you can do