<?php
/*
+——————————————————————-++——————————————————————-+
*/
session_start();
// Enable error reporting
// ini_set(“display_errors”,”1″);
// ini_set(“error_reporting”, E_ALL);// Pull in the NuSOAP code
require_once(‘nusoap/lib/nusoap.php’);// Create the client instance
//$client = new nusoap_client(‘http://dev1.uvjtech.net/gev/API/Authentication.php?wsdl’, true);
$client = new nusoap_client(‘http://my2020i.com/gev/API/Authentication.php?wsdl’, true);// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo ‘<h2>Constructor error</h2><pre>’ . $err . ‘</pre>’;
// At this point, you know the call that follows will fail
}$error_text = “”;
if(isset($_POST['submit']) && $_POST['submit'] == “Sign In”){$username = $_POST['username'];
$password = $_POST['password'];if($username && $password){
if($_POST['is_doctor'] == 1)
$is_doctor = TRUE;
else
$is_doctor = FALSE;if($username && $password){
// Call the SOAP method
$result = $client->call(‘Authenticate’, array(‘user_username’ => $username, ‘user_password’ => $password, ‘is_doctor’ => $is_doctor));
if($result['user_id']){
$_SESSION['user_id'] = $result['user_id'];
$_SESSION['user_grp_id'] = $result['user_grp_id'];
}}
}else{
$error_text = “Please enter Username or Password”;
}}
//echo ‘<h2>Response</h2><pre>’ . htmlspecialchars($client->response, ENT_QUOTES) . ‘</pre>’;
?>
<html>
<head>
<title>Authentication</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head><body>
<table width=”100%” cellpadding=”1″ cellspacing=”1″ align=”center” border=”0″>
<tr>
<td width=”20%” align=”center” valign=”top”></td>
<td width=”80%” valign=”top”>
<form name=”frm_login” action=”" method=”post”>
<table>
<tr><td colspan=”2″><b>Sign in</b></td></tr>
<tr><td colspan=”2″></td></tr><?php if($_POST['submit'] && $result['user_id']){
?>
<tr><td colspan=”2″ height=”20″></td></tr>
<tr><td colspan=”2″><?php echo “Welcome, “. $result['user_fname'].’ ‘.$result['user_lname']; ?></td></tr>
<tr><td colspan=”2″><?php echo “Your email ID: “.$result['user_email']; ?></td></tr>
<?php if(!$is_doctor){
?>
<tr><td colspan=”2″ height=”20″><a href=”find_doctors.php”>Search Doctor</a></td></tr>
<?php }
?>
<tr><td colspan=”2″ height=”20″><a href=”update_profile.php”>Update Profile</a></td></tr>
<tr><td colspan=”2″ height=”20″><a href=”change_password.php”>Change Password</a></td></tr><tr><td colspan=”2″ height=”20″></td></tr>
<?php }else if($result['user_id'] == ’0′){ ?>
<tr><td colspan=”2″>Sorry…Invalid login. Please try again.</td></tr>
<tr><td colspan=”2″ height=”20″></td></tr><?php }else if($error_text){ ?>
<tr><td colspan=”2″><?php echo $error_text; ?></td></tr>
<tr><td colspan=”2″ height=”20″> </td></tr>
<?php } ?>
<tr >
<td >Username</td>
<td ><input type=”text” name=”username” value=”<?php echo $username; ?>” /></td></tr>
<tr >
<td>Password</td>
<td ><input type=”password” name=”password” /></td>
</tr><tr >
<td>Check if Doctor</td>
<td ><input type=”checkbox” name=”is_doctor” value=”1″ <?php if($is_doctor) echo ‘checked’;?> /></td>
</tr><tr>
<td ></td>
<td align=”left”>
<input type=”submit” name=”submit” value=”Sign In” />
</td>
</tr>
<tr>
<td colspan=”2″> </td>
</tr>
<tr>
<td colspan=”2″><a href=”user_registration.php”>Sign Up</a></td>
</tr></table>
</form>
</td>
</tr></table>
</body>
</html>
Example code for SOAP , using nusoap library January 23, 2012
Example code for SOAP , using nusoap library January 23, 2012
<?php
/**This is for getting a list of doctors, by giving address
**/
session_start();// Enable error reporting
// ini_set(“display_errors”,”1″);
// ini_set(“error_reporting”, E_ALL);// Pull in the NuSOAP code
require_once(‘nusoap/lib/nusoap.php’);// Create the client instance
// $client = new nusoap_client(‘http://dev1.uvjtech.net/gev/API/Doctors.php?wsdl’, true);
$client = new nusoap_client(‘http://my2020i.com/gev/API/Doctors.php?wsdl’, true);// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo ‘<h2>Constructor error</h2><pre>’ . $err . ‘</pre>’;
// At this point, you know the call that follows will fail
}// Search Doctor…
$error_text = “”;
if(isset($_POST['search']) && $_POST['search'] == “Search”){$address = strip_tags($_POST['address']);
if($address){
// Call the SOAP method
$doctor_list = $client->call(‘GetDoctorsList’, array(‘address’ => $address)); // echo ‘<pre>’; print_r($doctor_list); exit;
}else{
$error_text = “Invalid Address”;
}
}//echo ‘<h2>Response</h2><pre>’ . htmlspecialchars($client->response, ENT_QUOTES) . ‘</pre>’;
?>
<html>
<head>
<title>Doctor Search</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<script language=”JavaScript” src=”includes/js/ajax.js”></script>
</head><body>
<table width=”100%” cellpadding=”1″ cellspacing=”1″ align=”center” border=”0″>
<tr>
<td colspan=”2″ align=”center” height=”100″> <b>Search Doctor</b></td>
</tr><tr>
<td colspan=”2″ width=”80%” valign=”top” align=”center”>
<form name=”frm_search” action=”" method=”post”>
<table>
<tr>
<td colspan=”2″><?php echo $error_text; ?></td>
</tr>
<tr >
<td >Address</td>
<td >
<input type=”text” name=”address” size=”30″ value=”<?php echo $_POST['address']; ?>” />
<input type=”submit” value=”Search” name=”search” />
</td>
</tr>
<tr>
<td colspan=”2″></td>
</tr>
</table>
</form>
</td>
</tr><?php if($_POST['search']){
?>
<tr>
<td width=”80%” align=”center”><table width=”50%” border=”0″ bgcolor=”#333333″ cellspacing=”0″ cellpadding=”0″>
<tr><td><table width=”100%” border=”0″ cellspacing=”1″ cellpadding=”1″>
<?php
if($doctor_list){
?><tr><td colspan=”2″ align=”center” bgcolor=”#DDDDDD”><b>Doctors</b></td></tr>
<?php
$i = 1;
foreach($doctor_list as $doctor){
?>
<tr><td width=”5%” align=”center” bgcolor=”#DDDDDD”><?php echo $i; ?></td>
<td bgcolor=”#DDDDDD”><a href=”javascript:void(0);” onClick=”window.open(‘doctor_details.php?id=<?php echo $doctor[user_id]; ?>’,'Doctor Details’,'width=500,height=500′);”><?php echo $doctor['user_fname'].’ ‘.$doctor['user_lname'] ;?></a></td>
</tr>
<?php
$i++;
}}else{
?>
<tr><td colspan=”2″ align=”center” bgcolor=”#DDDDDD”><b>No Records found</b></td></tr><?php
}
?>
</table></td>
</tr>
</table>
</td><?php }?>
</tr>
<tr>
<td><table width=”30%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr><td align=”center” bgcolor=”#DDDDDD” height=”25″><b>Chat logs</b></td></tr>
<tr><td align=”left” ><div id=”chat_log” style=”width:400;height:300;overflow-y:scroll”></div></td></tr>
</table>
</td>
</tr>
</table><script type=”text/javascript”>
//setInterval(“ViewMessage()”,3000);function clock()
{
var d=new Date();
var t=d.toLocaleTimeString();
//document.getElementById(“chat_log”).innerHTML=t;
//document.getElementById(“chat_log”).innerHTML = document.getElementById(“chat_log”).innerHTML+’hai<br />’;
}
</script></body>
</html>
Code for downloading a txt file December 2, 2011
header(‘Content-Description: File Transfer’);
header(‘Content-Type: text/html’);
header(‘Content-Disposition: attachment; filename=Emails.txt’);
header(‘Expires: 0′);
header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0′);
header(‘Pragma: public’);
ob_clean();
flush();
$str =”first\t\n
echo $str;
RSS Feed December 2, 2011
Creation of rss feed in our site
1) we need to create a xml file ,
2) It has a general format (http://en.wikipedia.org/wiki/RSS
3) It can create manually , or automatically using any software like feedforall http://www.feedforall.com/
Display of Rss feed in any site
1) we need to use any parser for parsing the feed xml
2) Example php parser for Rss feed is simplepie (http://simplepie.org/)
3) After parsing the feed , just display in html as per our requirement
4) Example code (ie simplepie) for rss parsing
<?php
require_once(‘simplepie.inc’);
$feed = new SimplePie();
$feed->set_feed_url(‘http://www.empoweringparents.com/RSS/rss-debbie-pincus.php’);
$feed->init();
$feed->handle_content_type();
?>
<?php foreach ($feed->get_items(0, 5) as $item): ?>
<div>
<h2><a href=”<?php echo $item->get_permalink(); ?>”><?php echo $item->get_title(); ?></a></h2>
<?php echo $item->get_description(); ?>
<p><small>Posted on <?php echo $item->get_date(‘j F Y | g:i a’); ?></small></p>
</div>
<?php endforeach; ?>
5) In set_feed_url, we need to give the path of the Rss xml
6) http://stackoverflow.com/questions/2037351/output-rss-feed-as-html
How to display Rss feed in browsers
While we taking any site, then if there is a orange icon is displaying
(in IE below the address bar of the browser, In Mozilla it is under the bookmark option)
Then it means that site provides rss feed.
Then by clicking that orange button, we can subscribe it and we can show it on our browser
For getting this option in our site, we need to add the following code , under the header tag
<link rel=”alternate” type=”application/atom+xml” title=”Feed for question ‘Output RSS feed as html?’” href=”linto.xml”>
Where href is the location of the xml file, that will generate the rss feed
Remove and display the value from textbox,by javaascript November 9, 2011
<input id=”zipcode1″ name=”zipcode” type=”text” value=”Enter Zip Code” onBlur=”if(this.value==”)this.value=this.defaultValue;” onFocus=”if(this.value==this.defaultValue)this.value=”;” maxlength=”5″>
Javascript code for formatting the phone number like (xxx)xxx-xxxx or (xxx) xxx-xxxx November 9, 2011
Link : http://javascript.internet.com/forms/format-phone-number.html
Script FOR (xxx)xxx-xxxx
=======
<HEAD><SCRIPT LANGUAGE=”JavaScript”>
<!– This script and many more are available free online at –>
<!– The JavaScript Source!! http://javascript.internet.com –>
<!– Original: Roman Feldblum (web.developer@programmer.net) –><!– Begin
var n;
var p;
var p1;
function format_phone(){
p=p1.value
if(p.length==3){
pp=p;
d4=p.indexOf(‘(‘)
d5=p.indexOf(‘)’)
if(d4==-1){
pp=”(“+pp;
}
if(d5==-1){
pp=pp+”)”;
}
document.form4.phone_number.value=”";
document.form4.phone_number.value=pp;
}
if(p.length>3){
d1=p.indexOf(‘(‘)
d2=p.indexOf(‘)’)
if (d2==-1){
l30=p.length;
p30=p.substring(0,4);
p30=p30+”)”
p31=p.substring(4,l30);
pp=p30+p31;
document.form4.phone_number.value=”";
document.form4.phone_number.value=pp;
}
}
if(p.length>5){
p11=p.substring(d1+1,d2);
if(p11.length>3){
p12=p11;
l12=p12.length;
l15=p.length
p13=p11.substring(0,3);
p14=p11.substring(3,l12);
p15=p.substring(d2+1,l15);
document.form4.phone_number.value=”";
pp=”(“+p13+”)”+p14+p15;
document.form4.phone_number.value=pp;
}
l16=p.length;
p16=p.substring(d2+1,l16);
l17=p16.length;
if(l17>3&&p16.indexOf(‘-’)==-1){
p17=p.substring(d2+1,d2+4);
p18=p.substring(d2+4,l16);
p19=p.substring(0,d2+1);
pp=p19+p17+”-”+p18;
document.form4.phone_number.value=”";
document.form4.phone_number.value=pp;
}
}setTimeout(format_phone,100)
}
function getIt(m){
n=m.name;
p1=m
format_phone()
}// End –>
</script></HEAD>
<!– STEP TWO: Copy this code into the BODY of your HTML document –>
<BODY>
<div align=”center”>
<form name=”form4″>
<font size=”4″ color=”#0000FF”><b>Enter Telephone Number</b></font><br>
(To refresh, hold down shift and press the browser refresh button)<br>
<input type=text name=”phone_number” id=”phone_number” maxlength=”13″ onclick=”javascript:getIt(this)” >
</form>
</div><p><center>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”http://javascriptsource.com”>The JavaScript Source</a></font>
</center><p><!– Script Size: 2.70 KB –>
http://www.kodyaz.com/articles/javascript-phone-format-phone-number-format.aspx
FOR (xxx) xxx-xxxx
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<script language=”javascript”><!– This script is based on the javascript code of Roman Feldblum (web.developer@programmer.net) –>
<!– Original script : http://javascript.internet.com/forms/format-phone-number.html –>
<!– Original script is revised by Eralper Yilmaz (http://www.eralper.com) –>
<!– Revised script : http://www.kodyaz.com –>
<!– Format : “(123) 456-7890″ –>var zChar = new Array(‘ ‘, ‘(‘, ‘)’, ‘-’, ‘.’);
var maxphonelength = 14;
var phonevalue1;
var phonevalue2;
var cursorposition;function ParseForNumber1(object){
phonevalue1 = ParseChar(object.value, zChar);
}function ParseForNumber2(object){
phonevalue2 = ParseChar(object.value, zChar);
}function backspacerUP(object,e) {
if(e){
e = e
} else {
e = window.event
}
if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}ParseForNumber1(object)
if(keycode >= 48){
ValidatePhone(object)
}
}function backspacerDOWN(object,e) {
if(e){
e = e
} else {
e = window.event
}
if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}
ParseForNumber2(object)
}function GetCursorPosition(){
var t1 = phonevalue1;
var t2 = phonevalue2;
var bool = false
for (i=0; i<t1.length; i++)
{
if (t1.substring(i,1) != t2.substring(i,1)) {
if(!bool) {
cursorposition=i
window.status=cursorposition
bool=true
}
}
}
}function ValidatePhone(object){
var p = phonevalue1
p = p.replace(/[^\d]*/gi,”")
if (p.length < 3) {
object.value=p
} else if(p.length==3){
pp=p;
d4=p.indexOf(‘(‘)
d5=p.indexOf(‘)’)
if(d4==-1){
pp=”(“+pp;
}
if(d5==-1){
pp=pp+”)”;
}
object.value = pp;
} else if(p.length>3 && p.length < 7){
p =”(” + p;
l30=p.length;
p30=p.substring(0,4);
p30=p30+”) “p31=p.substring(4,l30);
pp=p30+p31;object.value = pp;
} else if(p.length >= 7){
p =”(” + p;
l30=p.length;
p30=p.substring(0,4);
p30=p30+”) “p31=p.substring(4,l30);
pp=p30+p31;l40 = pp.length;
p40 = pp.substring(0,9);
p40 = p40 + “-”p41 = pp.substring(9,l40);
ppp = p40 + p41;object.value = ppp.substring(0, maxphonelength);
}GetCursorPosition()
if(cursorposition >= 0){
if (cursorposition == 0) {
cursorposition = 2
} else if (cursorposition <= 2) {
cursorposition = cursorposition + 1
} else if (cursorposition <= 4) {
cursorposition = cursorposition + 3
} else if (cursorposition == 5) {
cursorposition = cursorposition + 3
} else if (cursorposition == 6) {
cursorposition = cursorposition + 3
} else if (cursorposition == 7) {
cursorposition = cursorposition + 4
} else if (cursorposition == 8) {
cursorposition = cursorposition + 4
e1=object.value.indexOf(‘)’)
e2=object.value.indexOf(‘-’)
if (e1>-1 && e2>-1){
if (e2-e1 == 4) {
cursorposition = cursorposition – 1
}
}
} else if (cursorposition == 9) {
cursorposition = cursorposition + 4
} else if (cursorposition < 11) {
cursorposition = cursorposition + 3
} else if (cursorposition == 11) {
cursorposition = cursorposition + 1
} else if (cursorposition == 12) {
cursorposition = cursorposition + 1
} else if (cursorposition >= 13) {
cursorposition = cursorposition
}var txtRange = object.createTextRange();
txtRange.moveStart( “character”, cursorposition);
txtRange.moveEnd( “character”, cursorposition – object.value.length);
txtRange.select();
}}
function ParseChar(sStr, sChar)
{if (sChar.length == null)
{
zChar = new Array(sChar);
}
else zChar = sChar;for (i=0; i<zChar.length; i++)
{
sNewStr = “”;var iStart = 0;
var iEnd = sStr.indexOf(sChar[i]);while (iEnd != -1)
{
sNewStr += sStr.substring(iStart, iEnd);
iStart = iEnd + 1;
iEnd = sStr.indexOf(sChar[i], iStart);
}
sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length);sStr = sNewStr;
}return sNewStr;
}
</script>
</head><body>
<input type=”text” onkeyup=”javascript:backspacerUP(this,event);” onkeydown=”javascript:backspacerDOWN(this,event);” maxlength=”14″>
</body>
</html>
How to download a file from server, using PHP code,FTP September 5, 2011
$conn_id = ftp_connect(“87.425.0″) or die(“Could not connect”);
$ftp_user_name=’dfg’;
$ftp_user_pass=’fgf!’;
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (($conn_id) || ($login_result))
{
$remote_file =”./public_html/uploads/”.trim($applicantName).”.txt”;
$local_file =”uploads/”.trim($applicantName).”.txt”;
$handle = fopen($local_file, ‘w’);if (ftp_fget($conn_id, $handle, $remote_file, FTP_ASCII, 0)) {
// echo “successfully written to $local_file\n”;
} else {
echo “There was a problem while downloading $remote_file to $local_file\n”;
}
}
else{
die(“FTP Connection Failed”);
}ftp_close($conn_id);
API for finding the longitude and latitude of a given address (America) June 20, 2011
Reference : http://code.google.com/apis/maps/documentation/geocoding/
Example request
———————————
http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA& sensor=true_or_falseParameters
url = http://maps.googleapis.com/maps/api/geocode/xml?
address = streetaddress, county or state, state ( two letter format)
sensor= false (means ,if it is a device, from which this request is comming)NOTE: All space in between the address should replace with ‘+’
Example response <GeocodeResponse> <status>OK</status> <result> <type>street_address</type> <formatted_address>1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA</formatted_address> <address_component> <long_name>1600</long_name> <short_name>1600</short_name> <type>street_number</type> </address_component> <address_component> <long_name>Amphitheatre Pkwy</long_name> <short_name>Amphitheatre Pkwy</short_name> <type>route</type> </address_component> <address_component> <long_name>Mountain View</long_name> <short_name>Mountain View</short_name> <type>locality</type> <type>political</type> </address_component> <address_component> <long_name>San Jose</long_name> <short_name>San Jose</short_name> <type>administrative_area_level_3</type> <type>political</type> </address_component> <address_component> <long_name>Santa Clara</long_name> <short_name>Santa Clara</short_name> <type>administrative_area_level_2</type> <type>political</type> </address_component> <address_component> <long_name>California</long_name> <short_name>CA</short_name> <type>administrative_area_level_1</type> <type>political</type> </address_component> <address_component> <long_name>United States</long_name> <short_name>US</short_name> <type>country</type> <type>political</type> </address_component> <address_component> <long_name>94043</long_name> <short_name>94043</short_name> <type>postal_code</type> </address_component> <geometry> <location> <lat>37.4217550</lat> <lng>-122.0846330</lng> </location> <location_type>ROOFTOP</location_type> <viewport> <southwest> <lat>37.4188514</lat> <lng>-122.0874526</lng> </southwest> <northeast> <lat>37.4251466</lat> <lng>-122.0811574</lng> </northeast> </viewport> </geometry> </result> </GeocodeResponse>
