Welcome to CodeGlobe. CodeGlobe provides free source code, tutorials and latest useful technology news.
Tuesday, December 8, 2009
Monday, December 7, 2009
send SMS using way2sms updated by sujith and joji
u = null; uc = null;
for (long num : numbers)
{
content = "HiddenAction=instantsms&login=&pass=&custid=undefined&MobNo=" + num + "&textArea=" + msg;
change this content part in previous post by
content = "custid=undefined&HiddenAction=instantsms&Action=custfrom50000&login=&pass=&MobNo=" + phone + "&textArea=" + msg+"&qlogin1=Gmail+Id&qpass1=******&gincheck=on&ylogin1=Yahoo+Id&ypass1=******&yincheck=on";
cellphone application providers cochin kerala
economic web hosting web development plans kerala cochin
Sunday, November 22, 2009
When i try to open my hard drives, it pop ups "open with" window?
This isn't necessarily a virus.
Try this:
Start
Run
Type: regsvr32 /i shell32
Enter
If the problem exists,
- Download FixDrive.zip and save it to Desktop
- Unzip the file and extract the contents (FixDrive.exe and readme.txt) to a folder
- Double FixDrive.exe to run it
- Select the drive-letter from the list that's exhibiting the problem
- Click Fix
Screenshot
FixDrive (for Windows XP / Windows Vista)
Friday, November 6, 2009
GET ALL FIELD NAMES FROM A GIVEN TABLE
To Retrieve All Column names from a given table using Mysql query
There are situation, we need to have retrieve column names associated with particular a particular table. For this so many techniques are available
here is the query
SELECT
COLUMN_NAME
FROM information_schema.COLUMNS
WHERE
table_name ='your table_name';
Here we are using simple select query to return the desired output
what is information schema
INFORMATION_SCHEMA
provides access to database metadata. A schema is a database, so the information_schema provides information about databases. Metadata is data about the data, such as the name of a database or table, the data type of a column, or access privileges. Other terms that sometimes are used for this information are data dictionary and system catalog.more...
Here COLUMN_NAME is in the COLUMN associated with information schema.The entire query is direct and simple huh?
regards..
Sunday, October 25, 2009
Google Map API V3 tutorial
Every one on web know Google map,Best mapping from google .But some know about the google map API and it’s very easy to use.
It’s great news that google released new version of google map API version 3.
The previous version will continue(V3).Nevertheless as a beginner to google map API I recommend Version 3 because it has great added advantage over Version 2 .
Some of the the advantages I noticed include
You need only develop a map it can run on android phones,website,iphone
and speed .
Other advantages we discuss later in this article.
For those who are beginner with google map go with v3 and those who want to switch from v2 this is the best time.because google map is in Labs and when it become full fledged you can go your study parallel.
About the API
Google map API is available to you in javascirpt language .You can integrate it with any of your server side programming like PHP,ASP.net JSP etc .
The previous version of API used a unique key for each user they want to use map in their application
For example if codeglob.blogspot.com want to use google map api v2 we have to sign up for the api using the site url and google account, a unique key is generated for you website.
Things have changed here is the happy news .You don’t need to use a API key for the Map API V3.
How to setup
We already told that MAP api is Javascript API .We need to add reference in our webpage.
<script type=”text/JavaScript” src=”http://maps.google.com/maps/apis/js?sensor=false”>
</script>
By doing this you added the reference to Google map API in your webpage.
Only thing you remember when referencing to google map is setting the sensor parameter
sensor = true/false this tells the map api whether you are using GPS sensor or not .
Next we look at the how we can initialize the map
Map needs a canvas to draw ,ie area in webpage usually used <div>
So create a div and give a id for the div
Eg:
<div id=”map”></div>
inorder to specify the width and height of the div specify a css style in page in style tag or external css file.
<style type=”text/css”>
#map
{
height:300px;
width:300px;
}
</style>
API v3 use JSON (Javascript Object Notation) for creating object .It’s easy when we use javascript object to set values.
Eg: We have an object car and it have some properties like color,tyre,type,make,model etc we can create a Javascript object of car like this
Car
{
color:red;
tyre:4;
make: Hyundai;
model:i-20
};
like this in Map Api uses some javascript objects. To access object property just call it like
alert(Car.color);
Map initialization
Map uses latitude longitude value( a particular point in map) .Setting initial latitude and longitude is like this
var latlng = new google.maps.LatLng(‘latitude value’,’longitude value’);
To initialize map we need to call the contructer of the class Map in Google map API.It takes two arguments one is the canvas that we need to draw the map HTML element .We already told that we setup div named map for showing map. And the second argument is the map otions.Map options is given in the format of JSON. .
So we create a options object having the folloging format
//Properties of the map
Options
{
zoom:16;//map has 0-19 zoom levels
center:latlng;// previously declared Latitide Longitude variable
mapTypeId: google.map.MapTypeId.ROADMAP;// Google map Type
};
Google map Support four types of maps
ROADMAP
HYBRID
SATELITE
TERRAIN
Next we call the constructer by passing the values to initialize the map.
Var map= new maps.google.Map(document.getElementById(‘map’),options);
Then the map is visible to you when you browse the page in browser.
Complete sample code for Google map Initialization
Adding marker and Info Window to the map
var marker= new google.maps.Marker({
position: new google.maps.LatLng(9.099761549253056,76.5246167373657),
title: "Hello Testing",
clickable: true,
map: map
});
var infiwindow = new google.maps.InfoWindow(
{
content: “Hello"
});
google.maps.event.addListener(marker,'mouseover',function(){
infiwindow.open(map,marker);
});
google.maps.event.addListener(marker,'mouseout',function(){
infiwindow.close(map,marker);
});
Here is the sample complete code for this article
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Google Map Test </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function initialize()
{
var latlng = new google.maps.LatLng(9.931544168615512,76.27632894178791);
var opt =
{
center:latlng,
zoom:10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableAutoPan:false,
navigationControl:true,
navigationControlOptions: {style:google.maps.NavigationControlStyle.SMALL },
mapTypeControl:true,
mapTypeControlOptions: {style:google.maps.MapTypeControlStyle.DROPDOWN_MENU}
};
var map = new google.maps.Map(document.getElementById("map"),opt);
var marker= new google.maps.Marker({
position: new google.maps.LatLng(9.931544168615512,76.27632894178791),
title: "CodeGlobe",
clickable: true,
map: map
});
var infiwindow = new google.maps.InfoWindow(
{
content: " I am here! "
});
google.maps.event.addListener(marker,'mouseover',function(){
infiwindow.open(map,marker);
});
google.maps.event.addListener(marker,'mouseout',function(){
infiwindow.close(map,marker);
});
}
function test(event)
{
alert( event.latLng.lat());
alert(event.latLng.lng());
}
</script>
<style type"text/css">
#map{
width:500px;
height:500px;
float:left;
position:absolute;
left:300px;
top:200px;
}
</style>
</HEAD>
<BODY onload="initialize();">
<div id="map" >
</div>
</BODY>
</HTML>
If you have any problem implementing google map API please mail me: irshadcp at gmail dot com
Monday, October 19, 2009
Zion Dengon 1.0 Beta
Redefine the way of SMS ing...Download.
Zion Dengon is an application that allows you to send messages in two ways
1.Using normal way.
2.Using way2sms account(you need GPRS enabled phone)
The key features and functionalities
1.You can maintain your own contact list and from those contact you can select multiple users and add to your message recipients.
2.It is the modifed version of Zion SMS Mania and combined version of Zion SMS and Zion SMS Mania.
2.You can add your contact member in two ways
a)By using the add contact option
b)By browsing your phone contact
I prefer the first way in this case you just need to enter the name of the person and if his/her number is already in your phone contact you have option to browse that number,and then you can add it to the Zion Dengon contact.
In the second way you don't need to type anything,just select the contact list that exist in your phone shown in the multi selection list,you feel this as more easy but actually it is more time consuming.
Note:Never add all the contacts at a a time(in option b) it will take more time to do and show in list.
For more details contact-email:xpedition009@gmail.com
Enjoy SMS ing..
Thursday, October 15, 2009
HTML Form elements array
Array is a collection of similar data elements, means we can use array to store similar elements referenced under a common name.
In web development sometimes we need to group HTML form elements as arrays do. For example, you have a form where user has to select his hobbies from a group of check boxes as given below.
Sample Code
<form action="showlist.php" method="post" name="hobby_frm"> <h3> Select your hobbies </h3> <input type="checkbox" name="hobbies[]" value="hb1" /> Reading <br /> <input type="checkbox" name="hobbies[]" value="hb2" /> Surfing <br /> <input type="checkbox" name="hobbies[]" value="hb3" /> Listening to music <br /> <input type="submit" value="submit" /> </form>Please notice the name of all checkboxes hobbies[]
The above code will define an array with the name hobbies
Accessing form elements array using JavaScript
Now, let's see how to access the hobbies[] using JavaScript.
<script type="text/javascript"> var hobbies = document.hobby_frm.elements['hobbies[]']; var str = "Length : "+hobbies.length+"\n"; for( var i = 0; i < hobbies.length; i++ ) { str = str + "Hobby "+(i+1)+" : "+hobbies[i].value+"\n"; } alert(str); </script>Handle form elements array in PHP
In PHP, data sent from a form with post method is available in $_POST array.
We can access hobbies[] using the following code.
<?php
$hobbies = $_POST['hobbies']; // use name of the array as key
foreach( $hobbies as $value )
print $value;
?>
courtesey webdevelopment hosting company cochin kerala
Friday, October 9, 2009
Zion Plus-2010(Beta)
Manage text files in your mobile phone in a more flexible manner..Download.
A new release of previous version of Zion Plus..More functionalities and a new look..useful and flexible than the previous version..try it today itself..
Its a Beta version modifications and performance issues will be updated in the coming versions..
An application that allows you to create text files in phone memory and memory card. If you want to create folder in your mobile through this application edit the "directoy" field,shown when you choose save or save as option. for eg: the directory field shows -"file:///e:/folderx/" you can create a folder "NEWFOLDER"in that directory by changing the field by "file:///e/folderx/NEWFOLDER/" You can specify the file name in the filename textbox,default name will be newfile. Help menu to assist you in how to use this application.
Wednesday, September 30, 2009
Wednesday, September 23, 2009
Lost Task Manager? alternate solution!
it is happy to know that the malicious program writers or the virus writers are really scare with this Task manager. A experienced administrator can easily find out
with the help of this task manager what are the suspected programs running in the background other than the normal programs. consequently their program process could be stopped by the administrator. In order to prevent this these ugly guys often programmed into disable the task manager.
Task manager can be re enabled in a file using "gpedit.msc" in the administrative templates that is there.But the "ugly" writers are more than of that when we re enable the task manager, within seconds or less than of second they will disappear it again.This means the malicious program still running in the background and must be stopped right?
Here is the solution...
netstat command could be used for alternative of to identify what are the program running in the background according to their name,memory usage and process ID.
here is a brief description of netstat with very useful options.
netstat -anbo
-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection
-a Displays all connections and listening ports
-b Displays the executable involved in creating each connection or
listening port.
the above command in the cmd will result a detailed status of the program with name, process id, including the dll fles etc.
simply use the process id to input to the "tskill" command.
ex.
tskill 8299
where 8299 will be the process id of suspected process.And this is one of the ways you can achieve this task right?.
regards..
Sunday, September 20, 2009
Struts2 align check box vertical
display the check boxes vetrically ie line by line. For aligning this as vertical we have to do as specified below
1) You have to create a directory template in your src folder
2) create a folder with name of the template you want to create (vertical-checkbox)
3) copy the struts-2.1.6/src/core/src/main/resources/template/simple/checkboxlist.ftl file to this directory content of this file is as follows. Before the </@s.iterator> you have to put a <br> tag as I given in this
<#--
/*
* $Id: checkboxlist.ftl 720258 2008-11-24 19:05:16Z musachy $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-->
<#assign itemCount = 0/>
<#if parameters.list??>
<@s.iterator value="parameters.list">
<#assign itemCount = itemCount + 1/>
<#if parameters.listKey??>
<#assign itemKey = stack.findValue(parameters.listKey)/>
<#else>
<#assign itemKey = stack.findValue('top')/>
</#if>
<#if parameters.listValue??>
<#assign itemValue = stack.findString(parameters.listValue)?default("")/>
<#else>
<#assign itemValue = stack.findString('top')/>
</#if>
<#assign itemKeyStr=itemKey.toString() />
<input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
<#if tag.contains(parameters.nameValue, itemKey)>
checked="checked"<#rt/>
</#if>
<#if parameters.disabled?default(false)>
disabled="disabled"<#rt/>
</#if>
<#if parameters.title??>
title="${parameters.title?html}"<#rt/>
</#if>
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
/>
<label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
<br>
</@s.iterator>
<#else>
</#if>
4) <s:checkboxlist list="urlist" name="selectedValues" listKey="id" listValue="descrption" theme="vertical-checkbox"></s:checkboxlist>
this will give you vertical check box list
only difference is that here you have to specify the theme which is same as the directory u have created in the template directory in the src folder of your project
Monday, September 14, 2009
Send Email from Java program using apache commons email
Download
Here I am giving you a sample code which lets you to send email fromyuor system
SimpleEmail email = new SimpleEmail();
email.setHostName("localhost");
try {
email.addTo("nimishth@gmail.com","Nimish T");
email.setFrom("admin@localhost");
email.setSubject("test");
email.setMsg("test message");
email.send();
} catch (EmailException e) {
e.printStackTrace();
}
first of all you have to include the downloaded library into u'r class path
after that write a java class and create an instarnce of SimpleEmail
then you have to set the set the host name, from address and to address
after that just add the message you want to send and and set a subject for the
perticular instance of the SimpleEmail class. here after you can call the sen method
which will send the email to the to address you have specified here its nimishth@gmail.com
If u want to send the mail using oter hservice providers such as gmail or oters
u have to change the the host name by the smtp address of the service provider you want to use
but there need authentication also
ie
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
try {
email.addTo("nimishth@gmail.com","Nimish T");
email.setFrom("your email address");
email.setAuthentication("yoru email address", "your password");
email.setTLS(true);
//465 or 587 which is the port number here
email.setSmtpPort(587);
email.setSubject("Test");
email.setMsg("test");
email.send();
} catch (EmailException e) {
e.printStackTrace();
}
You will get more details about the mail such as attachment, html mail etc from
User Guide
Saturday, September 12, 2009
Retrieving Query Result in a Tree Structure in MS SQL SERVER using Common Table Expression (CTE)
WITH cte_name [(col1,col2,......,coln)] (Here the column names are optional)
AS
(
cte_query (Anchor member defined here)
UNION ALL
cte_query(recursive member referencing cte_name here)
)
select statement to retrieve the result
A recursive CTE consists of three elements:
1). Invocation of the routine
This part consist of one or more cte_query definitions joined by UNION ALL, UNION, EXCEPT, or INTERSECT operators. This query definitions are referred to as anchor elements because they form the base resultset of CTE.
2)Recursive invocation of routine
The recursive invocation includes one or more CTE_query_definitions joined by UNION ALL operators that reference the CTE itself. These query definitions are referred to as recursive members.
3)Termination check.
The termination check is implicit i.e recursion stops when no rows are returned from the previous invocation.
The semantics behind CTE is as follows:
a)Splitting the CTE expression into anchor and recursive members.
b) Then we run the anchor member creating the first invocation or base result, say BR0 .
c) Now we run the recursive member with BRi(where i=0 to n) as input and BRi+1 as output.
d) Repeat step c until an empty set is returned.
e)Return the resultset this is BR0 UNION ALL BRn
Example Query
WITH MyLedger(BranchID, AccParentID, AccID) AS
(
SELECT DISTINCT BranchID,AccParentID, AccID
FROM GeneralLedger
WHERE ActiveFlag='Y'
UNION ALL
SELECT e.BranchID,e.AccParentID, e.AccID
FROM GeneralLedger e
INNER JOIN MyLedger d
ON e.AccParentID = d.AccID AND E.BranchID=d.BranchID AND ActiveFlag='Y'
)
SELECT * FROM MyLedger
BranchID-denotes the branch.
AccParentID- denotes the parent group here.
AccID-denotes the account id.
The above result displays a General Ledger in a Tree Structure branch wise. Here we form our base result from the table GeneralLedger.
Happy Programming...... Enjoy!!!!!!!!!!!!!!!!!!!!!!!!!
Retrieve Query result(records) as Comma Separated Value in SQL Server
DECLARE @s varchar(3500)
SET @s=''
SELECT @s=state +','+@s FROM Country WHERE countryname='INDIA'
SELECT @S
The keyword DECLARE is used to declare a variable named s and declare its datatype as varchar which can hold upto 3500 chars. Then we use the SET keyword to null string because if we dont assign it to null string the result will also be null. Now we use SELECT keyword to assign the result set into @s. Then at last we print our result using the last SELECT Keyword.
I know what i presented here is not a "Big thing", But every one knows nothing is so simple ever..........................
Thursday, August 27, 2009
File Upload Struts2
fileupload.java contains a file field and a submit button
fileupload.jsp
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:form action="addDocument" enctype="multipart/form-data" method="POST">
<table>
<tr>
<td><s:file label="File" name="data"></s:file></td>
</tr>
<tr>
<s:submit type="submit" theme="simple" value="Upload" />
</tr>
</table>
<s:form>
DocumentAction.java
package in.codeglobe.fileupload.action;
public class DocumentAction extends ActionSupport {
private File data;
private String dataContentType;
private String dataFileName;
private Document document = new Document();
public Document getDocument() {
return document;
}
public void setDocument(Document document) {
this.document = document;
}
public File getData() {
return data;
}
public void setData(File data) {
this.data = data;
}
public String getDataContentType() {
return dataContentType;
}
public void setDataContentType(String dataContentType) {
this.dataContentType = dataContentType;
}
public String getDataFileName() {
return dataFileName;
}
public void setDataFileName(String dataFileName) {
this.dataFileName = dataFileName;
}
public String add() {
String result = "view";
try {
FileInputStream fis;
byte[] content = null;
try {
fis = new FileInputStream(data);
content = new byte[fis.available()];
fis.read(content);
fis.close();
} catch (Exception e) {
throw e;
}
document.setData(content);
document.setFileName(dataFileName);
document.setContentType(dataContentType);
/*
u have to write the code to save in to the database
*/
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
The addDocument action in the fileupload.jsp invokes the add method in the DocumentAction class
this method reads the datafrom the uploaded file and store it to the byte array in the
document class.
this is the action mapping for the upload file after successful upload page is redirected to success.jsp
struts.xml
<action name="*Document" method="{1}"
class="in.codeglobe.fileupload.action.DocumentAction">
<result name="view">/success.jsp</result>
</action>
Document.java
package in.codeglobe.fileupload.entity;
public class Document {
private Long documentId;
private String fileName;
private String contentType;
private byte[] data;
public Document() {
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public Long getDocumentId() {
return documentId;
}
public void setDocumentId(Long documentId) {
this.documentId = documentId;
}
}
success,jsp
File with file name ${dataFileName} is successfully uploaded to database
File type: ${dataContentType}
This is the hibernate configuration
document.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="in.codeglobe.fileupload.entity.Document"
table="DOCUMENT">
<id name="documentId" column="documentId">
<generator class="native" />
</id>
<property name="data">
<column name="data" sql-type="MEDIUMBLOB"></column>
</property>
<property name="fileName" />
<property name="contentType" />
</class>
</hibernate-mapping>
cheapest web development hosting solutions cochin kerala
Running ASP.NET Applications in Debian and Ubuntu
Mono has a fully functional implementation of ASP.NET. This includes full support for ASP.NET Web Forms and Web Services. This essentially means that more or less any ASP.NET application that you have developed using with the .NET Framework will work with MonoASP.NET with Mono you have two options as regards which web server to host your ASP.NET applications that is XSP and Apache.
XSP
XSP is a “light-weight web server” capable of hosting and serving ASP.NET applications. It is written using C#, making extensive use of the classes in the System.Web namespace.XSP web server runs on both the Mono runtime and also on the .NET runtime.
Now we are going to take a look how to install XPS and mono for ASP.NET applications and testing this setupnstall mono in Debian
If you want to install mono in your debian system you need to run the following command
#apt-get install mono mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol
You can can see in this screen which will install all the required packages
Install mono in Ubuntu
If you want to install mono in your Debian system you need to run the following command
sudo apt-get install mono mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol
Install XSP Web server in Debian
If you want to install ASP.NET2.0 version use the following command
#apt-get install mono-xsp2 mono-xsp2-base asp.net2-examples
If you want to install ASP.NET1.0 version use the following command
#apt-get install mono-xsp mono-xsp-base asp.net-examples
This will install all the required development environment and sample applications
Install XSP Web server in Ubuntu
If you want to install ASP.NET2.0 version use the following command
sudo apt-get install mono-xsp2 mono-xsp2-base asp.net2-examples
If you want to install ASP.NET1.0 version use the following command
sudo apt-get install mono-xsp mono-xsp-base asp.net-examples
This will install all the required development environment and sample applications for ASP.NET
Test ASP.NET Applications
We have already installed sample applications
If you want to run ASP.NET 2.0 application you need to go to /usr/share/asp.net2-demos/ run the following command
#xsp2
This will start the XSP with ASP.Net 2.0 application
xsp2
Listening on port: 8080 (non-secure)
Listening on address: 0.0.0.0
Root directory: /usr/share/asp.net2-demos
Hit Return to stop the server.
Application_Start
Now you need to point your web browser to http://localhost:8080/
If you want to run ASP.NET 1.0 application you need to go to /usr/share/asp.net-demos/ run the following command
#xsp
This will start the XSP with ASP.Net 1.0 application
xsp
Listening on port: 8080 (non-secure)
Listening on address: 0.0.0.0
Root directory: /usr/share/asp.net-demos
Hit Return to stop the server.
Application_Start
Now you need to point your web browser to http://localhost:8080/
Possible errors
If you get the following error when you point http://localhost:8080/
Error Message: HTTP 404. File not found /usr/share/asp.net2-demos/index2.aspx
Solution
You need to copy the index.aspx to index2.aspx
For Debian Users
#cp /usr/share/asp.net2-demos/index.aspx /usr/share/asp.net2-demos/index2.aspx
For Ubuntu Users
sudo cp /usr/share/asp.net2-demos/index.aspx /usr/share/asp.net2-demos/index2.aspx
.net application developers cochin kerala
web IT solutions cochin Kerala
Get Running Process C#
ProcessThreadCollection threadlist = theProcess.Threads;
foreach(ProcessThread theThread in threadlist){
Console.WriteLine("Thread ID:{0} Priority: {1} Started: {2}", theThread.Id, theThread.PriorityLevel, theThread.StartTime);
}
Tuesday, August 25, 2009
PixelShots a Mobile Photography blog
An ultimate place for cellphone photography, Digital photography using various MP cell phone cameras
Pixelshots
kerala webdesigns cochin
Send Mail Using JAVA MAIL API
You can download Java Mail API from http://java.sun.com/products/javamail/downloads/
An Example program for sending mail using JAVA Mail
------------------------------------------------------------------
Before run the example code please goes through steps given below
1. download java mail API. and add to Classpath
2. Create one Gmail Account ( in this example we use google mail server as server)
3. edit the code "USERNAME = new gmail id" and PASSWORD = "password of new gmail id";
4. edit formAddress and to address.
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class SendMail {
public static final String MAIL_SERVER = "smtp.gmail.com";
public static final String USERNAME = "servermail@gmail.com";
public static final String PASSWORD = "password";
public static void main(String[] args) {
try {
fromAddress = "fromaddress@gmail.com";
String toAddress = "toaddress@gmail.com";
String subject = "This is a test Message";
String message = "Hello Hows u?";
Properties properties = System.getProperties();
properties.put("mail.smtps.host", MAIL_SERVER);
properties.put("mail.smtps.auth", "true");
Session session = Session.getInstance(properties);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(fromAddress));
msg.addRecipients(Message.RecipientType.TO, toAddress);
msg.setSubject(subject);
msg.setText(message);
Transport tr = session.getTransport("smtps");
tr.connect(MAIL_SERVER, USERNAME, PASSWORD);
tr.sendMessage(msg, msg.getAllRecipients());
tr.close();
} catch (AddressException ex) {
System.out.println(ex.getMessage());
} catch (MessagingException ex) {
System.out.println(ex.getMessage());
}
}
}
webdevelopers webhosting application development-IT solutions Cochin Kerala
Monday, August 24, 2009
Snake game for U in turbo c
# include <graphics.h>
# include <stdlib.h>
# include <dos.h>
# include <conio.h>
int gdriver=DETECT,gmode,x1=0,y1=0,x2,y2,k=0,c,a,i=0;
int bufx[150],bufy[150],dist=7,delayspeed=100,d;
int rndx,rndy,tail=2,size,dash=0;
int life=5;
int choice;
void randomnumber(void);
void move(int a);
void statusbar(void);
void main()
{
// registerfarbgidriver(EGAVGA_driver_far);
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
size=tail;
cleardevice();
printf("Devlopped By IDEAL BERG");
printf("Enter the speed:: \n<1> for slow <2> for slower <3> for slowest\n<4> for normal\n<5> for fast <6> for faster <7> for fastest");
scanf("%d",&choice);
switch(choice)
{
case 1: delayspeed=250;break;
case 2: delayspeed=200;break;
case 3: delayspeed=160;break;
case 4: delayspeed=90;break;
case 5: delayspeed=60;break;
case 6: delayspeed=40;break;
case 7: delayspeed=20;break;
};
cleardevice();
randomnumber();
bar3d(rndx,rndy,rndx+dist,rndy+dist,0,0);
statusbar();
while((c=getch())!='\033')
{
if (c=='\115') a=1;
if (c=='\113') a=2;
if (c=='\120') a=3;
if (c=='\110') a=4;
dash=0;
move(a);
}
}
void move(int a)
{
void checkcollision(int x1,int y1);
void checkcapture(int x1,int y1);
while(!kbhit())
{
if (!dash)
{
k=k++%size;
i++;
setfillstyle(1,7);
bar3d(x1,y1,x1+dist,y1+dist,0,0);
if(i>=size) // Style start
{
setfillstyle(0,0);
setcolor(0);
bar3d(bufx[k],bufy[k],bufx[k]+dist,bufy[k]+dist,0,0);
bufx[k]=x1;
bufy[k]=y1;
setcolor(15);
checkcapture(x1,y1);
}
else
{
bufx[1]=x1;
bufy[1]=y1;
}
if(a==1) x1=x1+dist;
if(a==2) x1=x1-dist;
if(a==3) y1=y1+dist;
if(a==4) y1=y1-dist;
checkcollision(x1,y1);
setfillstyle(1,14);
bar3d(x1,y1,x1+dist,y1+dist,0,0);
sound(300);
delay(delayspeed);
nosound();
delay(delayspeed);
}
}
}
void checkcollision(int x1,int y1)
{
int i;
for(i=1;i<=size;i++) if((bufx[i]==x1)&&(bufy[i]==y1)) dash=1; if((x1<0)||(x1>=400)||(y1<0)||(y1>400)) dash=1;
if(dash)
{
if(--life<0) exit(0); sound(700); delay(300); nosound(); if(size>25) life++;size=tail;
cleardevice();
}
statusbar();
}
void checkcapture(int x1,int y1)
{
int i;
if((x1==rndx)&&(y1==rndy))
{
size++;
sound(500);
delay(100);
randomnumber();
}
setfillstyle(11,14);
bar3d(rndx,rndy,rndx+dist,rndy+dist,0,0);
}
void statusbar()
{
char s[10];
s[1]=life;
setcolor(15);
rectangle(0,0,400,400);
gotoxy(55,2);
printf("Life: %d size: %d",life,size);
gotoxy(55,5);
printf("Down: ");
putchar(31);
printf("\tUP");
putchar(30);
gotoxy(55,6);
printf("RIGHT :");
putchar(16);
printf("\tLEFT :");
putchar(17);
}
void randomnumber()
{
int i,j;
randomize();
i=random(10000)%40;
i=i*dist;
j=random(10000)%40;
j=j*dist;
rndx=i;
rndy=j;
}
Kerala IT companies - webdevelopment webhosting application development Cochin
Monday, August 17, 2009
"Setup did not find any hard disk drives" during Windows XP Installation on Dell Laptops
Are you experience trouble installing Windows XP in your Dell Laptop?
Before you install XP, you must first configure a setting in BIOS else XP CD will not detect your hard disk
In BIOS:
Onboard Devices -> Flash Cache Module -> Set Off
Onboard Devices -> SATA Operation -> Set ATA
Ok, you can now proceed with installing Windows XP
Sunday, August 2, 2009
Rediif Local Ads
Rediff LocalAds is a service that provides you to register your add to rediff's advertising program subject to your compliance with Terms and Conditions. Now rediff offers these services totally free including the communication(Phone) between the customer and advertiser. Customers can search products that they want to buy and rediff lists all ads relating to that product. They can also call to the advitiser(1 minute) totally free.
Link to add your local ad
Google SMS Channel
This is another product from Google Labs. You can create your own channel(s) to receive regular alerts over SMS on specific topics that interest you. You can also invite others to subscribe to your channel(s). You can use your channel(s) as a discussion group as well, allowing other people to post messages.
The main advantage is that you can use this channel to alert your readers when a new post is published in your blog. You need not take any effort for this. Google automatically do this. Only thing is that at the time of creation you need to provide your blog's address. You can also use this to provide alert from your google groups, Google news or from a RSS feed as shown in the figure. Also you(channel owner) can post messages manually. You can click here to start your own SMS channel.
Link for SMS subscribtion to codeglobe
Saturday, August 1, 2009
think beyond wml.
What stands the name 'HAWHAW' for?
HTML And WML Hybrid Adapted Webserver.
for more details
http://www.hawhaw.de/faq.htm
Type in Malayalam in any text box on any web-site of your choice
Click here to get the transliteration bookmarkle
NB : You should install malayalam font to use this option.
For other languages, use the appropriate link: Arabic Bengali Gujarati Hindi Kannada Malayalam Marathi Nepali Tamil Telugu
Inserting images in Gmail
Make sure you're in rich formatting mode, or it won't show up. Click the little image icon, and you can insert images in two ways: by uploading image files from your computer or providing image URLs.
Keep in mind that Gmail doesn't show URL-based images in messages by default to protect you from spammers, so if you're sending mail to other Gmail users, they'll still have to click "Display images below" or "Always display images from ..." to see images you embed.
Wednesday, July 29, 2009
Zion Lurk 1.0 beta-Hide your secret/important files..
Everyone like to protect their secret/personal/important files in his mobile from others who using our mobile..
Here is the option to protect/hide your file from mobile browser to keep them away from other users.
The key features are
1.'Lock' option is to lock the file(s),use the browse option to browse the files to be locked and use 'Mark' option in the Zion Browser to select files to be locked and then click 'Lock' to lock the file..
2.'Unlock' option is to unlock file(s),the browse option let you see the locked files..there you can unlock the file..
3.'Settings' option is to change your login password.
Default password is:'zionlurk'
Note:Once you installed the application in your mobile,before going to delete the application ensure that you have unlocked all the locked files otherwise those file may become inaccessible even if you reinstall the application.
After installing the application move it in to external memory,because all inatallation will go to internal memory.To hide more files you have to move the application to external memory..
Download Zion Lurk 1.0 Beta
cheap kerala webhosting plans
cellphone application developers
Tuesday, July 28, 2009
windowsXP command manual
start--> run
in run window type
hh ntcmds.chm
this will open a command manual of chm format.
linux minicom
this is some what similar to the hyperterminal in windows
which also used for modem communications
configure minicom
minicom -s
set device(eg, ttyS0,) set baudrate say (9600 or parity hardware flow control etc).and etc...
save the configuration file
and in the root prompt
enter command
minicom
will connect device which you configured in the minicom.
(router interface with linux mechine is also done using minicom)
Rebuild the Windows boot.ini.
Reboot the computer form CD
Setup menu press R to open the recovery console
Enter the Admin password
Type bootcfg /rebuild to start the rebuild process.
The rebuild process will step you through a number of steps depending upon how many operating systems
or u can type /fastdetect to automatically detect the available options.
type exit to reboot the computer.
Monday, July 27, 2009
hacking root shell in linux
we need to edit the grub(editing grub is described in previous posts) bootup screen using press 'e' place the end of the line as following
init=/bin/sh
enter and press 'b' for boot
after boot you will get a shining root shell "#"!!
in this above procedure we could bypass the init proces to a shell from what it does in normal.
in this point we didn't mount any file system. (manually mount if it required.normally dont need)
for checking the read right permission for the file system use touch utility
touch something
if it is given an error message then you dont have write permission to the file system.
to gain the filesystem read write permission u need to remount it as follows
mount -o remount,rw /
after that you can do anything as root!!!eg. change the root password. placing commands in inittab etc...remember dont press ctrl+D it will kill the shell causing kernel panic.
ls commands in linux
the common nature of the ls commads are listing operation here there are...
ls- list contents (commonly used).
lsof- list the opened files which is used by the running process.
lsusb-list the usb devices connected to the system.
lsmod-list the modules which is loaded in the running kernel.
lspci-list the pci(Peripheral Component Interconnect) devices (use lspci -vvx to get meaning full data othere wise expert can understand it).
lsattr-to list attributes of a file(attributes like immutable field)
lshal-list hal(Hardware Abstraction Layer, HAL which is a piece of software that provides a view of the various hardware attached to a system)devices
cheers.......
Sunday, July 26, 2009
Zion SMS Mania 1.1 beta-Send SMS freely from your mobile...
You can send SMS without any cost you just need the following things..
1.Need way2sms login(for this just login to way2sms(www.way2sms.com) and create an account its totally free).
2.GPRS must be activated in your phone.
3.Cell must be java enabled.
Then you can start sending SMS very easily no need to go to way2sms and waste your time,you can send in just one click..
In this application,in the first two fields you have to enter your way2sms username and password.
Then in the third field you can enter your message(you can also browse for the message in your phone).
Fourth field enter the recipients phone numbers,each number must be seperated by semicolon(eg:9496340837;9995736630).(You can also browse for the txt file that contains the phone numbers,file contains numbers seperated by semicolon,if you save the recipients nos in a txt file you don't need to enter them all the time,you just need to locate the file..)
There is an option to remember your login information so that you don't need to enter them each time you login to this application..
webhosting webdevelopment cochin kerala
cellphone apllication development Cochin Kerala
Change the Linux root password from single user mode
1. Boot up your Fedora 10 system, on the boot up splash screen press and hold shift key until you enter the GRUB screen
Press and hold "shift" key here and wait until GRUB boot menu screen appear
2. if you have multiple operating system installed, you may have to select the Fedora 10 by using the 'up' and 'down' key... then hit the 'e' key to enter GRUB editing mode
3. Use the 'up' and 'down' key again, select the 'kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=27f6ac23-638f-439a-8a97-2baaf6a32922 rhgb quiet', and the hit the 'e' key again to edit the grub command line.
4. The below screen appear after you hit the 'e' key, now notice that you mouse cursor at the end of line 'kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=27f6ac23-638f-439a-8a97-2baaf6a32922 rhgb quiet'.
5. Change at the end of the line that say 'rhgb quiet' to 'linux single'
From : kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=27f6ac23-638f-439a-8a97-2baaf6a32922 rhgb quiet
To : kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=27f6ac23-638f-439a-8a97-2baaf6a32922 linux single
hit 'Enter' key after finish enter the 'linux single' at the end of kernel line, as show on GRUB.
6. Hit the 'b' key to boot the selected kernel and start the boot process to Linux single user mode.
7. After you hit the 'b' key, the Fedora 10 should reboot and then enter the single user mode and should give you root shell terminal without prompt any password field or ask for password.
Issue passwd command to change root user password on Fedora 10 after we finish the procedure to enter the Linux single mode as show on step by step example above.
[root@fedora /]# passwd <-- Start type in 'passwd' command and hit Enter key
Changing password for user root.
New UNIX password:
passwd: all authentication tokens updated successfully.
Then reboot the system and start using the new root password for your Fedora 10 system
[root@fedora /]# reboot <-- Type in 'reboot' command and hit Enter key to start reboot Fedora system
website development hosting cochin - Kerala IT solution providers, Kochi
Saturday, July 25, 2009
Thursday, July 23, 2009
Booting another bootloader(grub,lilo,ntldr....) from grub
eg.
Suppose main grub installed on /dev/sda1 and the second os is installed on /dev/sda2
in /boot/grub/grub.conf or /boot/grub/menu.lst (which is grub configuration file)
add as following
title Linux 2 on /dev/sda2
root (hd0,1)
# or use rootnoverify (hd0,1)
#rootnoverify is same as root but don't attempt to mount the partition.
chainloader +1
.
FIX Master Boot Record
A:\> FDISK.EXE /MBR
FDISK is a standard utility included in MS-DOS, Windows 95, 98, ME.
If you have Windows NT / 2000 / XP, you can boot from startup floppy disks or CD-ROM, choose repair option during setup, and run Recovery Console. When you are logged on, you can run FIXMBR command to fix MBR.
1. First, restart your computer with the Windows XP setup disk in the CD drive. If you don’t have your original disk, borrow one or download a ISO image from a torrent site.
2. When prompted, boot from the CD drive by pressing any key. If Windows loads automatically, you will first have to enter the BIOS setup and change the order of the boot devices to start with the CD drive.
change boot order
3. Once the setup loads, you will see the option to press R to repair a Windows installation.
repair windows
4. Once the Recovery Console loads up, you will have to type in a number that corresponds to your Windows installation. This is normally just 1. Press Enter and then type in the Administrator password.
recovery console
5. Now at the prompt, type in fixmbr. Your damaged MBR will now be replaced with a new master boot record and your computer should now be able to boot properly. Note that you may also want to run the fixboot command to repair the boot sector with a new one.
Wednesday, July 22, 2009
Bluetooth command line operations in linux
hciconfig
- Gives info about the bluetooth hci on your pc
- Ensure the device is up and running and has required scan modes
- hcitool dev should also give some of this info
hcitool inq and hcitool scan
- Gives info about or rather identifies nearby bluetooth devices
hcitool info
- BTAddr refferes bluetooth address.
- Get info about remote bluetooth device
l2ping
- One way to see if we can communicate with a remote bluetooth device
sdptool browse
- Gives info about the services provided by a remote bluetooth device
obexftp –nopath –noconn –uuid none –bluetooth
- Allows one to send file without specifying the pin on the remote device side
- The OPush channel number for device is got from sdptool above
passkey-agent –default
- Pin specified here is what the remote BT device should provide
or its user enter on that device when requested.
obexftp -b
- Allows one to put a file onto the specified BT device
- obexftp could also be used to get or list the files on the BT device
- also allows one to identify a nearby BT device by just giving -b option
obexpushd
- Allows one to recieve files sent from a bluetooth device.
- Depending on who started it, the recieved files will be stored in the corresponding home directory
Note: The old style pin_handler doesn’t work with latest bluez(is a protocol stack for linux), you require adbus based passkey handler and there is one provided by default by bluez-utils
called passkey-agent
Blogger SEO Tips...Submit sitemaps in Google Webmaster tools
More over the tool can display if there are any crawl errors, any url in your site having crawler access problem, frequency of crawling, number of pages indexed and many more..You can also set the frequency at which you may need your site to be crawled by Google..
Adding your blog and its sitemap..........
1) Just goto the webmaster tools from your google account and add your site.
2)go to dashboard by clicking the added site name->SiteConfiguration->SiteMaps->submit sitemap->general web sitemap->
If your blog has less than a 100 posting add sitemap as
atom.xml?redirect=false&start-index=1&max-results=100
And if your blog having more than 100 postings you have to add one more site map in addition to the above as..
atom.xml?redirect=false&start-index=101&max-results=100
and if more than 200 you have to change the 'start-index=101 in the above link to start-index=201 and add one more sitemap, ie the 3rd site map is
atom.xml?redirect=false&start-index=201&max-results=100 and so on..
If your sitemap is submitted successfully you will see the number corresponding to your total blog postings as submitted urls.. And note that, the indexed url's depends on the quality of blog postings and is upto Google's strategy of finding quality contents...
Goodluck from pixelshots the photo blog...
courtesey: kerala business website designs hosting plans
Tuesday, July 21, 2009
Change file attribute in Linux
Make a file readonly, ie nobody, even root, can make changes to a file:
This can be done by using the "chattr" command and "i" attribute.
[root@odcclient6 Desktop]# chattr +i test.txt
you can view the attribute of the file using this command lsattr.
To remove the attribute use this command "chattr -i"
Cheers...............
Find encoding of given file linux
by simply using this command
file filename
eg:
vimal@TECH-10:~$ file vimal
vimal: ASCII text
Mysql Search and Replace
update 'tablename' set field = replace(field,'search_item','replace_item');
Monday, July 20, 2009
linux shell script for find and replace strings in a directory
#check for required parameters
if [ ${#1} -gt 0 ] && [ ${#2} -gt 0 ];
then
for f in `find -type f`;
do
if grep -q $1 $f;
then
cp $f $f.bak
echo "The string $1 will be replaced with $2 in $f"
sed s/$1/$2/g < $f.bak > $f
rm $f.bak
fi
done
else
#print usage informamtion
echo usage incorrect.try findscript string1 string2
echo special characters forwarded with slash
Thursday, July 16, 2009
To load modules on startup LINUX
we will make(build or compile) our modules using the help of make utility on linux.
this utility or cammand uses Makefile as its input for compiling or building modules.
after build the modules we will get our executable module as
(make modules install for compiling kernel also install all modules in /lib/modules/uname -r/kernel directory)
modulename.ko
if we want to load module ,
insmod modulename.ko
there are somany issues for this modules are depended on another module.
if say our module modulename.ko is depended on module1.ko and module2.ko
in this case we want to load
insmod module1.ko
insmod module2.ko
insmod modulename.ko
to simplify this task we have a modprob utility
we could set dependency in a file /lib/modules/($SHELL uname -r)/modules.dep
modprobe actually uses insmod to insert module in a running kernel.
the entry in modules.dep is like as follows
/lib/modules/2.6.26-1-686/kernel/mymodule.ko: /lib/modules/2.6.26-1-686/kernel/module1.ko /lib/modules/2.6.26-1-686/kernel/module1.ko
(eg: modulename : (colon) first dependency (space)second dependacy (space) etc....)
syntax is important!!!
use command
modprobe mymodule.ko
it will automatically add module1.ko and module2.ko automatically
lets come to the context if we want to load it on startup we will have to configure modprobe. For that we could use /etc/modprobe.conf or /etc/modules.conf or /etc/modules according to different distributions of linux
/etc/modules.conf uses 2.4 and earlier version now we are popular 2.6 kernel so it is modeprobe.conf(/etc/modprobe.d/)
add a single line to that file will load the module on the startup
just add
at the end of line
mymodule
it is very easy to play with modprobe.conf there is a command line interface also there.
man modprobe ,for more information!
we could set aliases for our modules in this file
hope u get some idea about how load module into running kernel at runtime....
regards
Nat Rule for IPTABLES
This is simple script for nat rule in ip tables. Just make changes in the script and run it. After running the script do the following.
service iptables save
service iptables restart
cheers....... :-)
Download -
Note: Make a copy of your current rule [/etc/sysconfig/iptables] before executing this.
Wednesday, July 15, 2009
The Blogger Data API
The Blogger Data API allows client applications to view and update Blogger content in the form of Google Data API feeds. Your client application can use the Data API to create new blog posts, edit or delete existing posts, and query for posts that match particular criteria.
follow the link
http://code.google.com/apis/blogger/
by, kerala webhosting
way2sms API
You have to create an account in way2sms
Implementaion details are alredy published in codeglobe
Try it at your own risk
Download
source
Find current stack view. Dont be a hacker
#include
int main()
{
printf("%8x.%8x.%8x.%8x");
//how much time you reapeat you will get one step below from the current stack pointer and it ends //on the null
}
explanation:
this is known as format string vulnerability
usually printf() function in c require minimum 2 or more arguments ie.format string as well as the value of the variable to be formated.
here used %x is hexadecimal format 08 for 8 places
if we closely look at the implementation of printf, the last argument is put on the stack is address of printf function here no more arguments so it is being a function call it can trace the entire stack.
Yahoo Astrology API Java
Download
Tuesday, July 14, 2009
EXTRACT ALL LINK FROM A GIVEN HTML PAGE
it will search and retrieve all links from that page and return it
it uses xpath to retrieve the link
try it.....
function get_link($html)
{
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo $url.""
return $url;
}
?>
parsing data from excel xml sheet using DOM
1.url
2.result
parsed the above are saved into corresponding variables,$url,$result
enter data into a excel sheet then save it as excel xml with extension .xml
upload in to the script
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
foreach ($rows as $row)
{
if ( !$first_row )
{
$url = "";
$result = "";
$index = 1;
$cells = $row->getElementsByTagName( 'Cell' );
// echo $cells;
foreach( $cells as $cell )
{
$ind = $cell->getAttribute( 'Index' );
if ( $ind != null ) $index = $ind;
//echo $index;
if ( $index == 1 ) $url = $cell->nodeValue;
if ( $index == 2 ) $result = $cell->nodeValue;
//echo "$cell->nodeValue";
$index += 1;
}
PHP code to check whether a yahoo user is online or not
Do you want to check whether a yahoo user is avoiding you by setting his status to invisible mode. Please try this code..
< ? php //-------> No spaces in between
$id="sujith.sasi";
$url = 'http://opi.yahoo.com/online?u=';
$data = file_get_contents($url . $id);
if (trim(strtolower(strip_tags($data))) != 'user not specified.') {
echo (strlen($data) == 140) ? 'online' : 'offline'; }
else {
echo trim(strip_tags($data));
} ?>
cheers........ :-) [Remember to remove the spaces b/w the php "< ? php " tag]
login and get contacts from yahoo mail with php curl
set_time_limit(0);
if($_POST['login'])
{
$php_userid = $_POST['login'];
$php_password = $_POST['passwd'];
$cookie_file_path = "./cookie.txt"; // Please set your Cookie File path
$fp = fopen($cookie_file_path,'wb');
fclose($fp);
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$reffer = "http://mail.yahoo.com/";
// log out.
$LOGINURL = "http://us.ard.yahoo.com/SIG=12hoqklmn/M=289534.5473431.6553392.5333790/D=mail/S=150500014:HEADR/Y=YAHOO/EXP=1135053978/A=2378664/R=4/SIG=133erplvs/*http://login.yahoo.com/config/login?logout=1&.done=http://mail.yahoo.com/&.src=ym&.lg=us&.intl=us";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);
//1. Get first login page to parse hash_u,hash_challenge
$LOGINURL = "http://mail.yahoo.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$loginpage_html = curl_exec ($ch);
curl_close ($ch);
preg_match_all("/name=\".u\" value=\"(.*?)\"/", $loginpage_html, $arr_hash_u);
preg_match_all("/name=\".challenge\" value=\"(.*?)\"/", $loginpage_html, $arr_hash_challenge);
$hash_u = $arr_hash_u[1][0];
$hash_challenge = $arr_hash_challenge[1][0];
// 2- Post Login Data to Page https://login.yahoo.com/config/login?
$LOGINURL = "https://login.yahoo.com/config/login?";
$POSTFIELDS = '.tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=&.partner=&.u='.$hash_u.'&.v=0&.challenge='.$hash_challenge.'&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&login='.$php_userid.'&passwd='.$php_password;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);
preg_match_all("/replace\(\"(.*?)\"/", $result, $arr_url);
$WelcomeURL = $arr_url[1][0];
// 3- Redirect to Welcome page. (Login Success)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$WelcomeURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);
// echo $result;
// 4- Get Address Book.
$addressURL = 'http://address.mail.yahoo.com/?A=B';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$addressURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);
//print $result;
preg_match_all("/\"\/yab\/us\/Yahoo\.csv\?(.*?)\"/", $result, $arr_address_url);
$randURL = html_entity_decode($arr_address_url[1][0]);
preg_match_all("/id=\"crumb2\" value=\"(.*?)\"/", $result, $arr_crumb);
$hash_crumb = $arr_crumb[1][0];
// 5- show Address Book.
$addressURL = 'http://address.mail.yahoo.com/index.php';
$POSTFIELDS ='.crumb='.$hash_crumb.'&VPC=import_export&submit%5Baction_export_yahoo%5D=Export+Now';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$addressURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);
//print $result;
} // extra code 2 if
else
{
login_form();
}
////////////////////////////////////////////////////////////////////////////////////////////////
Here login form is the function to generate a html form with username and password
login and passwd are the name of the used text field respectively