1/* 2 * More info at: http://phpjs.org 3 * 4 * This is version: 3.25 5 * php.js is copyright 2011 Kevin van Zonneveld. 6 * 7 * Portions copyright Brett Zamir (http://brett-zamir.me), Kevin van Zonneveld 8 * (http://kevin.vanzonneveld.net), Onno Marsman, Theriault, Michael White 9 * (http://getsprink.com), Waldo Malqui Silva, Paulo Freitas, Jonas Raoni 10 * Soares Silva (http://www.jsfromhell.com), Jack, Philip Peterson, Legaev 11 * Andrey, Ates Goral (http://magnetiq.com), Ratheous, Alex, RafaŠKukawski 12 * (http://blog.kukawski.pl), Martijn Wieringa, lmeyrick 13 * (https://sourceforge.net/projects/bcmath-js/), Nate, Enrique Gonzalez, 14 * Philippe Baumann, Webtoolkit.info (http://www.webtoolkit.info/), Jani 15 * Hartikainen, Ole Vrijenhoek, Ash Searle (http://hexmen.com/blog/), Carlos 16 * R. L. Rodrigues (http://www.jsfromhell.com), travc, Michael Grier, 17 * Erkekjetter, Johnny Mast (http://www.phpvrouwen.nl), RafaŠKukawski 18 * (http://blog.kukawski.pl/), GeekFG (http://geekfg.blogspot.com), Andrea 19 * Giammarchi (http://webreflection.blogspot.com), WebDevHobo 20 * (http://webdevhobo.blogspot.com/), d3x, marrtins, 21 * http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript, 22 * pilus, stag019, T.Wild, Martin (http://www.erlenwiese.de/), majak, Marc 23 * Palau, Mirek Slugen, Chris, Diplom@t (http://difane.com/), Breaking Par 24 * Consulting Inc 25 * (http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CFB006C45F7), 26 * gettimeofday, Arpad Ray (mailto:[email protected]), Oleg Eremeev, Josh Fraser 27 * (http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/), 28 * Steve Hilder, mdsjack (http://www.mdsjack.bo.it), Kevin van Zonneveld 29 * (http://kevin.vanzonneveld.net/), gorthaur, Aman Gupta, Sakimori, Joris, 30 * Robin, Kankrelune (http://www.webfaktory.info/), Alfonso Jimenez 31 * (http://www.alfonsojimenez.com), David, Felix Geisendoerfer 32 * (http://www.debuggable.com/felix), Lars Fischer, Karol Kowalski, Imgen Tata 33 * (http://www.myipdf.com/), Steven Levithan (http://blog.stevenlevithan.com), 34 * Tim de Koning (http://www.kingsquare.nl), Dreamer, AJ, Paul Smith, KELAN, 35 * Pellentesque Malesuada, felix, Michael White, Mailfaker 36 * (http://www.weedem.fr/), Thunder.m, Tyler Akins (http://rumkin.com), 37 * saulius, Public Domain (http://www.json.org/json2.js), Caio Ariede 38 * (http://caioariede.com), Steve Clay, David James, madipta, Marco, Ole 39 * Vrijenhoek (http://www.nervous.nl/), class_exists, T. Wild, noname, Arno, 40 * Frank Forte, Francois, Scott Cariss, Slawomir Kaniecki, date, Itsacon 41 * (http://www.itsacon.net/), Billy, vlado houba, Jalal Berrami, 42 * ReverseSyntax, Mateusz "loonquawl" Zalega, john (http://www.jd-tech.net), 43 * mktime, Douglas Crockford (http://javascript.crockford.com), ger, Nick 44 * Kolosov (http://sammy.ru), Nathan, nobbler, Fox, marc andreu, Alex Wilson, 45 * Raphael (Ao RUDLER), Bayron Guevara, Adam Wallner 46 * (http://web2.bitbaro.hu/), paulo kuong, jmweb, Lincoln Ramsay, djmix, 47 * Pyerre, Jon Hohle, Thiago Mata (http://thiagomata.blog.com), lmeyrick 48 * (https://sourceforge.net/projects/bcmath-js/this.), Linuxworld, duncan, 49 * Gilbert, Sanjoy Roy, Shingo, sankai, Oskar Larsson Högfeldt 50 * (http://oskar-lh.name/), Denny Wardhana, 0m3r, Everlasto, Subhasis Deb, 51 * josh, jd, Pier Paolo Ramon (http://www.mastersoup.com/), P, merabi, Soren 52 * Hansen, EdorFaus, Eugene Bulkin (http://doubleaw.com/), Der Simon 53 * (http://innerdom.sourceforge.net/), echo is bad, JB, LH, kenneth, J A R, 54 * Marc Jansen, Stoyan Kyosev (http://www.svest.org/), Francesco, XoraX 55 * (http://www.xorax.info), Ozh, Brad Touesnard, MeEtc 56 * (http://yass.meetcweb.com), Peter-Paul Koch 57 * (http://www.quirksmode.org/js/beat.html), Olivier Louvignes 58 * (http://mg-crea.com/), T0bsn, Tim Wiel, Bryan Elliott, nord_ua, Martin, JT, 59 * David Randall, Thomas Beaucourt (http://www.webapp.fr), Tim de Koning, 60 * stensi, Pierre-Luc Paour, Kristof Coomans (SCK-CEN Belgian Nucleair 61 * Research Centre), Martin Pool, Kirk Strobeck, Rick Waldron, Brant Messenger 62 * (http://www.brantmessenger.com/), Devan Penner-Woelk, Saulo Vallory, Wagner 63 * B. Soares, Artur Tchernychev, Valentina De Rosa, Jason Wong 64 * (http://carrot.org/), Christoph, Daniel Esteban, strftime, Mick@el, rezna, 65 * Simon Willison (http://simonwillison.net), Anton Ongson, Gabriel Paderni, 66 * Marco van Oort, penutbutterjelly, Philipp Lenssen, Bjorn Roesbeke 67 * (http://www.bjornroesbeke.be/), Bug?, Eric Nagel, Tomasz Wesolowski, 68 * Evertjan Garretsen, Bobby Drake, Blues (http://tech.bluesmoon.info/), Luke 69 * Godfrey, Pul, uestla, Alan C, Ulrich, Rafal Kukawski, Yves Sucaet,
70 * sowberry, Norman "zEh" Fuchs, hitwork, Zahlii, johnrembo, Nick Callen, 71 * Steven Levithan (stevenlevithan.com), ejsanders, Scott Baker, Brian Tafoya 72 * (http://www.premasolutions.com/), Philippe Jausions 73 * (http://pear.php.net/user/jausions), Aidan Lister 74 * (http://aidanlister.com/), Rob, e-mike, HKM, ChaosNo1, metjay, strcasecmp, 75 * strcmp, Taras Bogach, jpfle, Alexander Ermolaev 76 * (http://snippets.dzone.com/user/AlexanderErmolaev), DxGx, kilops, Orlando, 77 * dptr1988, Le Torbi, James (http://www.james-bell.co.uk/), Pedro Tainha 78 * (http://www.pedrotainha.com), James, Arnout Kazemier 79 * (http://www.3rd-Eden.com), Chris McMacken, Yannoo, jakes, gabriel paderni, 80 * FGFEmperor, Greg Frazier, baris ozdil, 3D-GRAF, daniel airton wermann 81 * (http://wermann.com.br), Howard Yeend, Diogo Resende, Allan Jensen 82 * (http://www.winternet.no), Benjamin Lupton, Atli Ãór, Maximusya, davook, 83 * Tod Gentille, Ryan W Tenney (http://ryan.10e.us), Nathan Sepulveda, Cord, 84 * fearphage (http://http/my.opera.com/fearphage/), Victor, RafaÅ Kukawski 85 * (http://kukawski.pl), Matteo, Manish, Matt Bradley, Riddler 86 * (http://www.frontierwebdev.com/), Alexander M Beedie, T.J. Leahy, RafaÅ 87 * Kukawski, taith, Luis Salazar (http://www.freaky-media.com/), FremyCompany, 88 * Rival, Luke Smith (http://lucassmith.name), Andrej Pavlovic, Garagoth, Le 89 * Torbi (http://www.letorbi.de/), Dino, Josep Sanz (http://www.ws3.es/), rem, 90 * Russell Walker (http://www.nbill.co.uk/), Jamie Beck 91 * (http://www.terabit.ca/), setcookie, Michael, YUI Library: 92 * http://developer.yahoo.com/yui/docs/YAHOO.util.DateLocale.html, Blues at 93 * http://hacks.bluesmoon.info/strftime/strftime.js, Ben 94 * (http://benblume.co.uk/), DtTvB 95 * (http://dt.in.th/2008-09-16.string-length-in-bytes.html), Andreas, William, 96 * meo, incidence, Cagri Ekin, Amirouche, Amir Habibi 97 * (http://www.residence-mixte.com/), Kheang Hok Chin 98 * (http://www.distantia.ca/), Jay Klehr, Lorenzo Pisani, Tony, Yen-Wei Liu, 99 * Greenseed, mk.keck, Leslie Hoare, dude, booeyOH, Ben Bryan 100 * 101 * Dual licensed under the MIT (MIT-LICENSE.txt) 102 * and GPL (GPL-LICENSE.txt) licenses. 103 * 104 * Permission is hereby granted, free of charge, to any person obtaining a 105 * copy of this software and associated documentation files (the 106 * "Software"), to deal in the Software without restriction, including 107 * without limitation the rights to use, copy, modify, merge, publish, 108 * distribute, sublicense, and/or sell copies of the Software, and to 109 * permit persons to whom the Software is furnished to do so, subject to 110 * the following conditions: 111 * 112 * The above copyright notice and this permission notice shall be included 113 * in all copies or substantial portions of the Software. 114 * 115 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 116 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 117 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 118 * IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES 119 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 120 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 121 * OTHER DEALINGS IN THE SOFTWARE. 122 */ 123 124 125// Compression: minified 126 127 128function base64_decode(data){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var o1,o2,o3,h1,h2,h3,h4,bits,i=0,ac=0,dec="",tmp_arr=[];if(!data){return data;} 129data+='';do{h1=b64.indexOf(data.charAt(i++));h2=b64.indexOf(data.charAt(i++));h3=b64.indexOf(data.charAt(i++));h4=b64.indexOf(data.charAt(i++));bits=h1<<18|h2<<12|h3<<6|h4;o1=bits>>16&0xff;o2=bits>>8&0xff;o3=bits&0xff;if(h3==64){tmp_arr[ac++]=String.fromCharCode(o1);}else if(h4==64){tmp_arr[ac++]=String.fromCharCode(o1,o2);}else{tmp_arr[ac++]=String.fromCharCode(o1,o2,o3);}}while(i<data.length);dec=tmp_arr.join('');dec=this.utf8_decode(dec);return dec;} 130function base64_encode(data){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var o1,o2,o3,h1,h2,h3,h4,bits,i=0,ac=0,enc="",tmp_arr=[];if(!data){return data;} 131data=this.utf8_encode(data+'');do{o1=data.charCodeAt(i++);o2=data.charCodeAt(i++);o3=data.charCodeAt(i++);bits=o1<<16|o2<<8|o3;h1=bits>>18&0x3f;h2=bits>>12&0x3f;h3=bits>>6&0x3f;h4=bits&0x3f;tmp_arr[ac++]=b64.charAt(h1)+b64.charAt(h2)+b64.charAt(h3)+b64.charAt(h4);}while(i<data.length);enc=tmp_arr.join('');switch(data.length%3){case 1:enc=enc.slice(0,-2)+'==';break;case 2:enc=enc.slice(0,-1)+'=';break;} 132return enc;} 133function json_decode(str_json){var json=this.window.JSON;if(typeof json==='object'&&typeof json.parse==='function'){try{return json.parse(str_json);}catch(err){if(!(err instanceof SyntaxError)){throw new Error('Unexpected error type in json_decode()');} 134this.php_js=this.php_js||{};this.php_js.last_error_json=4;return null;}} 135var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var j;var text=str_json;cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCo
vendor: 9,994 bytes, lines 135-205
135deAt(0).toString(16)).slice(-4);});} 136if((/^[\],:{}\s]*$/).test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return j;} 137this.php_js=this.php_js||{};this.php_js.last_error_json=4;return null;} 138function json_encode(mixed_val){var retVal,json=this.window.JSON;try{if(typeof json==='object'&&typeof json.stringify==='function'){retVal=json.stringify(mixed_val);if(retVal===undefined){throw new SyntaxError('json_encode');} 139return retVal;} 140var value=mixed_val;var quote=function(string){var escapable=/[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';};var str=function(key,holder){var gap='';var indent=' ';var i=0;var k='';var v='';var length=0;var mind=gap;var partial=[];var value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);} 141switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';} 142if((this.PHPJS_Resource&&value instanceof this.PHPJS_Resource)||(window.PHPJS_Resource&&value instanceof window.PHPJS_Resource)){throw new SyntaxError('json_encode');} 143gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';} 144v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;} 145for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}} 146v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;case'undefined':case'function':default:throw new SyntaxError('json_encode');}};return str('',{'':value});}catch(err){if(!(err instanceof SyntaxError)){throw new Error('Unexpected error type in json_encode()');} 147this.php_js=this.php_js||{};this.php_js.last_error_json=4;return null;}} 148function pack(format){var formatPointer=0,argumentPointer=1,result='',argument='',i=0,r=[],instruction,quantifier,word,precisionBits,exponentBits,extraNullCount;var bias,minExp,maxExp,minUnnormExp,status,exp,len,bin,signal,n,intPart,floatPart,lastBit,rounded,j,k,tmpResult;while(formatPointer<format.length){instruction=format[formatPointer];quantifier='';formatPointer++;while((formatPointer<format.length)&&(format[formatPointer].match(/[\d\*]/)!==null)){quantifier+=format[formatPointer];formatPointer++;} 149if(quantifier===''){quantifier='1';} 150switch(instruction){case'a':case'A':if(typeof arguments[argumentPointer]==='undefined'){throw new Error('Warning: pack() Type '+instruction+': not enough arguments');}else{argument=String(arguments[argumentPointer]);} 151if(quantifier==='*'){quantifier=argument.length;} 152for(i=0;i<quantifier;i++){if(typeof argument[i]==='undefined'){if(instruction==='a'){result+=String.fromCharCode(0);}else{result+=' ';}}else{result+=argument[i];}} 153argumentPointer++;break;case'h':case'H':if(typeof arguments[argumentPointer]==='undefined'){throw new Error('Warning: pack() Type '+instruction+': not enough arguments');}else{argument=arguments[argumentPointer];} 154if(quantifier==='*'){quantifier=argument.length;} 155if(quantifier>argument.length){throw new Error('Warning: pack() Type '+instruction+': not enough characters in string');} 156for(i=0;i<quantifier;i+=2){word=argument[i];if(((i+1)>=quantifier)||typeof(argument[i+1])==='undefined'){word+='0';}else{word+=argument[i+1];} 157if(instruction==='h'){word=word[1]+word[0];} 158result+=String.fromCharCode(parseInt(word,16));} 159argumentPointer++;break;case'c':case'C':if(quantifier==='*'){quantifier=arguments.length-argumentPointer;} 160if(quantifier>(arguments.length-argumentPointer)){throw new Error('Warning: pack() Type '+instruction+': too few arguments');} 161for(i=0;i<quantifier;i++){result+=String.fromCharCode(arguments[argumentPointer]);argumentPointer++;} 162break;case's':case'S':case'v':if(quantifier==='*'){quantifier=arguments.length-argumentPointer;} 163if(quantifier>(arguments.length-argumentPointer)){throw new Error('Warning: pack() Type '+instruction+': too few arguments');} 164for(i=0;i<quantifier;i++){result+=String.fromCharCode(arguments[argumentPointer]&0xFF);result+=String.fromCharCode(arguments[argumentPointer]>>8&0xFF);argumentPointer++;} 165break;case'n':if(quantifier==='*'){quantifier=arguments.length-argumentPointer;} 166if(quantifier>(arguments.length-argumentPointer)){throw new Error('Warning: pack() Type '+instruction+': too few arguments');} 167for(i=0;i<quantifier;i++){result+=String.fromCharCode(arguments[argumentPointer]>>8&0xFF);result+=String.fromCharCode(arguments[argumentPointer]&0xFF);argumentPointer++;} 168break;case'i':case'I':case'l':case'L':case'V':if(quantifier==='*'){quantifier=arguments.length-argumentPointer;} 169if(quantifier>(arguments.length-argumentPointer)){throw new Error('Warning: pack() Type '+instruction+': too few arguments');} 170for(i=0;i<quantifier;i++){result+=String.fromCharCode(arguments[argumentPointer]&0xFF);result+=String.fromCharCode(arguments[argumentPointer]>>8&0xFF);result+=String.fromCharCode(arguments[argumentPointer]>>16&0xFF);result+=String.fromCharCode(arguments[argumentPointer]>>24&0xFF);argumentPointer++;} 171break;case'N':if(quantifier==='*'){quantifier=arguments.length-argumentPointer;} 172if(quantifier>(arguments.length-argumentPointer)){throw new Error('Warning: pack() Type '+instruction+': too few arguments');} 173for(i=0;i<quantifier;i++){result+=String.fromCharCode(arguments[argumentPointer]>>24&0xFF);result+=String.fromCharCode(arguments[argumentPointer]>>16&0xFF);result+=String.fromCharCode(arguments[argumentPointer]>>8&0xFF);result+=String.fromCharCode(arguments[argumentPointer]&0xFF);argumentPointer++;} 174break;case'f':case'd':precisionBits=23;exponentBits=8;if(instruction==='d'){precisionBits=52;exponentBits=11;} 175if(quantifier==='*'){quantifier=arguments.length-argumentPointer;} 176if(quantifier>(arguments.length-argumentPointer)){throw new Error('Warning: pack() Type '+instruction+': too few arguments');} 177for(i=0;i<quantifier;i++){argument=arguments[argumentPointer];bias=Math.pow(2,exponentBits-1)-1;minExp=-bias+1;maxExp=bias;minUnnormExp=minExp-precisionBits;status=isNaN(n=parseFloat(argument))||n===-Infinity||n===+Infinity?n:0;exp=0;len=2*bias+1+precisionBits+3;bin=new Array(len);signal=(n=status!==0?0:n)<0;n=Math.abs(n);intPart=Math.floor(n);floatPart=n-intPart;for(k=len;k;){bin[--k]=0;} 178for(k=bias+2;intPart&&k;){bin[--k]=intPart%2;intPart=Math.floor(intPart/2);} 179for(k=bias+1;floatPart>0&&k;--floatPart){(bin[++k]=((floatPart*=2)>=1)-0);} 180for(k=-1;++k<len&&!bin[k];){} 181if(bin[(lastBit=precisionBits-1+(k=(exp=bias+1-k)>=minExp&&exp<=maxExp?k+1:bias+1-(exp=minExp-1)))+1]){if(!(rounded=bin[lastBit])){for(j=lastBit+2;!rounded&&j<len;rounded=bin[j++]){}} 182for(j=lastBit+1;rounded&&--j>=0;(bin[j]=!bin[j]-0)&&(rounded=0)){}} 183for(k=k-2<0?-1:k-3;++k<len&&!bin[k];){} 184if((exp=bias+1-k)>=minExp&&exp<=maxExp){++k;}else{if(exp<minExp){if(exp!==bias+1-len&&exp<minUnnormExp){} 185k=bias+1-(exp=minExp-1);}} 186if(intPart||status!==0){exp=maxExp+1;k=bias+2;if(status===-Infinity){signal=1;}else if(isNaN(status)){bin[k]=1;}} 187n=Math.abs(exp+bias);tmpResult='';for(j=exponentBits+1;--j;){tmpResult=(n%2)+tmpResult;n=n>>=1;} 188n=0;j=0;k=(tmpResult=(signal?'1':'0')+tmpResult+bin.slice(k,k+precisionBits).join('')).length;r=[];for(;k;){n+=(1<<j)*tmpResult.charAt(--k);if(j===7){r[r.length]=String.fromCharCode(n);n=0;} 189j=(j+1)%8;} 190r[r.length]=n?String.fromCharCode(n):'';result+=r.join('');argumentPointer++;} 191break;case'x':if(quantifier==='*'){throw new Error('Warning: pack(): Type x: \'*\' ignored');} 192for(i=0;i<quantifier;i++){result+=String.fromCharCode(0);} 193break;case'X':if(quantifier==='*'){throw new Error('Warning: pack(): Type X: \'*\' ignored');} 194for(i=0;i<quantifier;i++){if(result.length===0){throw new Error('Warning: pack(): Type X:'+' outside of string');}else{result=result.substring(0,result.length-1);}} 195break;case'@':if(quantifier==='*'){throw new Error('Warning: pack(): Type X: \'*\' ignored');} 196if(quantifier>result.length){extraNullCount=quantifier-result.length;for(i=0;i<extraNullCount;i++){result+=String.fromCharCode(0);}} 197if(quantifier<result.length){result=result.substring(0,quantifier);} 198break;default:throw new Error('Warning: pack() Type '+instruction+': unknown format code');}} 199if(argumentPointer<arguments.length){throw new Error('Warning: pack(): '+(arguments.length-argumentPointer)+' arguments unused');} 200return result;} 201function utf8_decode(str_data){var tmp_arr=[],i=0,ac=0,c1=0,c2=0,c3=0;str_data+='';while(i<str_data.length){c1=str_data.charCodeAt(i);if(c1<128){tmp_arr[ac++]=String.fromCharCode(c1);i++;}else if(c1>191&&c1<224){c2=str_data.charCodeAt(i+1);tmp_arr[ac++]=String.fromCharCode(((c1&31)<<6)|(c2&63));i+=2;}else{c2=str_data.charCodeAt(i+1);c3=str_data.charCodeAt(i+2);tmp_arr[ac++]=String.fromCharCode(((c1&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}} 202return tmp_arr.join('');} 203function utf8_encode(argString){if(argString===null||typeof argString==="undefined"){return"";} 204var string=(argString+'');var utftext="",start,end,stringl=0;start=end=0;stringl=string.length;for(var n=0;n<stringl;n++){var c1=string.charCodeAt(n);var enc=null;if(c1<128){end++;}else if(c1>127&&c1<2048){enc=String.fromCharCode((c1>>6)|192)+String.fromCharCode((c1&63)|128);}else{enc=String.fromCharCode((c1>>12)|224)+String.fromCharCode(((c1>>6)&63)|128)+String.fromCharCode((c1&63)|128);} 205if(enc!==null){if(end>
205start){utftext+=string.slice(start,end);} 206utftext+=enc;start=end=n+1;}} 207if(end>start){utftext+=string.slice(start,stringl);} 208return utftext;} 209 210// SPRINTF() 211function sprintf () { 212 // http://kevin.vanzonneveld.net 213 // + original by: Ash Searle (http://hexmen.com/blog/) 214 // + namespaced by: Michael White (http://getsprink.com) 215 // + tweaked by: Jack 216 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 217 // + input by: Paulo Freitas 218 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 219 // + input by: Brett Zamir (http://brett-zamir.me) 220 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 221 // * example 1: sprintf("%01.2f", 123.1); 222 // * returns 1: 123.10 223 // * example 2: sprintf("[%10s]", 'monkey'); 224 // * returns 2: '[ monkey]' 225 // * example 3: sprintf("[%'#10s]", 'monkey'); 226 // * returns 3: '[####monkey]' 227 var regex = /%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuidfegEG])/g; 228 var a = arguments, 229 i = 0, 230 format = a[i++]; 231 232 // pad() 233 var pad = function (str, len, chr, leftJustify) { 234 if (!chr) { 235 chr = ' '; 236 } 237 var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr); 238 return leftJustify ? str + padding : padding + str; 239 }; 240 241 // justify() 242 var justify = function (value, prefix, leftJustify, minWidth, zeroPad, customPadChar) { 243 var diff = minWidth - value.length; 244 if (diff > 0) { 245 if (leftJustify || !zeroPad) { 246 value = pad(value, minWidth, customPadChar, leftJustify); 247 } else { 248 value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length); 249 } 250 } 251 return value; 252 }; 253 254 // formatBaseX() 255 var formatBaseX = function (value, base, prefix, leftJustify, minWidth, precision, zeroPad) { 256 // Note: casts negative numbers to positive ones 257 var number = value >>> 0; 258 prefix = prefix && number && { 259 '2': '0b', 260 '8': '0', 261 '16': '0x' 262 }[base] || ''; 263 value = prefix + pad(number.toString(base), precision || 0, '0', false); 264 return justify(value, prefix, leftJustify, minWidth, zeroPad); 265 }; 266 267 // formatString() 268 var formatString = function (value, leftJustify, minWidth, precision, zeroPad, customPadChar) { 269 if (precision != null) { 270 value = value.slice(0, precision); 271 } 272 return justify(value, '', leftJustify, minWidth, zeroPad, customPadChar); 273 }; 274 275 // doFormat() 276 var doFormat = function (substring, valueIndex, flags, minWidth, _, precision, type) { 277 var number; 278 var prefix; 279 var method; 280 var textTransform; 281 var value; 282 283 if (substring == '%%') { 284 return '%'; 285 } 286 287 // parse flags 288 var leftJustify = false, 289 positivePrefix = '', 290 zeroPad = false, 291 prefixBaseX = false, 292 customPadChar = ' '; 293 var flagsl = flags.length; 294 for (var j = 0; flags && j < flagsl; j++) { 295 switch (flags.charAt(j)) { 296 case ' ': 297 positivePrefix = ' '; 298 break; 299 case '+': 300 positivePrefix = '+'; 301 break; 302 case '-': 303 leftJustify = true; 304 break; 305 case "'": 306 customPadChar = flags.charAt(j + 1); 307 break; 308 case '0': 309 zeroPad = true; 310 break; 311 case '#': 312 prefixBaseX = true; 313 break; 314 } 315 } 316 317 // parameters may be null, undefined, empty-string or real valued 318 // we want to ignore null, undefined and empty-string values 319 if (!minWidth) { 320 minWidth = 0; 321 } else if (minWidth == '*') { 322 minWidth = +a[i++]; 323 } else if (minWidth.charAt(0) == '*') { 324 minWidth = +a[minWidth.slice(1, -1)]; 325 } else { 326 minWidth = +minWidth; 327 } 328 329 // Note: undocumented perl feature: 330 if (minWidth < 0) { 331 minWidth = -minWidth; 332 leftJustify = true; 333 } 334 335 if (!isFinite(minWidth)) { 336 throw new Error('sprintf: (minimum-)width must be finite'); 337 } 338 339 if (!precision) { 340 precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : undefined; 341 } else if (precision == '*') { 342 precision = +a[i++]; 343 } else if (precision.charAt(0) == '*') { 344 precision = +a[precision.slice(1, -1)]; 345 } else { 346 precision = +precision; 347 } 348 349 // grab value using valueIndex if required? 350 value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++]; 351 352 switch (type) { 353 case 's': 354 return formatString(String(value), leftJustify, minWidth, precision, zeroPad, customPadChar); 355 case 'c': 356 return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad); 357 case 'b': 358 return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad); 359 case 'o': 360 return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad); 361 case 'x': 362 return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad); 363 case 'X': 364 return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad).toUpperCase(); 365 case 'u': 366 return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad); 367 case 'i': 368 case 'd': 369 number = (+value) | 0; 370 prefix = number < 0 ? '-' : positivePrefix; 371 value = prefix + pad(String(Math.abs(number)), precision, '0', false); 372 return justify(value, prefix, leftJustify, minWidth, zeroPad); 373 case 'e': 374 case 'E': 375 case 'f': 376 case 'F': 377 case 'g': 378 case 'G': 379 number = +value; 380 prefix = number < 0 ? '-' : positivePrefix; 381 method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())]; 382 textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2]; 383 value = prefix + Math.abs(number)[method](precision); 384 return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform](); 385 default: 386 return substring; 387 } 388 }; 389 390 return format.replace(regex, doFormat); 391} 392 393// PARSE_URL() 394function parse_url (str, component) { 395 // http://kevin.vanzonneveld.net 396 // + original by: Steven Levithan (http://blog.stevenlevithan.com) 397 // + reimplemented by: Brett Zamir (http://brett-zamir.me) 398 // + input by: Lorenzo Pisani 399 // + input by: Tony 400 // + improved by: Brett Zamir (http://brett-zamir.me) 401 // % note: Based on http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js 402 // % note: blog post at http://blog.stevenlevithan.com/archives/parseuri 403 // % note: demo at http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js 404 // % note: Does not replace invalid characters with '_' as in PHP, nor does it return false with 405 // % note: a seriously malformed URL. 406 // % note: Besides function name, is essentially the same as parseUri as well as our allowing 407 // % note: an extra slash after the scheme/protocol (to allow file:/// as in PHP) 408 // * example 1: parse_url('http://username:password@hostname/path?arg=value#anchor'); 409 // * returns 1: {scheme: 'http', host: 'hostname', user: 'username', pass: 'password', path: '/path', query: 'arg=value', fragment: 'anchor'} 410 var key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port', 411 'relative', 'path', 'directory', 'file', 'query', 'fragment'], 412 ini = (this.php_js && this.php_js.ini) || {}, 413 mode = (ini['phpjs.parse_url.mode'] && 414 ini['phpjs.parse_url.mode'].local_value) || 'php', 415 parser = { 416 php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
417 strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, 418 loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this) 419 }; 420 421 var m = parser[mode].exec(str), 422 uri = {}, 423 i = 14; 424 while (i--) { 425 if (m[i]) { 426 uri[key[i]] = m[i]; 427 } 428 } 429 430 if (component) { 431 return uri[component.replace('PHP_URL_', '').toLowerCase()]; 432 } 433 if (mode !== 'php') { 434 var name = (ini['phpjs.parse_url.queryKey'] && 435 ini['phpjs.parse_url.queryKey'].local_value) || 'queryKey'; 436 parser = /(?:^|&)([^&=]*)=?([^&]*)/g; 437 uri[name] = {}; 438 uri[key[12]].replace(parser, function ($0, $1, $2) { 439 if ($1) {uri[name][$1] = $2;} 440 }); 441 } 442 delete uri.source; 443 return uri; 444}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.