Using XAJAX to autocomplete emails from address book

PostPosted: Sat Sep 10, 2005 6:00 pm Post subject: Reply with quote

Imagine that you are supposed to type in an email address into a form. You would typically type an email address that may be stored in your address book from a MySQL database. There are too many emails in your address book to pre-populate into a list on the page. Instead you want to start typing and have addresses that match what you’ve typed so far appear in a drop down. We will fetch the emails to populate the drop down from the server, on the fly, in the background.

Read moreUsing XAJAX to autocomplete emails from address book

Net_IPv4 Coolness

Available from the PEAR website, http://pear.php.net/package/Net_IPv4, the Net_IPv4 package is pretty cool. Check this out:

<?php
require_once(“IPv4.php”);
$ip = $argv[1];
$netmask = $argv[2];

$ip_calc = new Net_IPv4();
$ip_calc->ip = $ip;
$ip_calc->netmask = $netmask;
$ip_calc->calculate();
$ip_calc->min = $ip_calc->network;
$ip_calc->max = $ip_calc->broadcast;
$ip_calc->min_long = $ip_calc->ip2double($ip_calc->network);
$ip_calc->max_long = $ip_calc->ip2double($ip_calc->broadcast);
$ip_calc->gateway = long2ip($ip_calc->max_long-1);

print_r($ip_calc);
?>

Read moreNet_IPv4 Coolness

Playing with Wake-On-Lan (WOL)

Pre-req:
+ Must have php5 with –enable-sockets

What is a magic packet?
It’s a udp packet sent through the broadcast address to all servers on the network (ie, all servers serviced by the broadcast address). It’s called magic, because the format of the message is so strange. A mac address looks like this, 00:30:1B:BA:FA:47, it’s a series of 6 hexidecimal numbers. The magic packet message is a 6 char header, then the mac address, converted to a character sequence, repeated 16 times.

Read morePlaying with Wake-On-Lan (WOL)

Repeating same name parameters with nusoap

This article assumes you have a background with nusoap. Start by reading a nusoap tutorial or two, suggest http://www.zend.com/zend/tut/tutorial-campbell.php and http://www.scottnichol.com/nusoapprogwsdl.htm

I’m going to setup a soap server to except parameters. The method will do something silly, the point is to understand how to make a client with nusoap, when the server excepts repeating, same name parameters. This came up for me recently, and I struggled with it for hours, never did find a good explaination of it online, so I’m writing this for the next guy.

Read moreRepeating same name parameters with nusoap

Paypal API issues, using PHP5 and nusoap

Posted 1 year, 6 months ago on August 27, 2006 by dave #

Back in Aug 2005, I found something wrong with the http://www.paypal.com/wsdl/PayPalSvc.wsdl file, it’s still a problem!

I have a really interesting situation trying to retrieve order information from Paypal. I compiled PHP 5.0.4 –with-soap thinking that I would just use the built in Soap implemention that comes with PHP5. So, I start with PayPal’s GetTransactionDetails API call. It didn’t work because the service address location defined in the production WSDL has the sandbox URL in it. I complained about this to Paypal, they ignored it, and even released another, version 2.0, of their WSDL with the same mistake in it. I don’t know what they’re doing over there… I can hardly believe that they are allowing this mistake to continue to live in production for weeks (now becoming months).

Read morePaypal API issues, using PHP5 and nusoap

Load javascript with random query param

For now, I am just getting this logged somewhere I can find it later:

Code:
<script>
  var el = document.createElement( “script” );
  el.setAttribute( “type”, “text/javascript” );
  el.setAttribute( “src”, “time.php?rand=”+bigRandomString);
  document.getElementsByTagName( “head” )[ 0 ].appendChild( el );

  function receiveTime(minLeft)
  {
     // Do whatever
  }
</script>

time.php:

<?php

$minleft = “whatever”;
print “receiveTime($minleft);”
exit;

?>

Read moreLoad javascript with random query param

Turn a Text Form Element into a drop down / text box

Imagine you have a text box, like this:

Name: [ ]Email: [ ]

You want them to be text boxes that the user can type in, but you also have some default choices to give. For example, I may have an address book in a database and may want to provide an autocomplete function on these fields.

So, I wrote a generic javascript package to be able to do this. I call it, “dropbox”. It allows you to turn any text input element into a text/dropbox element. You just define an array of choices to be displayed. It will show the whole list, onfocus, if the field is empty, but will reduce it’s selection set as the user types. In other words, it acts as an autocomplete selection drop down.

Read moreTurn a Text Form Element into a drop down / text box