Login in Joomla 1.5 through curl

December 1, 2011 1 comment

First of all we need three inputs.
$uname = “test”;
$upswd = “123456″;
$url = ‘http://localhost/joomla/index.php?option=com_user&view=login

//Initialize curl. This is one time curl session no need another session.
$ch = curl_init();

//Try to loging in[Joomla]
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_COOKIEJAR, ‘./cookie.txt’);
curl_setopt($ch, CURLOPT_COOKIEFILE, ‘./cookie.txt’);
curl_setopt($ch, CURLOPT_HEADER, FALSE );
$ret = curl_exec($ch);//access login page
if (!preg_match(‘/name=”([a-zA-z0-9]{32})”/’, $ret, $spoof)) {
preg_match(“/name=’([a-zA-z0-9]{32})’/”, $ret, $spoof);
}
// Collecting all POST fields
$postfields = array();
$postfields['username'] = $uname;
$postfields['passwd'] = $upswd;
$postfields['lang'] = ”;
$postfields['option'] = ‘com_user’;
$postfields['task'] = ‘login’;
$postfields[$spoof[1]] = ’1′;
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$ret = curl_exec($ch);//Get result after login page.
//Close curl and free server recourses.
curl_close($ch);

Categories: Joomla 1.5

How to copy a table structure and data

November 9, 2011 2 comments

To copy table structure run this query

CREATE TABLE database_name.`new_table_name` LIKE database_name.`old_table_name` ;

To copy table data run this query

INSERT INTO database_name.`new_table_name` SELECT * FROM database_name.`old_table_name` ;

How to set application icon

September 22, 2011 2 comments

If you want to set your own application icon in Android then here is the solution. Please follow these step.
1. Put you icon in ‘res/drawable/’ directory.
2. Open your AndroidManifeast.xml file in code mode.
3. Find this attribute ‘android:icon=”@drawable/icon’ in this tag ‘<application’. Here icon is the your icon file name. Here you have two option either you can replace ‘icon’ name with you icon file name or save icon file by ‘icon’ name.
4. Run your Emulator. Now check applications list in the emulator the new application icon installed and ready.

How to install apk files on Android Emulator

September 7, 2011 3 comments

If you looking to test any application on android emulator. Please follow these step.

1.  Run the emulator.
2. Copy the apk file to /tools folder
3. Change directory to /tools and run from commandline  adb install your_application.apk [ this command for windows if you are using linux then  $install your_application.apk ]
4. Now check applications list in the emulator the new application installed and ready.

Module creator

July 8, 2011 1 comment

This is a tool that will cut some time of work of any custom Joomla Module development. Simply enter the name of your new Joomla 1.5 module and this tool will create a ready to install zip file with all the right files inside all correctly extending the right classes etc.

Follow this link to create module Joomla 1.5 or create module Joomla 1.7 .

Check object exists or not

April 12, 2011 Leave a comment

We can check through javascript whether html element exists or not.
create this function
function checkobject(obj) {
if (document.getElementById(obj)) {
return true;
}else {
return false;
}
}

Pass element’s id in this function, this function return ‘true’ if that element exists on web page other wise return false.

 

How to get which element clicked

April 11, 2011 Leave a comment

We can find out which element clicked on web document.
First we need to create a function i.e
function gotElement(){
var ele = arguments[0] || window.event, origEl = ev.target || ev.srcElement;
alert(ele.tagName);//Getting  tag name of element.
}

Now call this function like this…
document.onclick = gotElement();

Whenever user click on click on document then a alert will open that contains tag name.

How to check browser has javascript enabled or not

April 7, 2011 Leave a comment

The <noscript> tag is used to provide an alternate content for users that have disabled scripts in their browser or have a browser that doesn’t support client-side scripting.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en”>
<head>
<title>Title</title>
<noscript>
<meta http-equiv=”refresh” content=”0;url=http://www.domain.com/errorPage.php”/>
</noscript>
</head>
<body>
</body>
</html>

Add and Remove element

October 28, 2010 1 comment

We can add any element through javascript. It is so simple and easy.  Use below script to add and remove a div element.

<html>
<head>
<title>Add Element</title>
<script language=”javascript”>
this.num = 1;
function addElement(){
$top = document.getElementById(‘top’);
newId = document.createElement(‘div’);
id = ‘my’+this.num;
newId.setAttribute(‘id’, id );
newId.innerHTML = “<a href=’javascript:void(0); ‘ onclick=’removedThis( “+id +”)’ >Added Element”+id+”</a>”;
$top.appendChild(newId);
this.num++;
}
function removedThis( id ){
var d = document.getElementById(‘top’);
d.removeChild(id);
}
</script>
</head>
<body>
<input type=”button” name=”button” value=”Add Element” onclick=”addElement()” />
<div id=”top” ></div>
</body>
</html>

Export database from MYSQL to Ms Access

April 14, 2010 Leave a comment
Download ODBC driver from
Create a system DSN for the MySQL database.
Create a new Access database, then do
File Get External Data Import…
In the Import dialog click the “Files of type” drop-down and choose
“ODBC Databases ()”. In the “Select Data Source” dialog click the
“Machine Data Source” , select the DSN you created, and click “OK”.
Select all of the tables and import them.

Download ODBC driver from http://dev.mysql.com/downloads/connector/odbc/
Create a system DSN for the MySQL database. Create a new Access database, then doFile Get External Data Import…
In the Import dialog click the “Files of type” drop-down and choose”ODBC Databases ()”. In the “Select Data Source” dialog click the”Machine Data Source” , select the DSN you created, and click “OK”.Select all of the tables and import them.

Follow

Get every new post delivered to your Inbox.