upgrade to yui 2.5.1

This commit is contained in:
JT Smith 2008-03-25 16:13:25 +00:00
parent e00050ad1c
commit ff7d72becc
1632 changed files with 812103 additions and 0 deletions

View file

@ -0,0 +1 @@
<html><body></body></html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

View file

@ -0,0 +1,490 @@
YAHOO.example.Data = {
apitester: [
{number:0, date:new Date(1999, 1, 1), string:"1"},
{number:1, date:new Date(1999, 10, 10), string:"12"},
{number:2, date:new Date(2000, 1, 1), string:"123"},
{number:3, date:new Date(2000, 10, 1), string:"10"},
{number:4, date:new Date(2001, 10, 12), string:"1"},
{number:5, date:new Date(2001, 1, 12), string:"123"},
{number:6, date:new Date(2001, 10, 1), string:"11"},
{number:7, date:new Date(2001, 10, 1), string:"16"},
{number:8, date:new Date(2001, 10, 1), string:"8"},
{number:9, date:new Date(2001, 10, 1), string:"6"},
{number:10, date:new Date(2001, 10, 1), string:"66"},
{number:11, date:new Date(2001, 10, 1), string:"111"},
{number:12, date:new Date(2001, 10, 1), string:"110"}
],
multitypes: {
items: [
{field1: "bananas", field2:new Date(2007, 1, 1), field3:111, field4:"23.4", field5:"bob", field6:"http://www.yahoo.com"},
{field1: undefined, field2:new Date(2006, 1, 1), field3:12.3, field4:"35.12", field5:"ann", field6:"http://www.yahoo.com"},
{field1: "apples", field2:new Date(2007, 11, 1), field3:1, field4:34.12, field5:"charlie", field6:"http://www.yahoo.com"},
{field1: "bananas", field2:new Date(2007, 1, 11), field3:1112, field4:"03", field5:"diane", field6:"http://www.yahoo.com"},
{field1: "cherries", field2:new Date(1999, 1, 11), field3:124, field4:03, field5:"edgar", field6:"http://www.yahoo.com"},
{field1: "", field2:"January 10, 2005", field3:"12", field4:"34", field5:"francine", field6:"http://www.yahoo.com"},
{field1: "unknown", field2:"January 1, 2005", field3:"19.1", field4:"234.5", field5:"george", field6:"http://www.yahoo.com"},
{field1: null, field2:"1/11/05", field3:"10.02", field4:"345.654", field5:"hannah", field6:"http://www.yahoo.com"},
{field1: "cherries", field2:"1/11/2005", field3:"109", field4:23.456, field5:"igor", field6:"http://www.yahoo.com"},
{field1: "bananas", field2:"November 1, 2005", field3:"11111", field4:23.0123, field5:"julie", field6:"http://www.yahoo.com"}
]
},
webstats: [
["home.html",20,400,44,657],
["blog.html",24,377,97,567],
["contact.html",32,548,42,543],
["about.html",8,465,12,946],
["pagenotfound.html",0,0,0,0]
],
emails: {
account:"jenny@yahoo.com",
currStorage: 10,
maxStorage: 200,
messages: [
{XID: "9897",Date:new Date(1981, 2, 24),To:"Joe",From:"Jenny",Unread:false,Subject:"Check out my new pictures"},
{XID: "7899",Date:new Date(1980, 1, 11),To:"Jane",From:"Jenny",Unread:false,Subject:"Let's have lunch"},
{XID: "6789",Date:new Date(1978, 11, 12),To:"Ann",From:"Jenny",Unread:false,Subject:"Here's the info you requested"},
{XID: "4996",Date:new Date(1974, 1, 11),To:"Bob",From:"Jenny",Unread:true,Subject:"RE: Let's have lunch"},
{XID: "4544",Date:new Date(1974, 1, 10),To:"Charlie",From:"Jenny",Unread:false,Subject:"Birthday party Saturday"}
]
},
inventory: [
{SKU:"23-23874", Quantity:43, Item:"Helmet", Description:"Red baseball helmet. Size: Large."},
{SKU:"48-38835", Quantity:84, Item:"Football", Description:"Leather football."},
{SKU:"84-84848", Quantity:31, Item:"Goggles", Description:"Light blue swim goggles"},
{SKU:"84-84843", Quantity:56, Item:"Badminton Set", Description:"Set of 2 badminton rackets, net, and 3 birdies."},
{SKU:"84-39321", Quantity:128, Item:"Tennis Balls", Description:"Canister of 3 tennis balls."},
{SKU:"39-48949", Quantity:55, Item:"Snowboard", Description:""},
{SKU:"99-28128", Quantity:77, Item:"Cleats", Description:"Soccer cleats. Size: 10."},
{SKU:"83-48281", Quantity:65, Item:"Volleyball", Description:""},
{SKU:"89-32811", Quantity:12, Item:"Sweatband", Description:"Blue sweatband. Size: Medium."},
{SKU:"28-22847", Quantity:43, Item:"Golf Set", Description:"Set of 9 golf clubs and bag."},
{SKU:"38-38281", Quantity:1, Item:"Basketball Shorts", Description:"Green basketball shorts. Size: Small."},
{SKU:"82-38333", Quantity:288, Item:"Lip balm", Description:"Lip balm. Flavor: Cherry."},
{SKU:"21-38485", Quantity:177, Item:"Ping Pong Ball", Description:""},
{SKU:"83-38285", Quantity:87, Item:"Hockey Puck", Description:"Glow-in-the-dark hockey puck."}
],
addresses: [
{name:"John A. Smith", address:"1236 Some Street", city:"San Francisco", state:"CA", amount:5, active:"yes", colors:["red"], last_login:"4/19/2007"},
{name:"Joan B. Jones", address:"3271 Another Ave", city:"New York", state:"NY", amount:3, active:"no", colors:["red","blue"], last_login:"2/15/2006"},
{name:"Bob C. Uncle", address:"9996 Random Road", city:"Los Angeles", state:"CA", amount:0, active:"maybe", colors:["green"], last_login:"1/23/2004"},
{name:"John D. Smith", address:"1623 Some Street", city:"San Francisco", state:"CA", amount:5, active:"yes", colors:["red"], last_login:"4/19/2007"},
{name:"Joan E. Jones", address:"3217 Another Ave", city:"New York", state:"NY", amount:3, active:"no", colors:["red","blue"], last_login:"2/15/2006"},
{name:"Bob F. Uncle", address:"9899 Random Road", city:"Los Angeles", state:"CA", amount:0, active:"maybe", colors:["green"], last_login:"1/23/2004"},
{name:"John G. Smith", address:"1723 Some Street", city:"San Francisco", state:"CA", amount:5, active:"yes", colors:["red"], last_login:"4/19/2007"},
{name:"Joan H. Jones", address:"3241 Another Ave", city:"New York", state:"NY", amount:3, active:"no", colors:["red","blue"], last_login:"2/15/2006"},
{name:"Bob I. Uncle", address:"9909 Random Road", city:"Los Angeles", state:"CA", amount:0, active:"maybe", colors:["green"], last_login:"1/23/2004"},
{name:"John J. Smith", address:"1623 Some Street", city:"San Francisco", state:"CA", amount:5, active:"yes", colors:["red"], last_login:"4/19/2007"},
{name:"Joan K. Jones", address:"3721 Another Ave", city:"New York", state:"NY", amount:3, active:"no", colors:["red","blue"], last_login:"2/15/2006"},
{name:"Bob L. Uncle", address:"9989 Random Road", city:"Los Angeles", state:"CA", amount:0, active:"maybe", colors:["green"], last_login:"1/23/2004"},
{name:"John M. Smith", address:"1293 Some Street", city:"San Francisco", state:"CA", amount:5, active:"yes", colors:["red"], last_login:"4/19/2007"},
{name:"Joan N. Jones", address:"3621 Another Ave", city:"New York", state:"NY", amount:3, active:"no", colors:["red","blue"], last_login:"2/15/2006"},
{name:"Bob O. Uncle", address:"9959 Random Road", city:"Los Angeles", state:"CA", amount:0, active:"maybe", colors:["green"], last_login:"1/23/2004"},
{name:"John P. Smith", address:"6123 Some Street", city:"San Francisco", state:"CA", amount:5, active:"yes", colors:["red"], last_login:"4/19/2007"},
{name:"Joan Q. Jones", address:"3281 Another Ave", city:"New York", state:"NY", amount:3, active:"no", colors:["red","blue"], last_login:"2/15/2006"},
{name:"Bob R. Uncle", address:"9989 Random Road", city:"Los Angeles", state:"CA", amount:0, active:"maybe", colors:["green"], last_login:"1/23/2004"}
],
bookorders: [
{id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"},
{id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"},
{id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"},
{id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"}
],
stateAbbrs: [
"AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI",
"ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS",
"MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR",
"PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"
],
areacodes: [
{areacode: "201", state: "New Jersey"},
{areacode: "202", state: "Washington, DC"},
{areacode: "203", state: "Connecticut"},
{areacode: "204", state: "Manitoba, Canada"},
{areacode: "205", state: "Alabama"},
{areacode: "206", state: "Washington"},
{areacode: "207", state: "Maine"},
{areacode: "208", state: "Idaho"},
{areacode: "209", state: "California"},
{areacode: "210", state: "Texas"},
{areacode: "212", state: "New York"},
{areacode: "213", state: "California"},
{areacode: "214", state: "Texas"},
{areacode: "215", state: "Pennsylvania"},
{areacode: "216", state: "Ohio"},
{areacode: "217", state: "Illinois"},
{areacode: "218", state: "Minnesota"},
{areacode: "219", state: "Indiana"},
{areacode: "224", state: "Illinois"},
{areacode: "225", state: "Louisiana"},
{areacode: "227", state: "Maryland"},
{areacode: "228", state: "Mississippi"},
{areacode: "229", state: "Georgia"},
{areacode: "231", state: "Michigan"},
{areacode: "234", state: "Ohio"},
{areacode: "239", state: "Florida"},
{areacode: "240", state: "Maryland"},
{areacode: "242", state: "Bahamas"},
{areacode: "246", state: "Barbados"},
{areacode: "248", state: "Michigan"},
{areacode: "250", state: "British Columbia"},
{areacode: "251", state: "Alabama"},
{areacode: "252", state: "North Carolina"},
{areacode: "253", state: "Washington"},
{areacode: "254", state: "Texas"},
{areacode: "256", state: "Alabama"},
{areacode: "260", state: "Indiana"},
{areacode: "262", state: "Wisconsin"},
{areacode: "264", state: "Anguilla"},
{areacode: "267", state: "Pennsylvania"},
{areacode: "268", state: "Antigua and Barbuda"},
{areacode: "269", state: "Michigan"},
{areacode: "270", state: "Kentucky"},
{areacode: "276", state: "Virginia"},
{areacode: "281", state: "Texas"},
{areacode: "283", state: "Ohio"},
{areacode: "284", state: "British Virgin Islands"},
{areacode: "289", state: "Ontario"},
{areacode: "301", state: "Maryland"},
{areacode: "302", state: "Delaware"},
{areacode: "303", state: "Colorado"},
{areacode: "304", state: "West Virginia"},
{areacode: "305", state: "Florida"},
{areacode: "306", state: "Saskatchewan, Canada"},
{areacode: "307", state: "Wyoming"},
{areacode: "308", state: "Nebraska"},
{areacode: "309", state: "Illinois"},
{areacode: "310", state: "California"},
{areacode: "312", state: "Illinois"},
{areacode: "313", state: "Michigan"},
{areacode: "314", state: "Missouri"},
{areacode: "315", state: "New York"},
{areacode: "316", state: "Kansas"},
{areacode: "317", state: "Indiana"},
{areacode: "318", state: "Louisiana"},
{areacode: "319", state: "Iowa"},
{areacode: "320", state: "Minnesota"},
{areacode: "321", state: "Florida"},
{areacode: "323", state: "California"},
{areacode: "330", state: "Ohio"},
{areacode: "331", state: "Illinois"},
{areacode: "334", state: "Alabama"},
{areacode: "336", state: "North Carolina"},
{areacode: "337", state: "Louisiana"},
{areacode: "339", state: "Massachusetts"},
{areacode: "340", state: "US Virgin Islands"},
{areacode: "345", state: "Cayman Islands"},
{areacode: "347", state: "New York"},
{areacode: "351", state: "Massachusetts"},
{areacode: "352", state: "Florida"},
{areacode: "360", state: "Washington"},
{areacode: "361", state: "Texas"},
{areacode: "386", state: "Florida"},
{areacode: "401", state: "Rhode Island"},
{areacode: "402", state: "Nebraska"},
{areacode: "403", state: "Alberta, Canada"},
{areacode: "404", state: "Georgia"},
{areacode: "405", state: "Oklahoma"},
{areacode: "406", state: "Montana"},
{areacode: "407", state: "Florida"},
{areacode: "408", state: "California"},
{areacode: "409", state: "Texas"},
{areacode: "410", state: "Maryland"},
{areacode: "412", state: "Pennsylvania"},
{areacode: "413", state: "Massachusetts"},
{areacode: "414", state: "Wisconsin"},
{areacode: "415", state: "California"},
{areacode: "416", state: "Ontario, Canada"},
{areacode: "417", state: "Missouri"},
{areacode: "418", state: "Quebec, Canada"},
{areacode: "419", state: "Ohio"},
{areacode: "423", state: "Tennessee"},
{areacode: "424", state: "California"},
{areacode: "425", state: "Washington"},
{areacode: "434", state: "Virginia"},
{areacode: "435", state: "Utah"},
{areacode: "440", state: "Ohio"},
{areacode: "441", state: "Bermuda"},
{areacode: "443", state: "Maryland"},
{areacode: "445", state: "Pennsylvania"},
{areacode: "450", state: "Quebec, Canada"},
{areacode: "464", state: "Illinois"},
{areacode: "469", state: "Texas"},
{areacode: "470", state: "Georgia"},
{areacode: "473", state: "Grenada"},
{areacode: "475", state: "Connecticut"},
{areacode: "478", state: "Georgia"},
{areacode: "479", state: "Arkansas"},
{areacode: "480", state: "Arizona"},
{areacode: "484", state: "Pennsylvania"},
{areacode: "501", state: "Arkansas"},
{areacode: "502", state: "Kentucky"},
{areacode: "503", state: "Oregon"},
{areacode: "504", state: "Louisiana"},
{areacode: "505", state: "New Mexico"},
{areacode: "506", state: "New Brunswick, Canada"},
{areacode: "507", state: "Minnesota"},
{areacode: "508", state: "Massachusetts"},
{areacode: "509", state: "Washington"},
{areacode: "510", state: "California"},
{areacode: "512", state: "Texas"},
{areacode: "513", state: "Ohio"},
{areacode: "514", state: "Quebec, Canada"},
{areacode: "515", state: "Iowa"},
{areacode: "516", state: "New York"},
{areacode: "517", state: "Michigan"},
{areacode: "518", state: "New York"},
{areacode: "519", state: "Ontario, Canada"},
{areacode: "520", state: "Arizona"},
{areacode: "530", state: "California"},
{areacode: "540", state: "Virginia"},
{areacode: "541", state: "Oregon"},
{areacode: "551", state: "New Jersey"},
{areacode: "557", state: "Missouri"},
{areacode: "559", state: "California"},
{areacode: "561", state: "Florida"},
{areacode: "562", state: "California"},
{areacode: "563", state: "Iowa"},
{areacode: "564", state: "Washington"},
{areacode: "567", state: "Ohio"},
{areacode: "570", state: "Pennsylvania"},
{areacode: "571", state: "Virginia"},
{areacode: "573", state: "Missouri"},
{areacode: "574", state: "Indiana"},
{areacode: "580", state: "Oklahoma"},
{areacode: "585", state: "New York"},
{areacode: "586", state: "Michigan"},
{areacode: "601", state: "Mississippi"},
{areacode: "602", state: "Arizona"},
{areacode: "603", state: "New Hampshire"},
{areacode: "604", state: "British Columbia, Canada"},
{areacode: "605", state: "South Dakota"},
{areacode: "606", state: "Kentucky"},
{areacode: "607", state: "New York"},
{areacode: "608", state: "Wisconsin"},
{areacode: "609", state: "New Jersey"},
{areacode: "610", state: "Pennsylvania"},
{areacode: "612", state: "Minnesota"},
{areacode: "613", state: "Ontario, Canada"},
{areacode: "614", state: "Ohio"},
{areacode: "615", state: "Tennessee"},
{areacode: "616", state: "Michigan"},
{areacode: "617", state: "Massachusetts"},
{areacode: "618", state: "Illinois"},
{areacode: "619", state: "California"},
{areacode: "620", state: "Kansas"},
{areacode: "623", state: "Arizona"},
{areacode: "626", state: "California"},
{areacode: "630", state: "Illinois"},
{areacode: "631", state: "New York"},
{areacode: "636", state: "Missouri"},
{areacode: "641", state: "Iowa"},
{areacode: "646", state: "New York"},
{areacode: "647", state: "Ontario, Canada"},
{areacode: "649", state: "Turks and Caicos Islands"},
{areacode: "650", state: "California"},
{areacode: "651", state: "Minnesota"},
{areacode: "660", state: "Missouri"},
{areacode: "661", state: "California"},
{areacode: "662", state: "Mississippi"},
{areacode: "664", state: "Montserrat"},
{areacode: "667", state: "Maryland"},
{areacode: "670", state: "CNMI"},
{areacode: "671", state: "Guam"},
{areacode: "678", state: "Georgia"},
{areacode: "682", state: "Texas"},
{areacode: "701", state: "North Dakota"},
{areacode: "702", state: "Nevada"},
{areacode: "703", state: "Virginia"},
{areacode: "704", state: "North Carolina"},
{areacode: "705", state: "Ontario, Canada"},
{areacode: "706", state: "Georgia"},
{areacode: "707", state: "California"},
{areacode: "708", state: "Illinois"},
{areacode: "709", state: "Newfoundland, Canada"},
{areacode: "712", state: "Iowa"},
{areacode: "713", state: "Texas"},
{areacode: "714", state: "California"},
{areacode: "715", state: "Wisconsin"},
{areacode: "716", state: "New York"},
{areacode: "717", state: "Pennsylvania"},
{areacode: "718", state: "New York"},
{areacode: "719", state: "Colorado"},
{areacode: "720", state: "Colorado"},
{areacode: "724", state: "Pennsylvania"},
{areacode: "727", state: "Florida"},
{areacode: "731", state: "Tennessee"},
{areacode: "732", state: "New Jersey"},
{areacode: "734", state: "Michigan"},
{areacode: "737", state: "Texas"},
{areacode: "740", state: "Ohio"},
{areacode: "754", state: "Florida"},
{areacode: "757", state: "Viriginia"},
{areacode: "758", state: "St. Lucia"},
{areacode: "760", state: "California"},
{areacode: "763", state: "Minnesota"},
{areacode: "765", state: "Indiana"},
{areacode: "767", state: "Dominica"},
{areacode: "770", state: "Georgia"},
{areacode: "772", state: "Florida"},
{areacode: "773", state: "Illinois"},
{areacode: "774", state: "Massachusetts"},
{areacode: "775", state: "Nevada"},
{areacode: "778", state: "British Columbia, Canada"},
{areacode: "780", state: "Alberta, Canada"},
{areacode: "781", state: "Massachusetts"},
{areacode: "784", state: "St. Vincent &amp; Gren."},
{areacode: "785", state: "Kansas"},
{areacode: "786", state: "Florida"},
{areacode: "787", state: "Puerto Rico"},
{areacode: "801", state: "Utah"},
{areacode: "802", state: "Vermont"},
{areacode: "803", state: "South Carolina"},
{areacode: "804", state: "Virginia"},
{areacode: "805", state: "California"},
{areacode: "806", state: "Texas"},
{areacode: "807", state: "Ontario, Canada"},
{areacode: "808", state: "Hawaii"},
{areacode: "809", state: "Dominican Republic"},
{areacode: "810", state: "Michigan"},
{areacode: "812", state: "Indiana"},
{areacode: "813", state: "Florida"},
{areacode: "814", state: "Pennsylvania"},
{areacode: "815", state: "Illinois"},
{areacode: "816", state: "Missouri"},
{areacode: "817", state: "Texas"},
{areacode: "818", state: "California"},
{areacode: "819", state: "Quebec, Canada"},
{areacode: "828", state: "North Carolina"},
{areacode: "830", state: "Texas"},
{areacode: "831", state: "California"},
{areacode: "832", state: "Texas"},
{areacode: "835", state: "Pennsylvania"},
{areacode: "843", state: "South Carolina"},
{areacode: "845", state: "New York"},
{areacode: "847", state: "Illinois"},
{areacode: "848", state: "New Jersey"},
{areacode: "850", state: "Florida"},
{areacode: "856", state: "New Jersey"},
{areacode: "857", state: "Massachusetts"},
{areacode: "858", state: "California"},
{areacode: "859", state: "Kentucky"},
{areacode: "860", state: "Connecticut"},
{areacode: "862", state: "New Jersey"},
{areacode: "863", state: "Florida"},
{areacode: "864", state: "South Carolina"},
{areacode: "865", state: "Tennessee"},
{areacode: "867", state: "Yukon, NW Territories, Canada"},
{areacode: "868", state: "Trinidad and Tobago"},
{areacode: "869", state: "St. Kitts &amp; Nevis"},
{areacode: "870", state: "Arkansas"},
{areacode: "872", state: "Illinois"},
{areacode: "876", state: "Jamaica"},
{areacode: "878", state: "Pennsylvania"},
{areacode: "901", state: "Tennessee"},
{areacode: "902", state: "Nova Scotia, Canada"},
{areacode: "903", state: "Texas"},
{areacode: "904", state: "Florida"},
{areacode: "905", state: "Ontario, Canada"},
{areacode: "906", state: "Michigan"},
{areacode: "907", state: "Alaska"},
{areacode: "908", state: "New Jersey"},
{areacode: "909", state: "California"},
{areacode: "910", state: "North Carolina"},
{areacode: "912", state: "Georgia"},
{areacode: "913", state: "Kansas"},
{areacode: "914", state: "New York"},
{areacode: "915", state: "Texas"},
{areacode: "916", state: "California"},
{areacode: "917", state: "New York"},
{areacode: "918", state: "Oklahoma"},
{areacode: "919", state: "North Carolina"},
{areacode: "920", state: "Wisconsin"},
{areacode: "925", state: "California"},
{areacode: "928", state: "Arizona"},
{areacode: "931", state: "Tennessee"},
{areacode: "936", state: "Texas"},
{areacode: "937", state: "Ohio"},
{areacode: "939", state: "Puerto Rico"},
{areacode: "940", state: "Texas"},
{areacode: "941", state: "Florida"},
{areacode: "947", state: "Michigan"},
{areacode: "949", state: "California"},
{areacode: "952", state: "Minnesota"},
{areacode: "954", state: "Florida"},
{areacode: "956", state: "Texas"},
{areacode: "959", state: "Connecticut"},
{areacode: "970", state: "Colorado"},
{areacode: "971", state: "Oregon"},
{areacode: "972", state: "Texas"},
{areacode: "973", state: "New Jersey"},
{areacode: "975", state: "Missouri"},
{areacode: "978", state: "Massachusetts"},
{areacode: "979", state: "Texas"},
{areacode: "980", state: "North Carolina"},
{areacode: "984", state: "North Carolina"},
{areacode: "985", state: "Louisiana"},
{areacode: "989", state: "Michigan"}
]
};

View file

@ -0,0 +1,808 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/* yadl_spaceid - Skip Stamping */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php,v 1.2 2007/07/31 21:14:29 jennyhan Exp $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 3);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 4);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 5);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 16);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
}
// treat it like a regular array
$elements = array_map(array($this, 'encode'), $var);
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
return '[' . join(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->encode($value);
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
return $this->encode(strval($name)) . ':' . $encoded_value;
}
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
case 'null':
return null;
default:
$m = array();
if (is_numeric($str)) {
// Lookie-loo, it's a number
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
}
}
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} else {
return $obj;
}
}
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
}
}
}
}
/**
* @todo Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
return false;
}
}
if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
} else {
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
}
}
}
?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
Domino's Pizza|615 Caliente Dr|Sunnyvale|(408) 732-3030|4|http://local.yahoo.com/details?id=21335892&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=17rS8q160Sy5Htog0TF1m1atNv01Iz7ySeGEMtCL4dJsf1ku0nhziD2qN5XcnHlJtDS4IydIbA--
Pizza Depot|919 E Duane Ave|Sunnyvale|(408) 245-7760|3.5|http://local.yahoo.com/details?id=21332021&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=6tiAL6160Sx1XVIEu1zIWPu6fD8rJDV4.offJLNUTb1Ri2Q.R5oLTYvDCz8YmzivI7Bz0gfrpw--
Pizza Hut|464 N Mathilda Ave|Sunnyvale|(408) 735-1900|2.5|http://local.yahoo.com/details?id=21340811&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=syVWvq160Szz0Q60Q8N7uetWGoUIbThLIdulmQLubJ29CuU7wpxDvDxrLF4md791a4jW7kNRr9eSVQ--
Giovannis Pizzeria|1127 N Lawrence Expy|Sunnyvale|(408) 734-4221|4.5|http://local.yahoo.com/details?id=21341983&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=kYc.Ba160SxZddWADEWWMRsGo0KgZ6X22_QAgTZxq3OdfrVCfCdLU9mvvJeybt8XpDhMC58HjElJAiWi
Round Table Pizza|415 N Mary Ave|Sunnyvale|(408) 733-1365|5|http://local.yahoo.com/details?id=21329046&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=OkhHFa160Sx2UXqpaqXDZAGyyKWrCO9wfqP24Mur1nNB2pqgQsi3DQxeSEK_Uj9fxQN4zNax
Vitos Famous Pizza|1155 Reed Ave|Sunnyvale|(408) 246-8800|4.5|http://local.yahoo.com/details?id=21332026&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=QTqeMK160Sx0Mril0Jnu_RK0RF4vTvEspLb2s60hJTic2.RapYE82B6edOm18LAox7KOqkw-
Round Table Pizza|101 Town And Countr|Sunnyvale|(408) 736-2242|3|http://local.yahoo.com/details?id=21340803&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=SiKr2K160SwJxDEvf_eAwROvFMpfCIqsVX3dSyYtvj6HomUPpdS92g9AIoaoZNtg.WNSGcT4hpk1JxxT
Round Table Pizza|860 Old San Francisco Rd|Sunnyvale|(408) 245-9000|3|http://local.yahoo.com/details?id=21340791&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=NF3MAq160SzKHt2S1yk7tJKtIMvbW44yNlckp8Y5veL7w8DWvagJYLH2tGehl1cPcLGbR4kzMTi4cf1U7iP6YA--
Domino's Pizza|992 W El Camino Real|Sunnyvale|(408) 736-3666|4|http://local.yahoo.com/details?id=21341882&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=_tzLZq160SyF.4GddMA07QiACQkYc84nqI0j3hvsAcfMemwlBCiezUltSm8_ppCH1Bo8SlklBj1QhuRp
Little Caesars Pizza|1039 Sunnyvale Saratoga Rd|Sunnyvale|(408) 245-0607|3|http://local.yahoo.com/details?id=21330174&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=89myuK160Syd6uoWQ5fTb6uLid70P.ucvPaBKA92m7bc1aVSW5LGmRbGsSIqT8U5e2eA4Ki4nQHVAAhh5.SVNIAQ

View file

@ -0,0 +1,11 @@
Restaurant|Location|Town|Telephone|Stars|Website
Domino's Pizza|615 Caliente Dr|Sunnyvale|(408) 732-3030|4|http://local.yahoo.com/details?id=21335892&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=17rS8q160Sy5Htog0TF1m1atNv01Iz7ySeGEMtCL4dJsf1ku0nhziD2qN5XcnHlJtDS4IydIbA--
Pizza Depot|919 E Duane Ave|Sunnyvale|(408) 245-7760|3.5|http://local.yahoo.com/details?id=21332021&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=6tiAL6160Sx1XVIEu1zIWPu6fD8rJDV4.offJLNUTb1Ri2Q.R5oLTYvDCz8YmzivI7Bz0gfrpw--
Pizza Hut|464 N Mathilda Ave|Sunnyvale|(408) 735-1900|2.5|http://local.yahoo.com/details?id=21340811&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=syVWvq160Szz0Q60Q8N7uetWGoUIbThLIdulmQLubJ29CuU7wpxDvDxrLF4md791a4jW7kNRr9eSVQ--
Giovannis Pizzeria|1127 N Lawrence Expy|Sunnyvale|(408) 734-4221|4.5|http://local.yahoo.com/details?id=21341983&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=kYc.Ba160SxZddWADEWWMRsGo0KgZ6X22_QAgTZxq3OdfrVCfCdLU9mvvJeybt8XpDhMC58HjElJAiWi
Round Table Pizza|415 N Mary Ave|Sunnyvale|(408) 733-1365|5|http://local.yahoo.com/details?id=21329046&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=OkhHFa160Sx2UXqpaqXDZAGyyKWrCO9wfqP24Mur1nNB2pqgQsi3DQxeSEK_Uj9fxQN4zNax
Vitos Famous Pizza|1155 Reed Ave|Sunnyvale|(408) 246-8800|4.5|http://local.yahoo.com/details?id=21332026&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=QTqeMK160Sx0Mril0Jnu_RK0RF4vTvEspLb2s60hJTic2.RapYE82B6edOm18LAox7KOqkw-
Round Table Pizza|101 Town And Countr|Sunnyvale|(408) 736-2242|3|http://local.yahoo.com/details?id=21340803&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=SiKr2K160SwJxDEvf_eAwROvFMpfCIqsVX3dSyYtvj6HomUPpdS92g9AIoaoZNtg.WNSGcT4hpk1JxxT
Round Table Pizza|860 Old San Francisco Rd|Sunnyvale|(408) 245-9000|3|http://local.yahoo.com/details?id=21340791&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=NF3MAq160SzKHt2S1yk7tJKtIMvbW44yNlckp8Y5veL7w8DWvagJYLH2tGehl1cPcLGbR4kzMTi4cf1U7iP6YA--
Domino's Pizza|992 W El Camino Real|Sunnyvale|(408) 736-3666|4|http://local.yahoo.com/details?id=21341882&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=_tzLZq160SyF.4GddMA07QiACQkYc84nqI0j3hvsAcfMemwlBCiezUltSm8_ppCH1Bo8SlklBj1QhuRp
Little Caesars Pizza|1039 Sunnyvale Saratoga Rd|Sunnyvale|(408) 245-0607|3|http://local.yahoo.com/details?id=21330174&amp;stx=pizza&amp;csz=Sunnyvale+CA&amp;ed=89myuK160Syd6uoWQ5fTb6uLid70P.ucvPaBKA92m7bc1aVSW5LGmRbGsSIqT8U5e2eA4Ki4nQHVAAhh5.SVNIAQ

View file

@ -0,0 +1,45 @@
<?php
/* yadl_spaceid - Skip Stamping */
// Yahoo! proxy
// Hard-code hostname and path:
define ('PATH', 'http://local.yahooapis.com/LocalSearchService/V2/localSearch');
$type = "text/xml";
// Get all query params
$query = "?";
foreach ($_GET as $key => $value) {
if(($key == "output") && ($value == "json")) {
$type = "application/json";
}
$query .= urlencode($key)."=".urlencode($value)."&";
}
foreach ($_POST as $key => $value) {
if(($key == "output") && ($value == "json")) {
$type = "application/json";
}
$query .= $key."=".$value."&";
}
$query .= "appid=YahooDemo";
$url = PATH.$query;
// Open the Curl session
$session = curl_init($url);
// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Make the call
$response = curl_exec($session);
header("Content-Type: ".$type);
echo $response;
curl_close($session);
?>