diff --git a/install/css/install.css b/install/css/install.css
new file mode 100644
index 000000000..58210adee
--- /dev/null
+++ b/install/css/install.css
@@ -0,0 +1,106 @@
+body{
+width: 1000px;
+margin-left: auto;
+margin-right: auto;
+background-image: url(../../includes/images/canevas/bg_home.jpg);
+font-family: sans-serif;
+font-size:11pt;
+}
+
+#top{
+width: 1000px;
+height: 35px;
+margin-left: auto;
+margin-right: auto;
+padding: 10px;
+font-family: sans-serif;
+font-size: 10px;
+display:block;
+}
+
+#title {
+ font: bold 270%/100% "Lucida Grande";
+ color: #464646;
+ float:left;
+ margin-top:3px;
+}
+
+#main {
+ width: 1000px;
+ margin-top:15px;
+ margin-left: auto;
+ margin-right: auto;
+ background-color:white;
+ color:#464646;
+ height:90%;
+ overflow:hidden;
+ padding:10px;
+ display:block;
+ height:100%;
+}
+
+#menu {
+ float: left;
+ width: 25%;
+ margin-left:-20px;
+ height:100%;
+}
+
+#menu li {
+ margin-top:5px;
+}
+
+.li_inprogress {
+ font-weight: bold;
+ color: #5283BB;
+}
+
+.li_done {
+ font-weight: normal;
+ color: #464646;
+}
+
+#content {
+ float:left;
+ width: 75%;
+ height:100%;
+}
+
+#step_name {
+ font-weight: bold;
+ text-align: center;
+ font-size: 15px;
+}
+
+#step_content {
+ margin-top: 10px;
+}
+
+#action_buttons {
+ width: 1000px;
+ padding: 10px;
+ margin:0 auto 0 auto;
+ background-color:white;
+ color:#464646;
+ height: 30px;
+ text-align: right;
+}
+h5 {
+ margin-bottom: 10px;
+}
+
+.label_block {
+ display: inline-block;
+ width: 200px;
+ margin-bottom: 2px;
+}
+
+.label_block_big {
+ display: inline-block;
+ width: 270px;
+ margin-bottom: 2px;
+}
+
+.hidden {
+ display: none;
+}
\ No newline at end of file
diff --git a/install/css/overcast/images/animated-overlay.gif b/install/css/overcast/images/animated-overlay.gif
new file mode 100644
index 000000000..d441f75eb
Binary files /dev/null and b/install/css/overcast/images/animated-overlay.gif differ
diff --git a/install/css/overcast/images/ui-bg_flat_0_aaaaaa_40x100.png b/install/css/overcast/images/ui-bg_flat_0_aaaaaa_40x100.png
new file mode 100644
index 000000000..414803b7e
Binary files /dev/null and b/install/css/overcast/images/ui-bg_flat_0_aaaaaa_40x100.png differ
diff --git a/install/css/overcast/images/ui-bg_flat_0_eeeeee_40x100.png b/install/css/overcast/images/ui-bg_flat_0_eeeeee_40x100.png
new file mode 100644
index 000000000..93120f5fd
Binary files /dev/null and b/install/css/overcast/images/ui-bg_flat_0_eeeeee_40x100.png differ
diff --git a/install/css/overcast/images/ui-bg_flat_55_c0402a_40x100.png b/install/css/overcast/images/ui-bg_flat_55_c0402a_40x100.png
new file mode 100644
index 000000000..7e0695656
Binary files /dev/null and b/install/css/overcast/images/ui-bg_flat_55_c0402a_40x100.png differ
diff --git a/install/css/overcast/images/ui-bg_flat_55_eeeeee_40x100.png b/install/css/overcast/images/ui-bg_flat_55_eeeeee_40x100.png
new file mode 100644
index 000000000..f92fcfdff
Binary files /dev/null and b/install/css/overcast/images/ui-bg_flat_55_eeeeee_40x100.png differ
diff --git a/install/css/overcast/images/ui-bg_glass_100_f8f8f8_1x400.png b/install/css/overcast/images/ui-bg_glass_100_f8f8f8_1x400.png
new file mode 100644
index 000000000..5faa7443d
Binary files /dev/null and b/install/css/overcast/images/ui-bg_glass_100_f8f8f8_1x400.png differ
diff --git a/install/css/overcast/images/ui-bg_glass_35_dddddd_1x400.png b/install/css/overcast/images/ui-bg_glass_35_dddddd_1x400.png
new file mode 100644
index 000000000..7f16ad905
Binary files /dev/null and b/install/css/overcast/images/ui-bg_glass_35_dddddd_1x400.png differ
diff --git a/install/css/overcast/images/ui-bg_glass_60_eeeeee_1x400.png b/install/css/overcast/images/ui-bg_glass_60_eeeeee_1x400.png
new file mode 100644
index 000000000..5f2c14a1a
Binary files /dev/null and b/install/css/overcast/images/ui-bg_glass_60_eeeeee_1x400.png differ
diff --git a/install/css/overcast/images/ui-bg_inset-hard_75_999999_1x100.png b/install/css/overcast/images/ui-bg_inset-hard_75_999999_1x100.png
new file mode 100644
index 000000000..88a85630e
Binary files /dev/null and b/install/css/overcast/images/ui-bg_inset-hard_75_999999_1x100.png differ
diff --git a/install/css/overcast/images/ui-bg_inset-soft_50_c9c9c9_1x100.png b/install/css/overcast/images/ui-bg_inset-soft_50_c9c9c9_1x100.png
new file mode 100644
index 000000000..d11e1ba19
Binary files /dev/null and b/install/css/overcast/images/ui-bg_inset-soft_50_c9c9c9_1x100.png differ
diff --git a/install/css/overcast/images/ui-icons_3383bb_256x240.png b/install/css/overcast/images/ui-icons_3383bb_256x240.png
new file mode 100644
index 000000000..af7039ded
Binary files /dev/null and b/install/css/overcast/images/ui-icons_3383bb_256x240.png differ
diff --git a/install/css/overcast/images/ui-icons_454545_256x240.png b/install/css/overcast/images/ui-icons_454545_256x240.png
new file mode 100644
index 000000000..d17a92766
Binary files /dev/null and b/install/css/overcast/images/ui-icons_454545_256x240.png differ
diff --git a/install/css/overcast/images/ui-icons_70b2e1_256x240.png b/install/css/overcast/images/ui-icons_70b2e1_256x240.png
new file mode 100644
index 000000000..aa5282eb9
Binary files /dev/null and b/install/css/overcast/images/ui-icons_70b2e1_256x240.png differ
diff --git a/install/css/overcast/images/ui-icons_999999_256x240.png b/install/css/overcast/images/ui-icons_999999_256x240.png
new file mode 100644
index 000000000..675b2648f
Binary files /dev/null and b/install/css/overcast/images/ui-icons_999999_256x240.png differ
diff --git a/install/css/overcast/images/ui-icons_fbc856_256x240.png b/install/css/overcast/images/ui-icons_fbc856_256x240.png
new file mode 100644
index 000000000..616135553
Binary files /dev/null and b/install/css/overcast/images/ui-icons_fbc856_256x240.png differ
diff --git a/install/css/overcast/jquery-ui-1.10.3.custom.min.css b/install/css/overcast/jquery-ui-1.10.3.custom.min.css
new file mode 100644
index 000000000..8bf80e7fc
--- /dev/null
+++ b/install/css/overcast/jquery-ui-1.10.3.custom.min.css
@@ -0,0 +1,5 @@
+/*! jQuery UI - v1.10.3 - 2013-07-15
+* http://jqueryui.com
+* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
+* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS%2CHelvetica%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=dddddd&bgTextureHeader=glass&bgImgOpacityHeader=35&borderColorHeader=bbbbbb&fcHeader=444444&iconColorHeader=999999&bgColorContent=c9c9c9&bgTextureContent=inset_soft&bgImgOpacityContent=50&borderColorContent=aaaaaa&fcContent=333333&iconColorContent=999999&bgColorDefault=eeeeee&bgTextureDefault=glass&bgImgOpacityDefault=60&borderColorDefault=cccccc&fcDefault=3383bb&iconColorDefault=70b2e1&bgColorHover=f8f8f8&bgTextureHover=glass&bgImgOpacityHover=100&borderColorHover=bbbbbb&fcHover=599fcf&iconColorHover=3383bb&bgColorActive=999999&bgTextureActive=inset_hard&bgImgOpacityActive=75&borderColorActive=999999&fcActive=ffffff&iconColorActive=454545&bgColorHighlight=eeeeee&bgTextureHighlight=flat&bgImgOpacityHighlight=55&borderColorHighlight=ffffff&fcHighlight=444444&iconColorHighlight=3383bb&bgColorError=c0402a&bgTextureError=flat&bgImgOpacityError=55&borderColorError=c0402a&fcError=ffffff&iconColorError=fbc856&bgColorOverlay=eeeeee&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=80&bgColorShadow=aaaaaa&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=60&thicknessShadow=4px&offsetTopShadow=-4px&offsetLeftShadow=-4px&cornerRadiusShadow=0px
+* Copyright 2013 jQuery Foundation and other contributors Licensed MIT */.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted #000}.ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin-top:2px;padding:.5em .5em .5em .7em;min-height:0}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-noicons{padding-left:.7em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-button{display:inline-block;position:relative;padding:0;line-height:normal;margin-right:.1em;cursor:pointer;vertical-align:middle;text-align:center;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:normal}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}input.ui-button::-moz-focus-inner,button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:0.9em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:700;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-dialog{position:absolute;top:0;left:0;padding:.2em;outline:0}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 0;white-space:nowrap;width:90%;overflow:hidden;text-overflow:ellipsis}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:21px;margin:-10px 0 0 0;padding:1px;height:20px}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:0;overflow:auto}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0;background-image:none;margin-top:.5em;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:12px;height:12px;right:-5px;bottom:-5px;background-position:16px 16px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-menu{list-style:none;padding:2px;margin:0;display:block;outline:0}.ui-menu .ui-menu{margin-top:-3px;position:absolute}.ui-menu .ui-menu-item{margin:0;padding:0;width:100%;list-style-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}.ui-menu .ui-menu-divider{margin:5px -2px 5px -2px;height:0;font-size:0;line-height:0;border-width:1px 0 0}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:2px .4em;line-height:1.5;min-height:0;font-weight:400}.ui-menu .ui-menu-item a.ui-state-focus,.ui-menu .ui-menu-item a.ui-state-active{font-weight:400;margin:-1px}.ui-menu .ui-state-disabled{font-weight:400;margin:.4em 0 .2em;line-height:1.5}.ui-menu .ui-state-disabled a{cursor:default}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item a{position:relative;padding-left:2em}.ui-menu .ui-icon{position:absolute;top:.2em;left:.2em}.ui-menu .ui-menu-icon{position:static;float:right}.ui-progressbar{height:2em;text-align:left;overflow:hidden}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-progressbar-overlay{background:url(images/animated-overlay.gif);height:100%;filter:alpha(opacity=25);opacity:.25}.ui-progressbar-indeterminate .ui-progressbar-value{background-image:none}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider.ui-state-disabled .ui-slider-handle,.ui-slider.ui-state-disabled .ui-slider-range{filter:inherit}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-spinner{position:relative;display:inline-block;overflow:hidden;padding:0;vertical-align:middle}.ui-spinner-input{border:0;background:0;color:inherit;padding:0;margin:.2em 0;vertical-align:middle;margin-left:.4em;margin-right:22px}.ui-spinner-button{width:16px;height:50%;font-size:.5em;padding:0;margin:0;text-align:center;position:absolute;cursor:default;display:block;overflow:hidden;right:0}.ui-spinner a.ui-spinner-button{border-top:0;border-bottom:0;border-right:0}.ui-spinner .ui-icon{position:absolute;margin-top:-8px;top:50%;left:0}.ui-spinner-up{top:0}.ui-spinner-down{bottom:0}.ui-spinner .ui-icon-triangle-1-s{background-position:-65px -16px}.ui-tabs{position:relative;padding:.2em}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:0;margin:1px .2em 0 0;border-bottom-width:0;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-active{margin-bottom:-1px;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-active a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-tabs-loading a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:0}.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}body .ui-tooltip{border-width:2px}.ui-widget{font-family:Trebuchet MS,Helvetica,Arial,sans-serif;font-size:0.9em}.ui-widget .ui-widget{font-size:0.9em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Trebuchet MS,Helvetica,Arial,sans-serif;font-size:0.9em}.ui-widget-content{border:1px solid #aaa;background:#c9c9c9 url(images/ui-bg_inset-soft_50_c9c9c9_1x100.png) 50% bottom repeat-x;color:#333}.ui-widget-content a{color:#333}.ui-widget-header{border:1px solid #bbb;background:#ddd url(images/ui-bg_glass_35_dddddd_1x400.png) 50% 50% repeat-x;color:#444;font-weight:bold}.ui-widget-header a{color:#444}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #ccc;background:#eee url(images/ui-bg_glass_60_eeeeee_1x400.png) 50% 50% repeat-x;font-weight:bold;color:#3383bb}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#3383bb;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #bbb;background:#f8f8f8 url(images/ui-bg_glass_100_f8f8f8_1x400.png) 50% 50% repeat-x;font-weight:bold;color:#599fcf}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited{color:#599fcf;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #999;background:#999 url(images/ui-bg_inset-hard_75_999999_1x100.png) 50% 50% repeat-x;font-weight:bold;color:#fff}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#fff;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #fff;background:#eee url(images/ui-bg_flat_55_eeeeee_40x100.png) 50% 50% repeat-x;color:#444}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#444}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #c0402a;background:#c0402a url(images/ui-bg_flat_55_c0402a_40x100.png) 50% 50% repeat-x;color:#fff}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#fff}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#fff}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px}.ui-icon,.ui-widget-content .ui-icon{background-image:url(images/ui-icons_999999_256x240.png)}.ui-widget-header .ui-icon{background-image:url(images/ui-icons_999999_256x240.png)}.ui-state-default .ui-icon{background-image:url(images/ui-icons_70b2e1_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(images/ui-icons_3383bb_256x240.png)}.ui-state-active .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(images/ui-icons_3383bb_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(images/ui-icons_fbc856_256x240.png)}.ui-icon-blank{background-position:16px 16px}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:6px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:6px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:6px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:6px}.ui-widget-overlay{background:#eee url(images/ui-bg_flat_0_eeeeee_40x100.png) 50% 50% repeat-x;opacity:.8;filter:Alpha(Opacity=80)}.ui-widget-shadow{margin:-4px 0 0 -4px;padding:4px;background:#aaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.6;filter:Alpha(Opacity=60);border-radius:0}
\ No newline at end of file
diff --git a/install/images/76.gif b/install/images/76.gif
new file mode 100644
index 000000000..5a7d542e0
Binary files /dev/null and b/install/images/76.gif differ
diff --git a/install/images/ajax-loader.gif b/install/images/ajax-loader.gif
new file mode 100644
index 000000000..0dae02306
Binary files /dev/null and b/install/images/ajax-loader.gif differ
diff --git a/install/images/cross.png b/install/images/cross.png
new file mode 100644
index 000000000..1514d51a3
Binary files /dev/null and b/install/images/cross.png differ
diff --git a/install/images/error.png b/install/images/error.png
new file mode 100644
index 000000000..628cf2dae
Binary files /dev/null and b/install/images/error.png differ
diff --git a/install/images/exclamation-red.png b/install/images/exclamation-red.png
new file mode 100644
index 000000000..517725822
Binary files /dev/null and b/install/images/exclamation-red.png differ
diff --git a/install/images/information-white.png b/install/images/information-white.png
new file mode 100644
index 000000000..bd4f552a8
Binary files /dev/null and b/install/images/information-white.png differ
diff --git a/install/images/minus-circle.png b/install/images/minus-circle.png
new file mode 100644
index 000000000..0cd0ca2ba
Binary files /dev/null and b/install/images/minus-circle.png differ
diff --git a/install/images/tick-circle.png b/install/images/tick-circle.png
new file mode 100644
index 000000000..210b1a6c3
Binary files /dev/null and b/install/images/tick-circle.png differ
diff --git a/install/images/tick.png b/install/images/tick.png
new file mode 100644
index 000000000..2414885b8
Binary files /dev/null and b/install/images/tick.png differ
diff --git a/install/install.css b/install/install.css
new file mode 100644
index 000000000..b3ea206ba
--- /dev/null
+++ b/install/install.css
@@ -0,0 +1,88 @@
+body{
+width: 1000px;
+margin-left: auto;
+margin-right: auto;
+background-image: url(../includes/images/canevas/bg_home.jpg);
+font-family: sans-serif;
+font-size:12pt;
+}
+
+#top{
+width: 980px;
+height: 35px;
+margin-left: auto;
+margin-right: auto;
+padding: 10px;
+font-family: sans-serif;
+font-size: 10px;
+display:block;
+}
+
+#logo{
+ float:left;
+ margin-right: 5px;
+ margin-top: -5px;
+}
+
+#title {
+ font: bold 270%/100% "Lucida Grande";
+ color: #464646;
+ float:left;
+ margin-top:3px;
+}
+
+div#content {
+margin-top:15px;
+position: relative;
+}
+
+div#center {
+padding:20px;
+padding-bottom: 50px;
+background-color:white;
+display: block;
+color:#464646;
+}
+
+label{
+width:150px;
+display:block;
+float:left;
+font-size:12pt;
+font-weight:bold;
+}
+
+.step{
+font-size:14pt;
+padding:2px;
+width:400px;
+margin-bottom: 3px;
+margin-top: 3px;
+}
+
+fieldset{
+margin:15px;
+}
+
+legend{
+margin-bottom: 5px;
+}
+
+#buttons_bottom{
+float:right;
+width:200px;
+text-align:right;
+}
+
+#footer{
+width: 980px;
+height: 26px;
+line-height: 26px;
+valign: middle;
+margin: 10px auto 0 auto;
+padding: 10px;
+background-image: url(../includes/images/canevas/footer_all.png);
+font-family: sans-serif;
+font-size: 10px;
+color: #F0F0F0;
+}
\ No newline at end of file
diff --git a/install/install.js b/install/install.js
new file mode 100644
index 000000000..33d51cd7f
--- /dev/null
+++ b/install/install.js
@@ -0,0 +1,263 @@
+/**
+ * @file install.js
+ * @author Nils Laumaillé
+ * @version 2.1.27
+ * @copyright (c) 2009-2011 Nils Laumaillé
+ * @licensing GNU AFFERO GPL 3.0
+ * @link http://www.teampass.net
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+$(function() {
+ $(".button").button();
+ $("#but_launch, #step_error, #but_restart").addClass("hidden");
+ $("#but_launch").prop("disabled", true);
+
+ // no paste
+ $("#admin_pwd").bind("paste",function(e) {
+ alert("Paste option is disabled !!");
+ e.preventDefault();
+ });
+});
+
+function aesEncrypt(text)
+{
+ return Aes.Ctr.encrypt(text, "cpm", 128);
+}
+
+function checkPage()
+{
+ var step = $("#page_id").val();
+ var data = "";
+ var error = "";
+ var index = "";
+ var tasks = [];
+ var multiple = "";
+ var tsk = "";
+ $("#step_error").addClass("hidden").html("");
+ $("#res_"+step).html("");
+
+ if (step === "2") {
+ // STEP 2
+ if ($("#url_path").val() === "" || $("#root_path").val() === "") {
+ error = "Fields need to be filled in!";
+ } else {
+ const jsonValues = {"root_path":$("#root_path").val(), "url_path":$("#url_path").val()};
+ data = JSON.stringify(jsonValues);
+ tasks = ["folder*install", "folder*includes", "folder*includes/config", "folder*includes/avatars", "folder*includes/libraries/csrfp/libs", "folder*includes/libraries/csrfp/js", "folder*includes/libraries/csrfp/log", "folder*files", "folder*upload", "extension*mcrypt", "extension*mbstring", "extension*openssl", "extension*bcmath", "extension*iconv", "extension*gd", "extension*xml", "extension*curl", "version*php", "ini*max_execution_time"];
+ multiple = true;
+ $("#hid_abspath").val($("#root_path").val());
+ $("#hid_url_path").val($("#url_path").val());
+ }
+ } else if (step === "3") {
+ // STEP 3
+ if ($("#db_host").val() === "" || $("#db_db").val() === "" || $("#db_login").val() === "" || $("#db_port").val() === "") {
+ error = "Paths need to be filled in!";
+ } else if ($("#db_pw").val().indexOf('"') > -1) {
+ error = "Double quotes in password not allowed!";
+ } else {
+ const jsonValues = {"db_host":$("#db_host").val(), "db_bdd":$("#db_bdd").val(), "db_login":$("#db_login").val(), "db_pw":$("#db_pw").val(), "db_port":$("#db_port").val(), "abspath":$("#hid_abspath").val(), "url_path":$("#hid_url_path").val()};
+ data = JSON.stringify(jsonValues);
+ tasks = ["connection*test"];
+ multiple = "";
+ $("#hid_db_host").val($("#db_host").val());
+ $("#hid_db_bdd").val($("#db_bdd").val());
+ $("#hid_db_login").val($("#db_login").val());
+ $("#hid_db_pwd").val($("#db_pw").val());
+ $("#hid_db_port").val($("#db_port").val());
+ }
+ } else if (step === "4") {
+ // STEP 4
+ if ($("#admin_pwd").val() === "") {
+ error = "You must define a password for Admin account!";
+ } else{
+ $("#hid_db_pre").val($("#tbl_prefix").val());
+ const jsonValues = {"tbl_prefix":sanitizeString($("#tbl_prefix").val()), "sk_path":sanitizeString($("#sk_path").val()), "admin_pwd":sanitizeString($("#admin_pwd").val()), "send_stats":""};
+ data = JSON.stringify(jsonValues);
+ tasks = ["misc*preparation"];
+ multiple = "";
+ }
+ } else if (step === "5") {
+ // STEP 5
+ data = "";
+ tasks = ["table*utf8", "table*items", "table*log_items", "table*misc", "table*nested_tree", "table*rights", "table*users", "table*tags", "table*log_system", "table*files", "table*cache", "table*roles_title", "table*roles_values", "table*kb", "table*kb_categories", "table*kb_items", "table*restriction_to_roles", "table*languages", "table*emails", "table*automatic_del", "table*items_edition", "table*categories", "table*categories_items", "table*categories_folders", "table*api", "table*otv", "table*suggestion", "table*tokens", "table*items_change"];
+ multiple = true;
+ } else if (step === "6") {
+ // STEP 6
+ const jsonValues = {"url_path":sanitizeString($("#hid_url_path").val())};
+ data = JSON.stringify(jsonValues);
+ tasks = ["file*sk.php", "file*security", "install*cleanup", "file*settings.php", "file*csrfp-token"];
+ multiple = true;
+ }
+
+ // launch query
+ if (error === "" && multiple === true) {
+ var ajaxReqs = [];
+
+ const dbInfo = {"db_host" : $("#hid_db_host").val(), "db_bdd" : $("#hid_db_bdd").val(), "db_login" : $("#hid_db_login").val(), "db_pw" : $("#hid_db_pwd").val(), "db_port" : $("#hid_db_port").val(), "db_pre" : $("#hid_db_pre").val()};
+
+ $("#step_result").html("Please wait ");
+ $("#step_res").val("true");
+ $("#pop_db").html("");
+
+ for (index = 0; index < tasks.length; ++index) {
+ tsk = tasks[index].split("*");
+ ajaxReqs.push($.ajax({
+ url: "install.queries.php",
+ type : "POST",
+ dataType : "json",
+ data : {
+ type: "step_"+step,
+ data: aesEncrypt(data), //
+ activity: aesEncrypt(tsk[0]),
+ task: aesEncrypt(tsk[1]),
+ db: aesEncrypt(JSON.stringify(dbInfo)),
+ index: index,
+ multiple: multiple,
+ info: tsk[0]+"-"+tsk[1]
+ },
+ complete : function(data){
+ if (data.responseText === "") {
+ // stop error occured, PHP5.5 installed?
+ $("#step_result").html("[ERROR] Answer from server is empty.");
+ } else {
+ data = $.parseJSON(data.responseText);
+ if (data[0].error === "") {
+ if (step === "5") {
+ if (data[0].activity === "table") {
+ $("#pop_db").append("
Table "+data[0].task+" created ");
+ } else if (data[0].activity === "entry") {
+ $("#pop_db").append("Entries "+data[0].task+" were added ");
+ }
+ } else {
+ $("#res"+step+"_check"+data[0].index).html(" ");
+ }
+
+ if (data[0].result !== undefined && data[0].result !== "" ) {
+ $("#step_result").html(data[0].result);
+ }
+ } else {
+ // ignore setting error if regarding setting permissions (step 6, index 2)
+ if (step+data[0].index !== "62") {
+ //$("#step_res").val("false");
+ }
+ $("#res"+step+"_check"+data[0].index).html(" "+data[0].error+" ");
+ $("#pop_db").append(" Error on task `"+data[0].activity+" > "+data[0].task+"` . "+data[0].error+" ");
+ if (data[0].result !== undefined && data[0].result !== "" ) {
+ $("#step_result").html(data[0].result);
+ }
+ }
+ }
+ }
+ }));
+ }
+ $.when.apply($, ajaxReqs).done(function(data) {
+ setTimeout(function(){
+ // all requests are complete
+ if ($("#step_res").val() === "false") {
+ $("#step_error").removeClass("hidden").html("At least one task has failed! Please correct and relaunch. ");
+ $("#res_"+step).html(" ");
+ } else {
+ $("#but_launch").prop("disabled", true);
+ $("#but_launch").addClass("hidden");
+ $("#but_next").prop("disabled", false);
+ $("#but_next").removeClass("hidden");
+ // Hide restart button at end of step 6 if successful
+ if (step === "6") {
+ $("#but_restart").prop("disabled", true);
+ $("#but_restart").addClass("hidden");
+ }
+ }
+ $("#step_result").html("");
+ }, 1000);
+ });
+ } else if (error === "" && multiple === "") {
+ $("#step_result").html("Please wait ");
+ tsk = tasks[0].split("*");
+
+ const dbInfo = {"db_host" : $("#hid_db_host").val(), "db_bdd" : $("#hid_db_bdd").val(), "db_login" : $("#hid_db_login").val(), "db_pw" : $("#hid_db_pwd").val(), "db_port" : $("#hid_db_port").val()};
+
+ $.ajax({
+ url: "install.queries.php",
+ type : 'POST',
+ dataType : "json",
+ data : {
+ type: "step_"+step,
+ data: aesEncrypt(data),
+ activity: aesEncrypt(tsk[0]),
+ task: aesEncrypt(tsk[1]),
+ db: aesEncrypt(JSON.stringify(dbInfo)),
+ index: index,
+ multiple: multiple,
+ info: tsk[0]+"-"+tsk[1]
+ },
+ complete : function(data){
+ data = $.parseJSON(data.responseText);
+ $("#step_result").html("");
+ if (data[0].error !== "" ) {
+ $("#step_error").removeClass("hidden").html("The next ERROR occurred: '"+data[0].error+"' Please correct and relaunch.");
+ $("#res_"+step).html(" ");
+ } else {
+ if (data[0].result !== undefined && data[0].result !== "" ) {
+ $("#step_result").html(""+data[0].result+" ");
+ }
+ $("#but_launch").prop("disabled", true);
+ $("#but_launch").addClass("hidden");
+ $("#but_next").prop("disabled", false);
+ $("#but_next").removeClass("hidden");
+ }
+ }
+ });
+ } else {
+ $("#step_error").removeClass("hidden").html(error);
+ }
+}
+
+
+function GotoNextStep()
+{
+ var step = $("#page_id").val();
+ var nextStep = parseInt(step)+1;
+
+ if (nextStep === 7) {
+ $("#but_restart, #but_next, #but_launch").addClass("hidden");
+ $("#but_start").addClass("hidden");
+ $("#step_result").html("").addClass("hidden");
+ $("#step_name").html($("#menu_step"+nextStep).html());
+ $("#step_content").html($("#text_step"+nextStep).html());
+ $("#menu_step"+step).switchClass("li_inprogress", "li_done");
+ $("#menu_step"+nextStep).switchClass("", "li_inprogress");
+ $("#res_"+step).html(" ");
+ } else {
+ $("#page_id").val(nextStep);
+ $("#but_launch").removeClass("hidden").prop("disabled", false);
+ $("#but_launch").removeClass("hidden");
+ $("#but_restart").removeClass("hidden");
+ $("#but_next").prop("disabled", true);
+ $("#but_next").addClass("hidden");
+ $("#menu_step"+step).switchClass("li_inprogress", "li_done");
+ $("#menu_step"+nextStep).switchClass("", "li_inprogress");
+ $("#res_"+step).html(" ");
+ $("#step_result").html("");
+ $("#step_name").html($("#menu_step"+nextStep).html());
+ $("#step_content").html($("#text_step"+nextStep).html());
+ $('#admin_pwd').live("paste",function(e) {
+ alert("Paste option is disabled !!");
+ e.preventDefault();
+ });
+ $("#admin_pwd").live("keypress", function(e){
+ var key = e.charCode || e.keyCode || 0;
+ // allow backspace, tab, delete, arrows, letters, numbers and keypad numbers ONLY
+ return (
+ key !== 39
+ );
+ });
+ // Auto start as required
+ if (nextStep === "5" || nextStep === "6" ) {
+ checkPage();
+ }
+ }
+}
diff --git a/install/install.php b/install/install.php
new file mode 100644
index 000000000..900e2ea04
--- /dev/null
+++ b/install/install.php
@@ -0,0 +1,302 @@
+
+
+
+
+
+ TeamPass Installation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ';
+ // # LOADER
+ echo '
+ ';
+ // # HEADER ##
+ echo '
+
+
+
+
+
Welcome
+
+
+
+ Before starting, be sure to:
+ - upload the complete package on the server,
+ - have the database connection information (*)
+
+
+
* Mysql database suggestions:
+ - create a new database (for example teampass),
+ - create a new mysql user (for example teampass_root),
+ - set full admin rights for this user on teampass database,
+ - allow access from localhost to the database
+
+ TeamPass is distributed under GNU AFFERO GPL licence.
+
+
+
+
+
+
+
+
+
+
+
+
+
';
+?>
+
+
+
+ Teampass instance information:
+
+
+ Following elements will be checked:
+
+ Directory "/install/" is writable
+ Directory "/includes/" is writable
+ Directory "/includes/config/" is writable
+ Directory "/includes/avatars/" is writable
+ Directory "/includes/libraries/csrfp/libs/" is writable
+ Directory "/includes/libraries/csrfp/js/" is writable
+ Directory "/includes/libraries/csrfp/log/" is writable
+ Directory "/files/" is writable
+ Directory "/upload/" is writable
+ PHP extension "mcrypt" is loaded
+ PHP extension "mbstring" is loaded
+ PHP extension "openssl" is loaded
+ PHP extension "bcmath" is loaded
+ PHP extension "iconv" is loaded
+ PHP extension "xml" is loaded
+ PHP extension "gd" is loaded
+ PHP extension "curl" is loaded
+ PHP version is greater or equal to 5.5.0
+ Execution time limit
+
+';
+
+echo '
+
+
Database information:
+
Database connection Information
+
+
';
+
+echo '
+';
+
+echo '
+
+
Now populating database
+
+
+
';
+
+
+echo '
+
+
Finalization:
+
+ Write the new setting.php file for your server configuration
+ Write the new sk.php file for data encryption
+ Change directory security permissions
+
+
';
+
+
+echo '
+
+
Thank you for installing Teampass .
+
+ The final step is now to move to the authentication page and start using Teampass .
+ The Administrator login is `admin `.
+
+ Its password is the one you have written during the installation process.
+
+
+ Please note that first page may be longer to load. Install files and folders will be deleted for security purpose.
+
+ In case warning "Install folder has to be removed!" is shown while login, this operation has failed and requires to be done manually.
+
+
+
+
';
+?>
diff --git a/install/install.queries.php b/install/install.queries.php
new file mode 100644
index 000000000..133327ecb
--- /dev/null
+++ b/install/install.queries.php
@@ -0,0 +1,1199 @@
+ isset($text) ? $text : "",
+ 'error' => $err
+ );
+}
+
+
+// Prepare POST variables
+$post_type = filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING);
+$post_data = filter_input(INPUT_POST, 'data', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
+$post_activity = filter_input(INPUT_POST, 'activity', FILTER_SANITIZE_STRING);
+$post_task = filter_input(INPUT_POST, 'task', FILTER_SANITIZE_STRING);
+$post_index = filter_input(INPUT_POST, 'index', FILTER_SANITIZE_NUMBER_INT);
+$post_multiple = filter_input(INPUT_POST, 'multiple', FILTER_SANITIZE_STRING);
+$post_db = filter_input(INPUT_POST, 'db', FILTER_SANITIZE_STRING);
+
+// Load libraries
+require_once '../includes/libraries/protect/SuperGlobal/SuperGlobal.php';
+$superGlobal = new protect\SuperGlobal\SuperGlobal();
+
+// Prepare SESSION variables
+$session_url_path = $superGlobal->get("url_path", "SESSION");
+$session_abspath = $superGlobal->get("abspath", "SESSION");
+$session_db_encoding = $superGlobal->get("db_encoding", "SESSION");
+
+$superGlobal->put("CPM", 1, "SESSION");
+
+if (null !== $post_type) {
+ switch ($post_type) {
+ case "step_2":
+ //decrypt
+ require_once 'libs/aesctr.php'; // AES Counter Mode implementation
+ $json = Encryption\Crypt\aesctr::decrypt($post_data, "cpm", 128);
+ $data = json_decode($json, true);
+ $json = Encryption\Crypt\aesctr::decrypt($post_activity, "cpm", 128);
+ $data = array_merge($data, array("activity" => $json));
+ $json = Encryption\Crypt\aesctr::decrypt($post_task, "cpm", 128);
+ $data = array_merge($data, array("task" => $json));
+
+ $abspath = str_replace('\\', '/', $data['root_path']);
+ if (substr($abspath, strlen($abspath) - 1) == "/") {
+ $abspath = substr($abspath, 0, strlen($abspath) - 1);
+ }
+ $session_abspath = $abspath;
+ $session_url_path = $data['url_path'];
+
+ if (isset($data['activity']) && $data['activity'] === "folder") {
+ if (is_writable($abspath."/".$data['task']."/") === true) {
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ } else {
+ echo '[{"error" : " Path '.$data['task'].' is not writable!", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ break;
+ }
+
+ if (isset($data['activity']) && $data['activity'] === "extension") {
+ if (extension_loaded($data['task'])) {
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ } else {
+ echo '[{"error" : " Extension '.$data['task'].' is not loaded!", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ break;
+ }
+
+ if (isset($data['activity']) && $data['activity'] === "function") {
+ if (function_exists($data['task'])) {
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ } else {
+ echo '[{"error" : " Function '.$data['task'].' is not available!", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ break;
+ }
+
+ if (isset($data['activity']) && $data['activity'] === "version") {
+ if (version_compare(phpversion(), '5.5.0', '>=')) {
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ } else {
+ echo '[{"error" : "PHP version '.phpversion().' is not OK (minimum is 5.5.0)", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ break;
+ }
+
+ if (isset($data['activity']) && $data['activity'] === "ini") {
+ if (ini_get($data['task']) >= 60) {
+ echo '[{"error" : "", "index" : "'.$post_index.'"}]';
+ } else {
+ echo '[{"error" : "PHP \"Maximum execution time\" is set to '.ini_get('max_execution_time').' seconds. Please try to set to 60s at least during installation.", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ break;
+ }
+ break;
+
+ case "step_3":
+ //decrypt
+ require_once 'libs/aesctr.php'; // AES Counter Mode implementation
+ $json = Encryption\Crypt\aesctr::decrypt($post_data, "cpm", 128);
+ $data = json_decode($json, true);
+ $json = Encryption\Crypt\aesctr::decrypt($post_db, "cpm", 128);
+ $db = json_decode($json, true);
+
+ // launch
+ if ($dbTmp = mysqli_connect($db['db_host'], $db['db_login'], $db['db_pw'], $db['db_bdd'], $db['db_port'])) {
+ // create temporary INSTALL mysqli table
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `_install` (
+ `key` varchar(100) NOT NULL,
+ `value` varchar(500) NOT NULL
+ ) CHARSET=utf8;"
+ );
+ // store values
+ foreach ($data as $key => $value) {
+ $superGlobal->put($key, $value, "SESSION");
+ $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `_install` WHERE `key` = '".$key."'"));
+ if (intval($tmp) === 0) {
+ mysqli_query($dbTmp, "INSERT INTO `_install` (`key`, `value`) VALUES ('".$key."', '".$value."');");
+ } else {
+ mysqli_query($dbTmp, "UPDATE `_install` SET `value` = '".$value."' WHERE `key` = '".$key."';");
+ }
+ }
+ $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `_install` WHERE `key` = 'url_path'"));
+ if (intval($tmp) === 0) {
+ mysqli_query($dbTmp, "INSERT INTO `_install` (`key`, `value`) VALUES ('url_path', '". empty($session_url_path) ? $db['url_path'] : $session_url_path. "');");
+ } else {
+ mysqli_query($dbTmp, "UPDATE `_install` SET `value` = '", empty($session_url_path) ? $db['url_path'] : $session_url_path, "' WHERE `key` = 'url_path';");
+ }
+ $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `_install` WHERE `key` = 'abspath'"));
+ if (intval($tmp) === 0) {
+ mysqli_query($dbTmp, "INSERT INTO `_install` (`key`, `value`) VALUES ('abspath', '". empty($session_abspath) ? $db['abspath'] : $session_abspath. "');");
+ } else {
+ mysqli_query($dbTmp, "UPDATE `_install` SET `value` = '". empty($session_abspath) ? $db['abspath'] : $session_abspath. "' WHERE `key` = 'abspath';");
+ }
+
+ echo '[{"error" : "", "result" : "Connection is successful", "multiple" : ""}]';
+ } else {
+ echo '[{"error" : "'.addslashes(str_replace(array("'", "\n", "\r"), array('"', '', ''), mysqli_connect_error())).'", "result" : "Failed", "multiple" : ""}]';
+ }
+ mysqli_close($dbTmp);
+ break;
+
+ case "step_4":
+ //decrypt
+ require_once 'libs/aesctr.php'; // AES Counter Mode implementation
+ $json = Encryption\Crypt\aesctr::decrypt($post_data, "cpm", 128);
+ $data = json_decode($json, true);
+ $json = Encryption\Crypt\aesctr::decrypt($post_db, "cpm", 128);
+ $db = json_decode($json, true);
+
+ $dbTmp = mysqli_connect($db['db_host'], $db['db_login'], $db['db_pw'], $db['db_bdd'], $db['db_port']);
+
+ // prepare data
+ foreach ($data as $key => $value) {
+ $data[$key] = str_replace(array('"', '\'), array('""', '\\\\'), $value);
+ }
+
+ // check skpath
+ if (empty($data['sk_path'])) {
+ $data['sk_path'] = $session_abspath."/includes";
+ } else {
+ $data['sk_path'] = str_replace("\", "/", $data['sk_path']);
+ }
+ if (substr($data['sk_path'], strlen($data['sk_path']) - 1) == "/" || substr($data['sk_path'], strlen($data['sk_path']) - 1) == "\"") {
+ $data['sk_path'] = substr($data['sk_path'], 0, strlen($data['sk_path']) - 1);
+ }
+ if (is_dir($data['sk_path'])) {
+ if (is_writable($data['sk_path'])) {
+ // store all variables in SESSION
+ foreach ($data as $key => $value) {
+ $superGlobal->put($key, $value, "SESSION");
+ $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `_install` WHERE `key` = '".$key."'"));
+ if (intval($tmp) === 0) {
+ mysqli_query($dbTmp, "INSERT INTO `_install` (`key`, `value`) VALUES ('".$key."', '".$value."');");
+ } else {
+ mysqli_query($dbTmp, "UPDATE `_install` SET `value` = '".$value."' WHERE `key` = '".$key."';");
+ }
+ }
+ echo '[{"error" : "", "result" : "Information stored", "multiple" : ""}]';
+ } else {
+ echo '[{"error" : "The Directory must be writable!", "result" : "Information stored", "multiple" : ""}]';
+ }
+ } else {
+ echo '[{"error" : "'.$data['sk_path'].' is not a Directory!", "result" : "Information stored", "multiple" : ""}]';
+ }
+ mysqli_close($dbTmp);
+ break;
+
+ case "step_5":
+ //decrypt
+ require_once 'libs/aesctr.php'; // AES Counter Mode implementation
+ $activity = Encryption\Crypt\aesctr::decrypt($post_activity, "cpm", 128);
+ $task = Encryption\Crypt\aesctr::decrypt($post_task, "cpm", 128);
+ $json = Encryption\Crypt\aesctr::decrypt($post_db, "cpm", 128);
+ $db = json_decode($json, true);
+
+ // launch
+ $dbTmp = mysqli_connect($db['db_host'], $db['db_login'], $db['db_pw'], $db['db_bdd'], $db['db_port']);
+ $dbBdd = $db['db_bdd'];
+ if ($dbTmp) {
+ $mysqli_result = "";
+
+ // read install variables
+ $result = mysqli_query($dbTmp, "SELECT * FROM `_install`");
+ while ($row = $result->fetch_array()) {
+ $var[$row[0]] = $row[1];
+ }
+
+ if ($activity === "table") {
+ if ($task === "utf8") {
+ //FORCE UTF8 DATABASE
+ mysqli_query($dbTmp, "ALTER DATABASE `".$dbBdd."` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
+ } elseif ($task === "items") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."items` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `label` varchar(500) NOT NULL,
+ `description` text DEFAULT NULL,
+ `pw` text DEFAULT NULL,
+ `pw_iv` text DEFAULT NULL,
+ `pw_len` int(5) NOT NULL DEFAULT '0',
+ `url` varchar(500) DEFAULT NULL,
+ `id_tree` varchar(10) DEFAULT NULL,
+ `perso` tinyint(1) NOT null DEFAULT '0',
+ `login` varchar(200) DEFAULT NULL,
+ `inactif` tinyint(1) NOT null DEFAULT '0',
+ `restricted_to` varchar(200) DEFAULT NULL,
+ `anyone_can_modify` tinyint(1) NOT null DEFAULT '0',
+ `email` varchar(100) DEFAULT NULL,
+ `notification` varchar(250) DEFAULT NULL,
+ `viewed_no` int(12) NOT null DEFAULT '0',
+ `complexity_level` varchar(3) NOT null DEFAULT '-1',
+ `auto_update_pwd_frequency` tinyint(2) NOT null DEFAULT '0',
+ `auto_update_pwd_next_date` varchar(100) NOT null DEFAULT '0',
+ `encryption_type` VARCHAR(20) NOT NULL DEFAULT 'not_set',
+ PRIMARY KEY (`id`),
+ KEY `restricted_inactif_idx` (`restricted_to`,`inactif`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "log_items") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."log_items` (
+ `id_item` int(8) NOT NULL,
+ `date` varchar(50) NOT NULL,
+ `id_user` int(8) NOT NULL,
+ `action` varchar(250) NULL,
+ `raison` text NULL,
+ `raison_iv` text NULL,
+ `encryption_type` VARCHAR(20) NOT NULL DEFAULT 'not_set'
+ ) CHARSET=utf8;"
+ );
+ // create index
+ mysqli_query(
+ $dbTmp,
+ "CREATE INDEX teampass_log_items_id_item_IDX ON ".$var['tbl_prefix']."log_items (id_item,date);"
+ );
+ } elseif ($task === "misc") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."misc` (
+ `increment_id` int(12) NOT null AUTO_INCREMENT,
+ `type` varchar(50) NOT NULL,
+ `intitule` varchar(100) NOT NULL,
+ `valeur` varchar(500) NOT NULL,
+ PRIMARY KEY (`increment_id`)
+ ) CHARSET=utf8;"
+ );
+
+ // include constants
+ require_once "../includes/config/include.php";
+
+ // prepare config file
+ $tp_config_file = "../includes/config/tp.config.php";
+ if (file_exists($tp_config_file)) {
+ if (!copy($tp_config_file, $tp_config_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
+ echo '[{"error" : "includes/config/tp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ break;
+ } else {
+ unlink($tp_config_file);
+ }
+ }
+ $file_handler = fopen($tp_config_file, 'w');
+ $config_text = " '".str_replace("'", "", $elem[2])."',";
+ }
+
+ // write to config file
+ $result = fwrite(
+ $file_handler,
+ utf8_encode(
+ $config_text."
+);"
+ )
+ );
+ fclose($file_handler);
+ } elseif ($task === "nested_tree") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."nested_tree` (
+ `id` bigint(20) unsigned NOT null AUTO_INCREMENT,
+ `parent_id` int(11) NOT NULL,
+ `title` varchar(255) NOT NULL,
+ `nleft` int(11) NOT NULL DEFAULT '0',
+ `nright` int(11) NOT NULL DEFAULT '0',
+ `nlevel` int(11) NOT NULL DEFAULT '0',
+ `bloquer_creation` tinyint(1) NOT null DEFAULT '0',
+ `bloquer_modification` tinyint(1) NOT null DEFAULT '0',
+ `personal_folder` tinyint(1) NOT null DEFAULT '0',
+ `renewal_period` TINYINT(4) NOT null DEFAULT '0',
+ PRIMARY KEY (`id`),
+ KEY `nested_tree_parent_id` (`parent_id`),
+ KEY `nested_tree_nleft` (`nleft`),
+ KEY `nested_tree_nright` (`nright`),
+ KEY `nested_tree_nlevel` (`nlevel`),
+ KEY `personal_folder_idx` (`personal_folder`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "rights") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."rights` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `tree_id` int(12) NOT NULL,
+ `fonction_id` int(12) NOT NULL,
+ `authorized` tinyint(1) NOT null DEFAULT '0',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "users") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."users` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `login` varchar(50) NOT NULL,
+ `pw` varchar(400) NOT NULL,
+ `groupes_visibles` varchar(250) NOT NULL,
+ `derniers` text NULL,
+ `key_tempo` varchar(100) NULL,
+ `last_pw_change` varchar(30) NULL,
+ `last_pw` text NULL,
+ `admin` tinyint(1) NOT null DEFAULT '0',
+ `fonction_id` varchar(255) NULL,
+ `groupes_interdits` varchar(255) NULL,
+ `last_connexion` varchar(30) NULL,
+ `gestionnaire` int(11) NOT null DEFAULT '0',
+ `email` varchar(300) NOT NULL DEFAULT 'none',
+ `favourites` varchar(300) NULL,
+ `latest_items` varchar(300) NULL,
+ `personal_folder` int(1) NOT null DEFAULT '0',
+ `disabled` tinyint(1) NOT null DEFAULT '0',
+ `no_bad_attempts` tinyint(1) NOT null DEFAULT '0',
+ `can_create_root_folder` tinyint(1) NOT null DEFAULT '0',
+ `read_only` tinyint(1) NOT null DEFAULT '0',
+ `timestamp` varchar(30) NOT null DEFAULT '0',
+ `user_language` varchar(50) NOT null DEFAULT '0',
+ `name` varchar(100) NULL,
+ `lastname` varchar(100) NULL,
+ `session_end` varchar(30) NULL,
+ `isAdministratedByRole` tinyint(5) NOT null DEFAULT '0',
+ `psk` varchar(400) NULL,
+ `ga` varchar(50) NULL,
+ `ga_temporary_code` VARCHAR(20) NOT NULL DEFAULT 'none',
+ `avatar` varchar(255) NULL,
+ `avatar_thumb` varchar(255) NULL,
+ `upgrade_needed` BOOLEAN NOT NULL DEFAULT FALSE,
+ `treeloadstrategy` varchar(30) NOT null DEFAULT 'full',
+ `can_manage_all_users` tinyint(1) NOT NULL DEFAULT '0',
+ `usertimezone` VARCHAR(50) NOT NULL DEFAULT 'not_defined',
+ `agses-usercardid` VARCHAR(50) NOT NULL DEFAULT '0',
+ `encrypted_psk` text NULL,
+ `user_ip` varchar(400) NOT null DEFAULT 'none',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `login` (`login`)
+ ) CHARSET=utf8;"
+ );
+
+ require_once "../includes/config/include.php";
+ // check that admin accounts doesn't exist
+ $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `".$var['tbl_prefix']."users` WHERE login = 'admin'"));
+ if ($tmp === 0) {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "INSERT INTO `".$var['tbl_prefix']."users` (`id`, `login`, `pw`, `admin`, `gestionnaire`, `personal_folder`, `groupes_visibles`, `email`, `encrypted_psk`, `last_pw_change`) VALUES ('1', 'admin', '".bCrypt($var['admin_pwd'], '13')."', '1', '0', '0', '', '', '', '".time()."')"
+ );
+ } else {
+ $mysqli_result = mysqli_query($dbTmp, "UPDATE `".$var['tbl_prefix']."users` SET `pw` = '".bCrypt($var['admin_pwd'], '13')."' WHERE login = 'admin' AND id = '1'");
+ }
+
+ // check that API doesn't exist
+ $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `".$var['tbl_prefix']."users` WHERE id = '".API_USER_ID."'"));
+ if ($tmp === 0) {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "INSERT INTO `".$var['tbl_prefix']."users` (`id`, `login`, `pw`, `groupes_visibles`, `derniers`, `key_tempo`, `last_pw_change`, `last_pw`, `admin`, `fonction_id`, `groupes_interdits`, `last_connexion`, `gestionnaire`, `email`, `favourites`, `latest_items`, `personal_folder`) VALUES ('".API_USER_ID."', 'API', '', '', '', '', '', '', '1', '', '', '', '0', '', '', '', '0')"
+ );
+ }
+
+ // check that OTV doesn't exist
+ $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `".$var['tbl_prefix']."users` WHERE id = '".OTV_USER_ID."'"));
+ if ($tmp === 0) {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "INSERT INTO `".$var['tbl_prefix']."users` (`id`, `login`, `pw`, `groupes_visibles`, `derniers`, `key_tempo`, `last_pw_change`, `last_pw`, `admin`, `fonction_id`, `groupes_interdits`, `last_connexion`, `gestionnaire`, `email`, `favourites`, `latest_items`, `personal_folder`) VALUES ('".OTV_USER_ID."', 'OTV', '', '', '', '', '', '', '1', '', '', '', '0', '', '', '', '0')"
+ );
+ }
+ } elseif ($task === "tags") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."tags` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `tag` varchar(30) NOT NULL,
+ `item_id` int(12) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "log_system") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."log_system` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `type` varchar(20) NOT NULL,
+ `date` varchar(30) NOT NULL,
+ `label` text NOT NULL,
+ `qui` varchar(255) NOT NULL,
+ `field_1` varchar(250) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "files") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."files` (
+ `id` int(11) NOT null AUTO_INCREMENT,
+ `id_item` int(11) NOT NULL,
+ `name` varchar(100) NOT NULL,
+ `size` int(10) NOT NULL,
+ `extension` varchar(10) NOT NULL,
+ `type` varchar(255) NOT NULL,
+ `file` varchar(50) NOT NULL,
+ `status` varchar(50) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "cache") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."cache` (
+ `id` int(12) NOT NULL,
+ `label` varchar(500) NOT NULL,
+ `description` text NOT NULL,
+ `tags` text DEFAULT NULL,
+ `id_tree` int(12) NOT NULL,
+ `perso` tinyint(1) NOT NULL,
+ `restricted_to` varchar(200) DEFAULT NULL,
+ `login` varchar(200) DEFAULT NULL,
+ `folder` varchar(300) NOT NULL,
+ `author` varchar(50) NOT NULL,
+ `renewal_period` tinyint(4) NOT NULL DEFAULT '0',
+ `timestamp` varchar(50) DEFAULT NULL,
+ `url` varchar(500) NOT NULL DEFAULT '0',
+ `encryption_type` VARCHAR(50) DEFAULT NULL DEFAULT '0'
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "roles_title") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."roles_title` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `title` varchar(50) NOT NULL,
+ `allow_pw_change` TINYINT(1) NOT null DEFAULT '0',
+ `complexity` INT(5) NOT null DEFAULT '0',
+ `creator_id` int(11) NOT null DEFAULT '0',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "roles_values") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."roles_values` (
+ `role_id` int(12) NOT NULL,
+ `folder_id` int(12) NOT NULL,
+ `type` varchar(5) NOT NULL DEFAULT 'R',
+ KEY `role_id_idx` (`role_id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "kb") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."kb` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `category_id` int(12) NOT NULL,
+ `label` varchar(200) NOT NULL,
+ `description` text NOT NULL,
+ `author_id` int(12) NOT NULL,
+ `anyone_can_modify` tinyint(1) NOT null DEFAULT '0',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "kb_categories") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."kb_categories` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `category` varchar(50) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "kb_items") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."kb_items` (
+ `kb_id` int(12) NOT NULL,
+ `item_id` int(12) NOT NULL
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task == "restriction_to_roles") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."restriction_to_roles` (
+ `role_id` int(12) NOT NULL,
+ `item_id` int(12) NOT NULL,
+ KEY `role_id_idx` (`role_id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "languages") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."languages` (
+ `id` INT(10) NOT null AUTO_INCREMENT PRIMARY KEY ,
+ `name` VARCHAR(50) NOT null ,
+ `label` VARCHAR(50) NOT null ,
+ `code` VARCHAR(10) NOT null ,
+ `flag` VARCHAR(30) NOT NULL
+ ) CHARSET=utf8;"
+ );
+
+ // add lanaguages
+ $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `".$var['tbl_prefix']."languages` WHERE name = 'french'"));
+ if ($tmp[0] == 0) {
+ $mysql_result = mysqli_query(
+ $dbTmp,
+ "INSERT INTO `".$var['tbl_prefix']."languages` (`name`, `label`, `code`, `flag`) VALUES
+ ('french', 'French' , 'fr', 'fr.png'),
+ ('english', 'English' , 'us', 'us.png'),
+ ('spanish', 'Spanish' , 'es', 'es.png'),
+ ('german', 'German' , 'de', 'de.png'),
+ ('czech', 'Czech' , 'cz', 'cz.png'),
+ ('italian', 'Italian' , 'it', 'it.png'),
+ ('russian', 'Russian' , 'ru', 'ru.png'),
+ ('turkish', 'Turkish' , 'tr', 'tr.png'),
+ ('norwegian', 'Norwegian' , 'no', 'no.png'),
+ ('japanese', 'Japanese' , 'ja', 'ja.png'),
+ ('portuguese', 'Portuguese' , 'pr', 'pr.png'),
+ ('portuguese_br', 'Portuguese (Brazil)' , 'pr-bt', 'pr-bt.png'),
+ ('chinese', 'Chinese' , 'cn', 'cn.png'),
+ ('swedish', 'Swedish' , 'se', 'se.png'),
+ ('dutch', 'Dutch' , 'nl', 'nl.png'),
+ ('catalan', 'Catalan' , 'ct', 'ct.png'),
+ ('vietnamese', 'Vietnamese' , 'vi', 'vi.png'),
+ ('estonian', 'Estonian' , 'ee', 'ee.png');"
+ );
+ }
+ } elseif ($task === "emails") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."emails` (
+ `timestamp` INT(30) NOT null ,
+ `subject` VARCHAR(255) NOT null ,
+ `body` TEXT NOT null ,
+ `receivers` VARCHAR(255) NOT null ,
+ `status` VARCHAR(30) NOT NULL
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "automatic_del") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."automatic_del` (
+ `item_id` int(11) NOT NULL,
+ `del_enabled` tinyint(1) NOT NULL,
+ `del_type` tinyint(1) NOT NULL,
+ `del_value` varchar(35) NOT NULL
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "items_edition") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."items_edition` (
+ `item_id` int(11) NOT NULL,
+ `user_id` int(12) NOT NULL,
+ `timestamp` varchar(50) NOT NULL
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "categories") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."categories` (
+ `id` int(12) NOT NULL AUTO_INCREMENT,
+ `parent_id` int(12) NOT NULL,
+ `title` varchar(255) NOT NULL,
+ `level` int(2) NOT NULL,
+ `description` text NULL,
+ `type` varchar(50) NULL default '',
+ `order` int(12) NOT NULL default '0',
+ `encrypted_data` tinyint(1) NOT NULL default '1',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "categories_items") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."categories_items` (
+ `id` int(12) NOT NULL AUTO_INCREMENT,
+ `field_id` int(11) NOT NULL,
+ `item_id` int(11) NOT NULL,
+ `data` text NOT NULL,
+ `data_iv` text NOT NULL,
+ `encryption_type` VARCHAR(20) NOT NULL DEFAULT 'not_set',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "categories_folders") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."categories_folders` (
+ `id_category` int(12) NOT NULL,
+ `id_folder` int(12) NOT NULL
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "api") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."api` (
+ `id` int(20) NOT NULL AUTO_INCREMENT,
+ `type` varchar(15) NOT NULL,
+ `label` varchar(255) NOT NULL,
+ `value` varchar(255) NOT NULL,
+ `timestamp` varchar(50) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "otv") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."otv` (
+ `id` int(10) NOT NULL AUTO_INCREMENT,
+ `timestamp` text NOT NULL,
+ `code` varchar(100) NOT NULL,
+ `item_id` int(12) NOT NULL,
+ `originator` int(12) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "suggestion") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."suggestion` (
+ `id` tinyint(12) NOT NULL AUTO_INCREMENT,
+ `label` varchar(255) NOT NULL,
+ `pw` text NOT NULL,
+ `pw_iv` text NOT NULL,
+ `pw_len` int(5) NOT NULL,
+ `description` text NOT NULL,
+ `author_id` int(12) NOT NULL,
+ `folder_id` int(12) NOT NULL,
+ `comment` text NOT NULL,
+ `suggestion_type` varchar(10) NOT NULL default 'new',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."export` (
+ `id` int(12) NOT NULL,
+ `label` varchar(500) NOT NULL,
+ `login` varchar(100) NOT NULL,
+ `description` text NOT NULL,
+ `pw` text NOT NULL,
+ `path` varchar(500) NOT NULL,
+ `email` varchar(500) NOT NULL default 'none',
+ `url` varchar(500) NOT NULL default 'none',
+ `kbs` varchar(500) NOT NULL default 'none',
+ `tags` varchar(500) NOT NULL default 'none'
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "tokens") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."tokens` (
+ `id` int(12) NOT NULL AUTO_INCREMENT,
+ `user_id` int(12) NOT NULL,
+ `token` varchar(255) NOT NULL,
+ `reason` varchar(255) NOT NULL,
+ `creation_timestamp` varchar(50) NOT NULL,
+ `end_timestamp` varchar(50) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ } elseif ($task === "items_change") {
+ $mysqli_result = mysqli_query(
+ $dbTmp,
+ "CREATE TABLE IF NOT EXISTS `".$var['tbl_prefix']."items_change` (
+ `id` int(12) NOT NULL AUTO_INCREMENT,
+ `item_id` int(12) NOT NULL,
+ `label` varchar(255) NOT NULL DEFAULT 'none',
+ `pw` text NOT NULL,
+ `login` varchar(255) NOT NULL DEFAULT 'none',
+ `email` varchar(255) NOT NULL DEFAULT 'none',
+ `url` varchar(255) NOT NULL DEFAULT 'none',
+ `description` text NOT NULL,
+ `comment` text NOT NULL,
+ `folder_id` tinyint(12) NOT NULL,
+ `user_id` int(12) NOT NULL,
+ `timestamp` varchar(50) NOT NULL DEFAULT 'none',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+ );
+ }
+ }
+ // answer back
+ if ($mysqli_result) {
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'", "task" : "'.$task.'", "activity" : "'.$activity.'"}]';
+ } else {
+ echo '[{"error" : "'.addslashes(str_replace(array("'", "\n", "\r"), array('"', '', ''), mysqli_error())).'", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'", "table" : "'.$task.'"}]';
+ }
+ } else {
+ echo '[{"error" : "'.addslashes(str_replace(array("'", "\n", "\r"), array('"', '', ''), mysqli_connect_error())).'", "result" : "Failed", "multiple" : ""}]';
+ }
+
+ mysqli_close($dbTmp);
+ // Destroy session without writing to disk
+ define('NODESTROY_SESSION', 'true');
+ session_destroy();
+ break;
+
+ case "step_6":
+ //decrypt
+ require_once 'libs/aesctr.php'; // AES Counter Mode implementation
+ $activity = Encryption\Crypt\aesctr::decrypt($post_activity, "cpm", 128);
+ $data_sent = Encryption\Crypt\aesctr::decrypt($post_data, "cpm", 128);
+ $data_sent = json_decode($data_sent, true);
+ $task = Encryption\Crypt\aesctr::decrypt($post_task, "cpm", 128);
+ $json = Encryption\Crypt\aesctr::decrypt($post_db, "cpm", 128);
+ $db = json_decode($json, true);
+
+ $dbTmp = mysqli_connect(
+ $db['db_host'],
+ $db['db_login'],
+ $db['db_pw'],
+ $db['db_bdd'],
+ $db['db_port']
+ );
+
+ // read install variables
+ $result = mysqli_query($dbTmp, "SELECT * FROM `_install`");
+ while ($row = $result->fetch_array()) {
+ $var[$row[0]] = $row[1];
+ }
+
+ // launch
+ if (empty($var['sk_path'])) {
+ $skFile = $var['abspath'].'/includes/sk.php';
+ $securePath = $var['abspath'];
+ } else {
+ //ensure $var['sk_path'] has no trailing slash
+ $var['sk_path'] = rtrim($var['sk_path'], '/\\');
+ $skFile = $var['sk_path'].'/sk.php';
+ $securePath = $var['sk_path'];
+ }
+
+ $events = "";
+
+ if ($activity === "file") {
+ if ($task === "settings.php") {
+ // first is to create teampass-seckey.txt
+ // 0- check if exists
+ $filename_seckey = $securePath."/teampass-seckey.txt";
+
+ if (file_exists($filename_seckey)) {
+ if (!copy($filename_seckey, $filename_seckey.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
+ echo '[{"error" : "File `$filename_seckey` already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ break;
+ } else {
+ unlink($filename);
+ }
+ }
+
+ // 1- generate saltkey
+ require_once '../includes/libraries/Encryption/Encryption/Crypto.php';
+ require_once '../includes/libraries/Encryption/Encryption/Encoding.php';
+ require_once '../includes/libraries/Encryption/Encryption/DerivedKeys.php';
+ require_once '../includes/libraries/Encryption/Encryption/Key.php';
+ require_once '../includes/libraries/Encryption/Encryption/KeyOrPassword.php';
+ require_once '../includes/libraries/Encryption/Encryption/File.php';
+ require_once '../includes/libraries/Encryption/Encryption/RuntimeTests.php';
+ require_once '../includes/libraries/Encryption/Encryption/KeyProtectedByPassword.php';
+ require_once '../includes/libraries/Encryption/Encryption/Core.php';
+
+ $key = \Defuse\Crypto\Key::createNewRandomKey();
+ $new_salt = $key->saveToAsciiSafeString();
+
+ // 2- store key in file
+ file_put_contents(
+ $filename_seckey,
+ $new_salt
+ );
+
+ // Now create settings file
+ $filename = "../includes/config/settings.php";
+
+ if (file_exists($filename)) {
+ if (!copy($filename, $filename.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
+ echo '[{"error" : "Setting.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ break;
+ } else {
+ unlink($filename);
+ }
+ }
+
+ // Encrypt the DB password
+ $encrypted_text = encryptFollowingDefuse(
+ $db['db_pw'],
+ $new_salt
+ )['string'];
+
+ // Open and write Settings file
+ $file_handler = fopen($filename, 'w');
+ $result = fwrite(
+ $file_handler,
+ utf8_encode(
+ ""
+ )
+ );
+ fclose($file_handler);
+
+ // finalize
+ if ($result === false) {
+ echo '[{"error" : "sk.php file could not be created. Please check the path and the rights.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ } else {
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ } elseif ($task === "security") {
+ # Sort out the file permissions
+
+ // is server Windows or Linux?
+ if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ // Change directory permissions
+ $result = chmodRecursive($session_abspath, 0770, 0740);
+ if ($result) {
+ $result = chmodRecursive($session_abspath.'/files', 0770, 0770);
+ }
+ if ($result) {
+ $result = chmodRecursive($session_abspath.'/upload', 0770, 0770);
+ }
+ }
+
+ if ($result === false) {
+ echo '[{"error" : "Cannot change directory permissions - please fix manually", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ } else {
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ } elseif ($task === "csrfp-token") {
+ // update CSRFP TOKEN
+ $csrfp_file_sample = "../includes/libraries/csrfp/libs/csrfp.config.sample.php";
+ $csrfp_file = "../includes/libraries/csrfp/libs/csrfp.config.php";
+ if (file_exists($csrfp_file)) {
+ if (!copy($csrfp_file, $csrfp_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
+ echo '[{"error" : "csrfp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ break;
+ } else {
+ $events .= "The file $csrfp_file already exist. A copy has been created. ";
+ }
+ }
+ unlink($csrfp_file); // delete existing csrfp.config file
+ copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file
+ $data = file_get_contents($csrfp_file);
+ $newdata = str_replace('"CSRFP_TOKEN" => ""', '"CSRFP_TOKEN" => "'.bin2hex(openssl_random_pseudo_bytes(25)).'"', $data);
+ $jsUrl = $data_sent['url_path'].'/includes/libraries/csrfp/js/csrfprotector.js';
+ $newdata = str_replace('"jsUrl" => ""', '"jsUrl" => "'.$jsUrl.'"', $newdata);
+ file_put_contents("../includes/libraries/csrfp/libs/csrfp.config.php", $newdata);
+
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ } elseif ($activity === "install") {
+ if ($task === "cleanup") {
+ // Mark a tag to force Install stuff (folders, files and table) to be cleanup while first login
+ mysqli_query($dbTmp, "INSERT INTO `".$var['tbl_prefix']."misc` (`type`, `intitule`, `valeur`) VALUES ('install', 'clear_install_folder', 'true')");
+
+ echo '[{"error" : "", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ }
+ }
+
+ mysqli_close($dbTmp);
+ // Destroy session without writing to disk
+ define('NODESTROY_SESSION', 'true');
+ session_destroy();
+ break;
+ }
+}
diff --git a/install/js/aes.min.js b/install/js/aes.min.js
new file mode 100644
index 000000000..672cb4744
--- /dev/null
+++ b/install/js/aes.min.js
@@ -0,0 +1,457 @@
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+/* AES implementation in JavaScript (c) Chris Veness 2005-2010 */
+/* - see http://csrc.nist.gov/publications/PubsFIPS.html#197 */
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+var Aes = {}; // Aes namespace
+
+/**
+ * AES Cipher function: encrypt 'input' state with Rijndael algorithm
+ * applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
+ *
+ * @param {Number[]} input 16-byte (128-bit) input state array
+ * @param {Number[][]} w Key schedule as 2D byte-array (Nr+1 x Nb bytes)
+ * @returns {Number[]} Encrypted output state array
+ */
+Aes.cipher = function(input, w) { // main Cipher function [§5.1]
+ var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
+ var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
+
+ var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [§3.4]
+ for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
+
+ state = Aes.addRoundKey(state, w, 0, Nb);
+
+ for (var round=1; round 6 && i%Nk == 4) {
+ temp = Aes.subWord(temp);
+ }
+ for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
+ }
+
+ return w;
+}
+
+/*
+ * ---- remaining routines are private, not called externally ----
+ */
+
+Aes.subBytes = function(s, Nb) { // apply SBox to state S [§5.1.1]
+ for (var r=0; r<4; r++) {
+ for (var c=0; c>> i*8) & 0xff;
+ for (var i=0; i<4; i++) counterBlock[i+4] = nonceMs & 0xff;
+ // and convert it to a string to go on the front of the ciphertext
+ var ctrTxt = '';
+ for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
+
+ // generate key schedule - an expansion of the key into distinct Key Rounds for each round
+ var keySchedule = Aes.keyExpansion(key);
+
+ var blockCount = Math.ceil(plaintext.length/blockSize);
+ var ciphertxt = new Array(blockCount); // ciphertext as array of strings
+
+ for (var b=0; b>> c*8) & 0xff;
+ for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
+
+ var cipherCntr = Aes.cipher(counterBlock, keySchedule); // -- encrypt counter block --
+
+ // block size is reduced on final block
+ var blockLength = b>> c*8) & 0xff;
+ for (var c=0; c<4; c++) counterBlock[15-c-4] = (((b+1)/0x100000000-1) >>> c*8) & 0xff;
+
+ var cipherCntr = Aes.cipher(counterBlock, keySchedule); // encrypt counter block
+
+ var plaintxtByte = new Array(ciphertext[b].length);
+ for (var i=0; i 0) { while (c++ < 3) { pad += '='; plain += '\0'; } }
+ // note: doing padding here saves us doing special-case packing for trailing 1 or 2 chars
+
+ for (c=0; c>18 & 0x3f;
+ h2 = bits>>12 & 0x3f;
+ h3 = bits>>6 & 0x3f;
+ h4 = bits & 0x3f;
+
+ // use hextets to index into code string
+ e[c/3] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
+ }
+ coded = e.join(''); // join() is far faster than repeated string concatenation in IE
+
+ // replace 'A's from padded nulls with '='s
+ coded = coded.slice(0, coded.length-pad.length) + pad;
+
+ return coded;
+}
+
+/**
+ * Decode string from Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
+ * (instance method extending String object). As per RFC 4648, newlines are not catered for.
+ *
+ * @param {String} str The string to be decoded from base-64
+ * @param {Boolean} [utf8decode=false] Flag to indicate whether str is Unicode string to be decoded
+ * from UTF8 after conversion from base64
+ * @returns {String} decoded string
+ */
+Base64.decode = function(str, utf8decode) {
+ utf8decode = (typeof utf8decode == 'undefined') ? false : utf8decode;
+ var o1, o2, o3, h1, h2, h3, h4, bits, d=[], plain, coded;
+ var b64 = Base64.code;
+
+ coded = utf8decode ? str.decodeUTF8() : str;
+
+
+ for (var c=0; c>>16 & 0xff;
+ o2 = bits>>>8 & 0xff;
+ o3 = bits & 0xff;
+
+ d[c/4] = String.fromCharCode(o1, o2, o3);
+ // check for padding
+ if (h4 == 0x40) d[c/4] = String.fromCharCode(o1, o2);
+ if (h3 == 0x40) d[c/4] = String.fromCharCode(o1);
+ }
+ plain = d.join(''); // join() is far faster than repeated string concatenation in IE
+
+ return utf8decode ? plain.decodeUTF8() : plain;
+}
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+/* Utf8 class: encode / decode between multi-byte Unicode characters and UTF-8 multiple */
+/* single-byte character encoding (c) Chris Veness 2002-2010 */
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+var Utf8 = {}; // Utf8 namespace
+
+/**
+ * Encode multi-byte Unicode string into utf-8 multiple single-byte characters
+ * (BMP / basic multilingual plane only)
+ *
+ * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars
+ *
+ * @param {String} strUni Unicode string to be encoded as UTF-8
+ * @returns {String} encoded string
+ */
+Utf8.encode = function(strUni) {
+ // use regular expressions & String.replace callback function for better efficiency
+ // than procedural approaches
+ var strUtf = strUni.replace(
+ /[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz
+ function(c) {
+ var cc = c.charCodeAt(0);
+ return String.fromCharCode(0xc0 | cc>>6, 0x80 | cc&0x3f); }
+ );
+ strUtf = strUtf.replace(
+ /[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz
+ function(c) {
+ var cc = c.charCodeAt(0);
+ return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f); }
+ );
+ return strUtf;
+}
+
+/**
+ * Decode utf-8 encoded string back into multi-byte Unicode characters
+ *
+ * @param {String} strUtf UTF-8 string to be decoded back to Unicode
+ * @returns {String} decoded string
+ */
+Utf8.decode = function(strUtf) {
+ // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
+ var strUni = strUtf.replace(
+ /[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
+ function(c) { // (note parentheses for precence)
+ var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f);
+ return String.fromCharCode(cc); }
+ );
+ strUni = strUni.replace(
+ /[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
+ function(c) { // (note parentheses for precence)
+ var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f;
+ return String.fromCharCode(cc); }
+ );
+ return strUni;
+}
diff --git a/install/js/crypt/aes.class.php b/install/js/crypt/aes.class.php
new file mode 100644
index 000000000..4d0b9001b
--- /dev/null
+++ b/install/js/crypt/aes.class.php
@@ -0,0 +1,207 @@
+ 6 && $i % $Nk == 4) {
+ $temp = self::subWord($temp);
+ }
+ for ($t = 0; $t < 4; $t++) {
+ $w[$i][$t] = $w[$i - $Nk][$t] ^ $temp[$t];
+ }
+ }
+
+ return $w;
+ }
+
+ private static function subWord($w) { // apply SBox to 4-byte word w
+ for ($i = 0; $i < 4; $i++) {
+ $w[$i] = self::$sBox[$w[$i]];
+ }
+
+ return $w;
+ }
+
+ private static function rotWord($w) { // rotate 4-byte word w left by one byte
+ $tmp = $w[0];
+ for ($i = 0; $i < 3; $i++) {
+ $w[$i] = $w[$i + 1];
+ }
+ $w[3] = $tmp;
+
+ return $w;
+ }
+
+ // sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [é5.1.1]
+ private static $sBox = array(
+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
+ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
+ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
+ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
+ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
+ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
+ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
+ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
+ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
+ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
+ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
+ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
+ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
+ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
+ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
+ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
+
+ // rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [é5.2]
+ private static $rCon = array(
+ array(0x00, 0x00, 0x00, 0x00),
+ array(0x01, 0x00, 0x00, 0x00),
+ array(0x02, 0x00, 0x00, 0x00),
+ array(0x04, 0x00, 0x00, 0x00),
+ array(0x08, 0x00, 0x00, 0x00),
+ array(0x10, 0x00, 0x00, 0x00),
+ array(0x20, 0x00, 0x00, 0x00),
+ array(0x40, 0x00, 0x00, 0x00),
+ array(0x80, 0x00, 0x00, 0x00),
+ array(0x1b, 0x00, 0x00, 0x00),
+ array(0x36, 0x00, 0x00, 0x00));
+
+}
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
diff --git a/install/js/crypt/aes.min.js b/install/js/crypt/aes.min.js
new file mode 100644
index 000000000..5ebd7ebb3
--- /dev/null
+++ b/install/js/crypt/aes.min.js
@@ -0,0 +1,457 @@
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+/* AES implementation in JavaScript (c) Chris Veness 2005-2010 */
+/* - see http://csrc.nist.gov/publications/PubsFIPS.html#197 */
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+var Aes = {}; // Aes namespace
+
+/**
+ * AES Cipher function: encrypt 'input' state with Rijndael algorithm
+ * applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
+ *
+ * @param {Number[]} input 16-byte (128-bit) input state array
+ * @param {Number[][]} w Key schedule as 2D byte-array (Nr+1 x Nb bytes)
+ * @returns {Number[]} Encrypted output state array
+ */
+Aes.cipher = function(input, w) { // main Cipher function [§5.1]
+ var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
+ var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
+
+ var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [§3.4]
+ for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
+
+ state = Aes.addRoundKey(state, w, 0, Nb);
+
+ for (var round=1; round 6 && i%Nk == 4) {
+ temp = Aes.subWord(temp);
+ }
+ for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
+ }
+
+ return w;
+}
+
+/*
+ * ---- remaining routines are private, not called externally ----
+ */
+
+Aes.subBytes = function(s, Nb) { // apply SBox to state S [§5.1.1]
+ for (var r=0; r<4; r++) {
+ for (var c=0; c>> i*8) & 0xff;
+ for (var i=0; i<4; i++) counterBlock[i+4] = nonceMs & 0xff;
+ // and convert it to a string to go on the front of the ciphertext
+ var ctrTxt = '';
+ for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
+
+ // generate key schedule - an expansion of the key into distinct Key Rounds for each round
+ var keySchedule = Aes.keyExpansion(key);
+
+ var blockCount = Math.ceil(plaintext.length/blockSize);
+ var ciphertxt = new Array(blockCount); // ciphertext as array of strings
+
+ for (var b=0; b>> c*8) & 0xff;
+ for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
+
+ var cipherCntr = Aes.cipher(counterBlock, keySchedule); // -- encrypt counter block --
+
+ // block size is reduced on final block
+ var blockLength = b>> c*8) & 0xff;
+ for (var c=0; c<4; c++) counterBlock[15-c-4] = (((b+1)/0x100000000-1) >>> c*8) & 0xff;
+
+ var cipherCntr = Aes.cipher(counterBlock, keySchedule); // encrypt counter block
+
+ var plaintxtByte = new Array(ciphertext[b].length);
+ for (var i=0; i 0) { while (c++ < 3) { pad += '='; plain += '\0'; } }
+ // note: doing padding here saves us doing special-case packing for trailing 1 or 2 chars
+
+ for (c=0; c>18 & 0x3f;
+ h2 = bits>>12 & 0x3f;
+ h3 = bits>>6 & 0x3f;
+ h4 = bits & 0x3f;
+
+ // use hextets to index into code string
+ e[c/3] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
+ }
+ coded = e.join(''); // join() is far faster than repeated string concatenation in IE
+
+ // replace 'A's from padded nulls with '='s
+ coded = coded.slice(0, coded.length-pad.length) + pad;
+
+ return coded;
+}
+
+/**
+ * Decode string from Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
+ * (instance method extending String object). As per RFC 4648, newlines are not catered for.
+ *
+ * @param {String} str The string to be decoded from base-64
+ * @param {Boolean} [utf8decode=false] Flag to indicate whether str is Unicode string to be decoded
+ * from UTF8 after conversion from base64
+ * @returns {String} decoded string
+ */
+Base64.decode = function(str, utf8decode) {
+ utf8decode = (typeof utf8decode == 'undefined') ? false : utf8decode;
+ var o1, o2, o3, h1, h2, h3, h4, bits, d=[], plain, coded;
+ var b64 = Base64.code;
+
+ coded = utf8decode ? str.decodeUTF8() : str;
+
+
+ for (var c=0; c>>16 & 0xff;
+ o2 = bits>>>8 & 0xff;
+ o3 = bits & 0xff;
+
+ d[c/4] = String.fromCharCode(o1, o2, o3);
+ // check for padding
+ if (h4 == 0x40) d[c/4] = String.fromCharCode(o1, o2);
+ if (h3 == 0x40) d[c/4] = String.fromCharCode(o1);
+ }
+ plain = d.join(''); // join() is far faster than repeated string concatenation in IE
+
+ return utf8decode ? plain.decodeUTF8() : plain;
+}
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+/* Utf8 class: encode / decode between multi-byte Unicode characters and UTF-8 multiple */
+/* single-byte character encoding (c) Chris Veness 2002-2010 */
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+var Utf8 = {}; // Utf8 namespace
+
+/**
+ * Encode multi-byte Unicode string into utf-8 multiple single-byte characters
+ * (BMP / basic multilingual plane only)
+ *
+ * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars
+ *
+ * @param {String} strUni Unicode string to be encoded as UTF-8
+ * @returns {String} encoded string
+ */
+Utf8.encode = function(strUni) {
+ // use regular expressions & String.replace callback function for better efficiency
+ // than procedural approaches
+ var strUtf = strUni.replace(
+ /[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz
+ function(c) {
+ var cc = c.charCodeAt(0);
+ return String.fromCharCode(0xc0 | cc>>6, 0x80 | cc&0x3f); }
+ );
+ strUtf = strUtf.replace(
+ /[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz
+ function(c) {
+ var cc = c.charCodeAt(0);
+ return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f); }
+ );
+ return strUtf;
+}
+
+/**
+ * Decode utf-8 encoded string back into multi-byte Unicode characters
+ *
+ * @param {String} strUtf UTF-8 string to be decoded back to Unicode
+ * @returns {String} decoded string
+ */
+Utf8.decode = function(strUtf) {
+ // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
+ var strUni = strUtf.replace(
+ /[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
+ function(c) { // (note parentheses for precence)
+ var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f);
+ return String.fromCharCode(cc); }
+ );
+ strUni = strUni.replace(
+ /[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
+ function(c) { // (note parentheses for precence)
+ var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f;
+ return String.fromCharCode(cc); }
+ );
+ return strUni;
+}
diff --git a/install/js/crypt/aesctr.class.php b/install/js/crypt/aesctr.class.php
new file mode 100644
index 000000000..84b2521e8
--- /dev/null
+++ b/install/js/crypt/aesctr.class.php
@@ -0,0 +1,191 @@
+>> operator nor unsigned ints
+ *
+ * @param a number to be shifted (32-bit integer)
+ * @param b number of bits to shift a to the right (0..31)
+ * @return a right-shifted and zero-filled by b bits
+ */
+ private static function urs($a, $b)
+ {
+ $a &= 0xffffffff; $b &= 0x1f; // (bounds check)
+ if ($a & 0x80000000 && $b > 0) { // if left-most bit set
+ $a = ($a >> 1) & 0x7fffffff; // right-shift one bit & clear left-most bit
+ $a = $a >> ($b - 1); // remaining right-shifts
+ } else { // otherwise
+ $a = ($a >> $b); // use normal right-shift
+ }
+
+ return $a;
+ }
+
+}
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
diff --git a/install/js/jquery-ui.min.js b/install/js/jquery-ui.min.js
new file mode 100644
index 000000000..6a06137c5
--- /dev/null
+++ b/install/js/jquery-ui.min.js
@@ -0,0 +1,638 @@
+/*!
+ * jQuery UI 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI
+ */
+(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.16",
+keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({propAttr:c.fn.prop||c.fn.attr,_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=
+this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,
+"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":
+"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,
+outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,
+"tabindex"),d=isNaN(b);return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&
+a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=
+false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
+;/*
+ * jQuery UI Position 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Position
+ */
+(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY,
+left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+=
+k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-=
+m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left=
+d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+=
+a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b),
+g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);
+;/*
+ * jQuery UI Draggable 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Draggables
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.mouse.js
+ * jquery.ui.widget.js
+ */
+(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper==
+"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b=
+this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;if(b.iframeFix)d(b.iframeFix===true?"iframe":b.iframeFix).each(function(){d('
').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")});return true},_mouseStart:function(a){var b=this.options;
+this.helper=this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
+this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);d.ui.ddmanager&&d.ui.ddmanager.dragStart(this,a);return true},
+_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b=
+false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,
+10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},_mouseUp:function(a){this.options.iframeFix===true&&d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});d.ui.ddmanager&&d.ui.ddmanager.dragStop(this,a);return d.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle||
+!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&
+a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=
+this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
+10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),
+10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[a.containment=="document"?0:d(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,a.containment=="document"?0:d(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,
+(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){a=d(a.containment);var b=a[0];if(b){a.offset();var c=d(b).css("overflow")!=
+"hidden";this.containment=[(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0),(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0),(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),
+10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=a}}else if(a.containment.constructor==Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+
+this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&
+!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,h=a.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;if(a.pageX-this.offset.click.leftg[2])e=g[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>g[3])h=g[3]+this.offset.click.top}if(b.grid){h=b.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/b.grid[1])*b.grid[1]:this.originalPageY;h=g?!(h-this.offset.click.topg[3])?h:!(h-this.offset.click.topg[2])?e:!(e-this.offset.click.left=0;i--){var j=c.snapElements[i].left,l=j+c.snapElements[i].width,k=c.snapElements[i].top,m=k+c.snapElements[i].height;if(j-e=j&&f<=l||h>=j&&h<=l||fl)&&(e>=
+i&&e<=k||g>=i&&g<=k||ek);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),
+top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=
+this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=a.handles||(!e(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",
+nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var c=this.handles.split(",");this.handles={};for(var d=0;d');/sw|se|ne|nw/.test(f)&&g.css({zIndex:++a.zIndex});"se"==f&&g.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(g)}}this._renderAxis=function(h){h=h||this.element;for(var i in this.handles){if(this.handles[i].constructor==
+String)this.handles[i]=e(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var j=e(this.handles[i],this.element),l=0;l=/sw|ne|nw|se|n|s/.test(i)?j.outerHeight():j.outerWidth();j=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");h.css(j,l);this._proportionallyResize()}e(this.handles[i])}};this._renderAxis(this.element);this._handles=e(".ui-resizable-handle",this.element).disableSelection();
+this._handles.mouseover(function(){if(!b.resizing){if(this.className)var h=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=h&&h[1]?h[1]:"se"}});if(a.autoHide){this._handles.hide();e(this.element).addClass("ui-resizable-autohide").hover(function(){if(!a.disabled){e(this).removeClass("ui-resizable-autohide");b._handles.show()}},function(){if(!a.disabled)if(!b.resizing){e(this).addClass("ui-resizable-autohide");b._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();
+var b=function(c){e(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a=
+false;for(var c in this.handles)if(e(this.handles[c])[0]==b.target)a=true;return!this.options.disabled&&a},_mouseStart:function(b){var a=this.options,c=this.element.position(),d=this.element;this.resizing=true;this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()};if(d.is(".ui-draggable")||/absolute/.test(d.css("position")))d.css({position:"absolute",top:c.top,left:c.left});e.browser.opera&&/relative/.test(d.css("position"))&&d.css({position:"relative",top:"auto",left:"auto"});
+this._renderProxy();c=m(this.helper.css("left"));var f=m(this.helper.css("top"));if(a.containment){c+=e(a.containment).scrollLeft()||0;f+=e(a.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:c,top:f};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:c,top:f};this.sizeDiff=
+{width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:b.pageX,top:b.pageY};this.aspectRatio=typeof a.aspectRatio=="number"?a.aspectRatio:this.originalSize.width/this.originalSize.height||1;a=e(".ui-resizable-"+this.axis).css("cursor");e("body").css("cursor",a=="auto"?this.axis+"-resize":a);d.addClass("ui-resizable-resizing");this._propagate("start",b);return true},_mouseDrag:function(b){var a=this.helper,c=this.originalMousePosition,d=this._change[this.axis];
+if(!d)return false;c=d.apply(this,[b,b.pageX-c.left||0,b.pageY-c.top||0]);this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)c=this._updateRatio(c,b);c=this._respectSize(c,b);this._propagate("resize",b);a.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(c);this._trigger("resize",b,this.ui());return false},
+_mouseStop:function(b){this.resizing=false;var a=this.options,c=this;if(this._helper){var d=this._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName);d=f&&e.ui.hasScroll(d[0],"left")?0:c.sizeDiff.height;f=f?0:c.sizeDiff.width;f={width:c.helper.width()-f,height:c.helper.height()-d};d=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null;var g=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;a.animate||this.element.css(e.extend(f,
+{top:g,left:d}));c.helper.height(c.size.height);c.helper.width(c.size.width);this._helper&&!a.animate&&this._proportionallyResize()}e("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",b);this._helper&&this.helper.remove();return false},_updateVirtualBoundaries:function(b){var a=this.options,c,d,f;a={minWidth:k(a.minWidth)?a.minWidth:0,maxWidth:k(a.maxWidth)?a.maxWidth:Infinity,minHeight:k(a.minHeight)?a.minHeight:0,maxHeight:k(a.maxHeight)?a.maxHeight:
+Infinity};if(this._aspectRatio||b){b=a.minHeight*this.aspectRatio;d=a.minWidth/this.aspectRatio;c=a.maxHeight*this.aspectRatio;f=a.maxWidth/this.aspectRatio;if(b>a.minWidth)a.minWidth=b;if(d>a.minHeight)a.minHeight=d;if(cb.width,h=k(b.height)&&a.minHeight&&a.minHeight>b.height;if(g)b.width=a.minWidth;if(h)b.height=a.minHeight;if(d)b.width=a.maxWidth;if(f)b.height=a.maxHeight;var i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height,l=/sw|nw|w/.test(c);c=/nw|ne|n/.test(c);if(g&&l)b.left=i-a.minWidth;if(d&&l)b.left=i-a.maxWidth;if(h&&c)b.top=j-a.minHeight;if(f&&c)b.top=j-a.maxHeight;if((a=!b.width&&!b.height)&&!b.left&&b.top)b.top=null;else if(a&&!b.top&&b.left)b.left=
+null;return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var b=this.helper||this.element,a=0;a');var a=e.browser.msie&&e.browser.version<7,c=a?1:0;a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+
+a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++b.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,a){return{width:this.originalSize.width+a}},w:function(b,a){return{left:this.originalPosition.left+a,width:this.originalSize.width-a}},n:function(b,a,c){return{top:this.originalPosition.top+c,height:this.originalSize.height-c}},s:function(b,a,c){return{height:this.originalSize.height+
+c}},se:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},sw:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,a,c]))},ne:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},nw:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,a,c]))}},_propagate:function(b,a){e.ui.plugin.call(this,b,[a,this.ui()]);
+b!="resize"&&this._trigger(b,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});e.extend(e.ui.resizable,{version:"1.8.16"});e.ui.plugin.add("resizable","alsoResize",{start:function(){var b=e(this).data("resizable").options,a=function(c){e(c).each(function(){var d=e(this);d.data("resizable-alsoresize",{width:parseInt(d.width(),
+10),height:parseInt(d.height(),10),left:parseInt(d.css("left"),10),top:parseInt(d.css("top"),10),position:d.css("position")})})};if(typeof b.alsoResize=="object"&&!b.alsoResize.parentNode)if(b.alsoResize.length){b.alsoResize=b.alsoResize[0];a(b.alsoResize)}else e.each(b.alsoResize,function(c){a(c)});else a(b.alsoResize)},resize:function(b,a){var c=e(this).data("resizable");b=c.options;var d=c.originalSize,f=c.originalPosition,g={height:c.size.height-d.height||0,width:c.size.width-d.width||0,top:c.position.top-
+f.top||0,left:c.position.left-f.left||0},h=function(i,j){e(i).each(function(){var l=e(this),q=e(this).data("resizable-alsoresize"),p={},r=j&&j.length?j:l.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(r,function(n,o){if((n=(q[o]||0)+(g[o]||0))&&n>=0)p[o]=n||null});if(e.browser.opera&&/relative/.test(l.css("position"))){c._revertToRelativePosition=true;l.css({position:"absolute",top:"auto",left:"auto"})}l.css(p)})};typeof b.alsoResize=="object"&&!b.alsoResize.nodeType?
+e.each(b.alsoResize,function(i,j){h(i,j)}):h(b.alsoResize)},stop:function(){var b=e(this).data("resizable"),a=b.options,c=function(d){e(d).each(function(){var f=e(this);f.css({position:f.data("resizable-alsoresize").position})})};if(b._revertToRelativePosition){b._revertToRelativePosition=false;typeof a.alsoResize=="object"&&!a.alsoResize.nodeType?e.each(a.alsoResize,function(d){c(d)}):c(a.alsoResize)}e(this).removeData("resizable-alsoresize")}});e.ui.plugin.add("resizable","animate",{stop:function(b){var a=
+e(this).data("resizable"),c=a.options,d=a._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName),g=f&&e.ui.hasScroll(d[0],"left")?0:a.sizeDiff.height;f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-g};g=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null;var h=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(e.extend(f,h&&g?{top:h,left:g}:{}),{duration:c.animateDuration,easing:c.animateEasing,
+step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};d&&d.length&&e(d[0]).css({width:i.width,height:i.height});a._updateCache(i);a._propagate("resize",b)}})}});e.ui.plugin.add("resizable","containment",{start:function(){var b=e(this).data("resizable"),a=b.element,c=b.options.containment;if(a=c instanceof e?c.get(0):/parent/.test(c)?a.parent().get(0):c){b.containerElement=
+e(a);if(/document/.test(c)||c==document){b.containerOffset={left:0,top:0};b.containerPosition={left:0,top:0};b.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}}else{var d=e(a),f=[];e(["Top","Right","Left","Bottom"]).each(function(i,j){f[i]=m(d.css("padding"+j))});b.containerOffset=d.offset();b.containerPosition=d.position();b.containerSize={height:d.innerHeight()-f[3],width:d.innerWidth()-f[1]};c=b.containerOffset;
+var g=b.containerSize.height,h=b.containerSize.width;h=e.ui.hasScroll(a,"left")?a.scrollWidth:h;g=e.ui.hasScroll(a)?a.scrollHeight:g;b.parentData={element:a,left:c.left,top:c.top,width:h,height:g}}}},resize:function(b){var a=e(this).data("resizable"),c=a.options,d=a.containerOffset,f=a.position;b=a._aspectRatio||b.shiftKey;var g={top:0,left:0},h=a.containerElement;if(h[0]!=document&&/static/.test(h.css("position")))g=d;if(f.left<(a._helper?d.left:0)){a.size.width+=a._helper?a.position.left-d.left:
+a.position.left-g.left;if(b)a.size.height=a.size.width/c.aspectRatio;a.position.left=c.helper?d.left:0}if(f.top<(a._helper?d.top:0)){a.size.height+=a._helper?a.position.top-d.top:a.position.top;if(b)a.size.width=a.size.height*c.aspectRatio;a.position.top=a._helper?d.top:0}a.offset.left=a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;c=Math.abs((a._helper?a.offset.left-g.left:a.offset.left-g.left)+a.sizeDiff.width);d=Math.abs((a._helper?a.offset.top-g.top:a.offset.top-
+d.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);g=/relative|absolute/.test(a.containerElement.css("position"));if(f&&g)c-=a.parentData.left;if(c+a.size.width>=a.parentData.width){a.size.width=a.parentData.width-c;if(b)a.size.height=a.size.width/a.aspectRatio}if(d+a.size.height>=a.parentData.height){a.size.height=a.parentData.height-d;if(b)a.size.width=a.size.height*a.aspectRatio}},stop:function(){var b=e(this).data("resizable"),a=b.options,c=b.containerOffset,d=b.containerPosition,
+f=b.containerElement,g=e(b.helper),h=g.offset(),i=g.outerWidth()-b.sizeDiff.width;g=g.outerHeight()-b.sizeDiff.height;b._helper&&!a.animate&&/relative/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g});b._helper&&!a.animate&&/static/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g})}});e.ui.plugin.add("resizable","ghost",{start:function(){var b=e(this).data("resizable"),a=b.options,c=b.size;b.ghost=b.originalElement.clone();b.ghost.css({opacity:0.25,
+display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");b.ghost.appendTo(b.helper)},resize:function(){var b=e(this).data("resizable");b.ghost&&b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})},stop:function(){var b=e(this).data("resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}});e.ui.plugin.add("resizable","grid",{resize:function(){var b=
+e(this).data("resizable"),a=b.options,c=b.size,d=b.originalSize,f=b.originalPosition,g=b.axis;a.grid=typeof a.grid=="number"?[a.grid,a.grid]:a.grid;var h=Math.round((c.width-d.width)/(a.grid[0]||1))*(a.grid[0]||1);a=Math.round((c.height-d.height)/(a.grid[1]||1))*(a.grid[1]||1);if(/^(se|s|e)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a}else if(/^(ne)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}else{if(/^(sw)$/.test(g)){b.size.width=d.width+h;b.size.height=
+d.height+a}else{b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}b.position.left=f.left-h}}});var m=function(b){return parseInt(b,10)||0},k=function(b){return!isNaN(parseInt(b,10))}})(jQuery);
+;/*
+ * jQuery UI Selectable 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Selectables
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.mouse.js
+ * jquery.ui.widget.js
+ */
+(function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"),
+selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("
")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX,
+c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;f._trigger("unselecting",
+c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var d=
+this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.righti||a.bottomb&&a.rightg&&a.bottom *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){var a=this.options;this.containerCache={};this.element.addClass("ui-sortable");
+this.refresh();this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(a,b){if(a===
+"disabled"){this.options[a]=b;this.widget()[b?"addClass":"removeClass"]("ui-sortable-disabled")}else d.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(a,b){if(this.reverting)return false;if(this.options.disabled||this.options.type=="static")return false;this._refreshItems(a);var c=null,e=this;d(a.target).parents().each(function(){if(d.data(this,"sortable-item")==e){c=d(this);return false}});if(d.data(a.target,"sortable-item")==e)c=d(a.target);if(!c)return false;if(this.options.handle&&
+!b){var f=false;d(this.options.handle,c).find("*").andSelf().each(function(){if(this==a.target)f=true});if(!f)return false}this.currentItem=c;this._removeCurrentsFromItems();return true},_mouseStart:function(a,b,c){b=this.options;var e=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,
+left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};
+this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();b.containment&&this._setContainment();if(b.cursor){if(d("body").css("cursor"))this._storedCursor=d("body").css("cursor");d("body").css("cursor",b.cursor)}if(b.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",b.opacity)}if(b.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",b.zIndex)}if(this.scrollParent[0]!=
+document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=this.scrollParent.offset();this._trigger("start",a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!c)for(c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("activate",a,e._uiHash(this));if(d.ui.ddmanager)d.ui.ddmanager.current=this;d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a);
+return true},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var b=this.options,c=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageY=0;b--){c=this.items[b];var e=c.item[0],f=this._intersectsWithPointer(c);if(f)if(e!=this.currentItem[0]&&this.placeholder[f==1?"next":"prev"]()[0]!=e&&!d.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!d.ui.contains(this.element[0],
+e):true)){this.direction=f==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(c))this._rearrange(a,c);else break;this._trigger("change",a,this._uiHash());break}}this._contactContainers(a);d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);this._trigger("sort",a,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(a,b){if(a){d.ui.ddmanager&&!this.options.dropBehaviour&&d.ui.ddmanager.drop(this,a);if(this.options.revert){var c=this;b=c.placeholder.offset();
+c.reverting=true;d(this.helper).animate({left:b.left-this.offset.parent.left-c.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:b.top-this.offset.parent.top-c.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){c._clear(a)})}else this._clear(a,b);return false}},cancel:function(){var a=this;if(this.dragging){this._mouseUp({target:null});this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):
+this.currentItem.show();for(var b=this.containers.length-1;b>=0;b--){this.containers[b]._trigger("deactivate",null,a._uiHash(this));if(this.containers[b].containerCache.over){this.containers[b]._trigger("out",null,a._uiHash(this));this.containers[b].containerCache.over=0}}}if(this.placeholder){this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove();d.extend(this,{helper:null,
+dragging:false,reverting:false,_noFinalSort:null});this.domPosition.prev?d(this.domPosition.prev).after(this.currentItem):d(this.domPosition.parent).prepend(this.currentItem)}return this},serialize:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};d(b).each(function(){var e=(d(a.item||this).attr(a.attribute||"id")||"").match(a.expression||/(.+)[-=_](.+)/);if(e)c.push((a.key||e[1]+"[]")+"="+(a.key&&a.expression?e[1]:e[2]))});!c.length&&a.key&&c.push(a.key+"=");return c.join("&")},
+toArray:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};b.each(function(){c.push(d(a.item||this).attr(a.attribute||"id")||"")});return c},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,e=this.positionAbs.top,f=e+this.helperProportions.height,g=a.left,h=g+a.width,i=a.top,k=i+a.height,j=this.offset.click.top,l=this.offset.click.left;j=e+j>i&&e+jg&&b+la[this.floating?"width":"height"]?j:g0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){this._refreshItems(a);this.refreshPositions();return this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(a){var b=[],c=[],e=this._connectWith();
+if(e&&a)for(a=e.length-1;a>=0;a--)for(var f=d(e[a]),g=f.length-1;g>=0;g--){var h=d.data(f[g],"sortable");if(h&&h!=this&&!h.options.disabled)c.push([d.isFunction(h.options.items)?h.options.items.call(h.element):d(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}c.push([d.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):d(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),
+this]);for(a=c.length-1;a>=0;a--)c[a][0].each(function(){b.push(this)});return d(b)},_removeCurrentsFromItems:function(){for(var a=this.currentItem.find(":data(sortable-item)"),b=0;b=0;f--)for(var g=d(e[f]),h=g.length-1;h>=0;h--){var i=d.data(g[h],"sortable");if(i&&i!=this&&!i.options.disabled){c.push([d.isFunction(i.options.items)?i.options.items.call(i.element[0],a,{item:this.currentItem}):d(i.options.items,i.element),i]);this.containers.push(i)}}for(f=c.length-1;f>=0;f--){a=c[f][1];e=c[f][0];h=0;for(g=e.length;h=0;b--){var c=this.items[b];if(!(c.instance!=this.currentContainer&&this.currentContainer&&c.item[0]!=this.currentItem[0])){var e=this.options.toleranceElement?d(this.options.toleranceElement,c.item):c.item;if(!a){c.width=e.outerWidth();c.height=e.outerHeight()}e=e.offset();c.left=e.left;c.top=e.top}}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(b=
+this.containers.length-1;b>=0;b--){e=this.containers[b].element.offset();this.containers[b].containerCache.left=e.left;this.containers[b].containerCache.top=e.top;this.containers[b].containerCache.width=this.containers[b].element.outerWidth();this.containers[b].containerCache.height=this.containers[b].element.outerHeight()}return this},_createPlaceholder:function(a){var b=a||this,c=b.options;if(!c.placeholder||c.placeholder.constructor==String){var e=c.placeholder;c.placeholder={element:function(){var f=
+d(document.createElement(b.currentItem[0].nodeName)).addClass(e||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!e)f.style.visibility="hidden";return f},update:function(f,g){if(!(e&&!c.forcePlaceholderSize)){g.height()||g.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10));g.width()||g.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")||
+0,10))}}}}b.placeholder=d(c.placeholder.element.call(b.element,b.currentItem));b.currentItem.after(b.placeholder);c.placeholder.update(b,b.placeholder)},_contactContainers:function(a){for(var b=null,c=null,e=this.containers.length-1;e>=0;e--)if(!d.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!(b&&d.ui.contains(this.containers[e].element[0],b.element[0]))){b=this.containers[e];c=e}}else if(this.containers[e].containerCache.over){this.containers[e]._trigger("out",
+a,this._uiHash(this));this.containers[e].containerCache.over=0}if(b)if(this.containers.length===1){this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}else if(this.currentContainer!=this.containers[c]){b=1E4;e=null;for(var f=this.positionAbs[this.containers[c].floating?"left":"top"],g=this.items.length-1;g>=0;g--)if(d.ui.contains(this.containers[c].element[0],this.items[g].item[0])){var h=this.items[g][this.containers[c].floating?"left":"top"];if(Math.abs(h-
+f)this.containment[2])f=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g-
+this.originalPageY)/b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.topthis.containment[3])?g:!(g-this.offset.click.topthis.containment[2])?f:!(f-this.offset.click.left=0;e--)if(d.ui.contains(this.containers[e].element[0],this.currentItem[0])&&!b){c.push(function(f){return function(g){f._trigger("receive",g,this._uiHash(this))}}.call(this,this.containers[e]));c.push(function(f){return function(g){f._trigger("update",g,this._uiHash(this))}}.call(this,this.containers[e]))}}for(e=this.containers.length-1;e>=0;e--){b||c.push(function(f){return function(g){f._trigger("deactivate",g,this._uiHash(this))}}.call(this,
+this.containers[e]));if(this.containers[e].containerCache.over){c.push(function(f){return function(g){f._trigger("out",g,this._uiHash(this))}}.call(this,this.containers[e]));this.containers[e].containerCache.over=0}}this._storedCursor&&d("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!b){this._trigger("beforeStop",
+a,this._uiHash());for(e=0;e li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:false,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var a=this,b=a.options;a.running=0;a.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix");
+a.headers=a.element.find(b.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){b.disabled||c(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){b.disabled||c(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){b.disabled||c(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){b.disabled||c(this).removeClass("ui-state-focus")});a.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");
+if(b.navigation){var d=a.element.find("a").filter(b.navigationFilter).eq(0);if(d.length){var h=d.closest(".ui-accordion-header");a.active=h.length?h:d.closest(".ui-accordion-content").prev()}}a.active=a._findActive(a.active||b.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");a.active.next().addClass("ui-accordion-content-active");a._createIcons();a.resize();a.element.attr("role","tablist");a.headers.attr("role","tab").bind("keydown.accordion",
+function(f){return a._keydown(f)}).next().attr("role","tabpanel");a.headers.not(a.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide();a.active.length?a.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):a.headers.eq(0).attr("tabIndex",0);c.browser.safari||a.headers.find("a").attr("tabIndex",-1);b.event&&a.headers.bind(b.event.split(" ").join(".accordion ")+".accordion",function(f){a._clickHandler.call(a,f,this);f.preventDefault()})},_createIcons:function(){var a=
+this.options;if(a.icons){c(" ").addClass("ui-icon "+a.icons.header).prependTo(this.headers);this.active.children(".ui-icon").toggleClass(a.icons.header).toggleClass(a.icons.headerSelected);this.element.addClass("ui-accordion-icons")}},_destroyIcons:function(){this.headers.children(".ui-icon").remove();this.element.removeClass("ui-accordion-icons")},destroy:function(){var a=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role");this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex");
+this.headers.find("a").removeAttr("tabIndex");this._destroyIcons();var b=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");if(a.autoHeight||a.fillHeight)b.css("height","");return c.Widget.prototype.destroy.call(this)},_setOption:function(a,b){c.Widget.prototype._setOption.apply(this,arguments);a=="active"&&this.activate(b);if(a=="icons"){this._destroyIcons();
+b&&this._createIcons()}if(a=="disabled")this.headers.add(this.headers.next())[b?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(a){if(!(this.options.disabled||a.altKey||a.ctrlKey)){var b=c.ui.keyCode,d=this.headers.length,h=this.headers.index(a.target),f=false;switch(a.keyCode){case b.RIGHT:case b.DOWN:f=this.headers[(h+1)%d];break;case b.LEFT:case b.UP:f=this.headers[(h-1+d)%d];break;case b.SPACE:case b.ENTER:this._clickHandler({target:a.target},a.target);
+a.preventDefault()}if(f){c(a.target).attr("tabIndex",-1);c(f).attr("tabIndex",0);f.focus();return false}return true}},resize:function(){var a=this.options,b;if(a.fillSpace){if(c.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}b=this.element.parent().height();c.browser.msie&&this.element.parent().css("overflow",d);this.headers.each(function(){b-=c(this).outerHeight(true)});this.headers.next().each(function(){c(this).height(Math.max(0,b-c(this).innerHeight()+
+c(this).height()))}).css("overflow","auto")}else if(a.autoHeight){b=0;this.headers.next().each(function(){b=Math.max(b,c(this).height("").height())}).height(b)}return this},activate:function(a){this.options.active=a;a=this._findActive(a)[0];this._clickHandler({target:a},a);return this},_findActive:function(a){return a?typeof a==="number"?this.headers.filter(":eq("+a+")"):this.headers.not(this.headers.not(a)):a===false?c([]):this.headers.filter(":eq(0)")},_clickHandler:function(a,b){var d=this.options;
+if(!d.disabled)if(a.target){a=c(a.currentTarget||b);b=a[0]===this.active[0];d.active=d.collapsible&&b?false:this.headers.index(a);if(!(this.running||!d.collapsible&&b)){var h=this.active;j=a.next();g=this.active.next();e={options:d,newHeader:b&&d.collapsible?c([]):a,oldHeader:this.active,newContent:b&&d.collapsible?c([]):j,oldContent:g};var f=this.headers.index(this.active[0])>this.headers.index(a[0]);this.active=b?c([]):a;this._toggle(j,g,e,b,f);h.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header);
+if(!b){a.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected);a.next().addClass("ui-accordion-content-active")}}}else if(d.collapsible){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header);this.active.next().addClass("ui-accordion-content-active");var g=this.active.next(),
+e={options:d,newHeader:c([]),oldHeader:d.active,newContent:c([]),oldContent:g},j=this.active=c([]);this._toggle(j,g,e)}},_toggle:function(a,b,d,h,f){var g=this,e=g.options;g.toShow=a;g.toHide=b;g.data=d;var j=function(){if(g)return g._completed.apply(g,arguments)};g._trigger("changestart",null,g.data);g.running=b.size()===0?a.size():b.size();if(e.animated){d={};d=e.collapsible&&h?{toShow:c([]),toHide:b,complete:j,down:f,autoHeight:e.autoHeight||e.fillSpace}:{toShow:a,toHide:b,complete:j,down:f,autoHeight:e.autoHeight||
+e.fillSpace};if(!e.proxied)e.proxied=e.animated;if(!e.proxiedDuration)e.proxiedDuration=e.duration;e.animated=c.isFunction(e.proxied)?e.proxied(d):e.proxied;e.duration=c.isFunction(e.proxiedDuration)?e.proxiedDuration(d):e.proxiedDuration;h=c.ui.accordion.animations;var i=e.duration,k=e.animated;if(k&&!h[k]&&!c.easing[k])k="slide";h[k]||(h[k]=function(l){this.slide(l,{easing:k,duration:i||700})});h[k](d)}else{if(e.collapsible&&h)a.toggle();else{b.hide();a.show()}j(true)}b.prev().attr({"aria-expanded":"false",
+"aria-selected":"false",tabIndex:-1}).blur();a.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(a){this.running=a?0:--this.running;if(!this.running){this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""});this.toHide.removeClass("ui-accordion-content-active");if(this.toHide.length)this.toHide.parent()[0].className=this.toHide.parent()[0].className;this._trigger("change",null,this.data)}}});c.extend(c.ui.accordion,{version:"1.8.16",
+animations:{slide:function(a,b){a=c.extend({easing:"swing",duration:300},a,b);if(a.toHide.size())if(a.toShow.size()){var d=a.toShow.css("overflow"),h=0,f={},g={},e;b=a.toShow;e=b[0].style.width;b.width(parseInt(b.parent().width(),10)-parseInt(b.css("paddingLeft"),10)-parseInt(b.css("paddingRight"),10)-(parseInt(b.css("borderLeftWidth"),10)||0)-(parseInt(b.css("borderRightWidth"),10)||0));c.each(["height","paddingTop","paddingBottom"],function(j,i){g[i]="hide";j=(""+c.css(a.toShow[0],i)).match(/^([\d+-.]+)(.*)$/);
+f[i]={value:j[1],unit:j[2]||"px"}});a.toShow.css({height:0,overflow:"hidden"}).show();a.toHide.filter(":hidden").each(a.complete).end().filter(":visible").animate(g,{step:function(j,i){if(i.prop=="height")h=i.end-i.start===0?0:(i.now-i.start)/(i.end-i.start);a.toShow[0].style[i.prop]=h*f[i.prop].value+f[i.prop].unit},duration:a.duration,easing:a.easing,complete:function(){a.autoHeight||a.toShow.css("height","");a.toShow.css({width:e,overflow:d});a.complete()}})}else a.toHide.animate({height:"hide",
+paddingTop:"hide",paddingBottom:"hide"},a);else a.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},a)},bounceslide:function(a){this.slide(a,{easing:a.down?"easeOutBounce":"swing",duration:a.down?1E3:200})}}})})(jQuery);
+;/*
+ * jQuery UI Autocomplete 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Autocomplete
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.widget.js
+ * jquery.ui.position.js
+ */
+(function(d){var e=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.propAttr("readOnly"))){g=
+false;var f=d.ui.keyCode;switch(c.keyCode){case f.PAGE_UP:a._move("previousPage",c);break;case f.PAGE_DOWN:a._move("nextPage",c);break;case f.UP:a._move("previous",c);c.preventDefault();break;case f.DOWN:a._move("next",c);c.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:if(a.menu.active){g=true;c.preventDefault()}case f.TAB:if(!a.menu.active)return;a.menu.select(c);break;case f.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!=
+a.element.val()){a.selectedItem=null;a.search(null,c)}},a.options.delay);break}}}).bind("keypress.autocomplete",function(c){if(g){g=false;c.preventDefault()}}).bind("focus.autocomplete",function(){if(!a.options.disabled){a.selectedItem=null;a.previous=a.element.val()}}).bind("blur.autocomplete",function(c){if(!a.options.disabled){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)}});this._initSource();this.response=function(){return a._response.apply(a,arguments)};
+this.menu=d("").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||"body",b)[0]).mousedown(function(c){var f=a.menu.element[0];d(c.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(h){h.target!==a.element[0]&&h.target!==f&&!d.ui.contains(f,h.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(c,f){f=f.item.data("item.autocomplete");false!==a._trigger("focus",c,{item:f})&&/^key/.test(c.originalEvent.type)&&
+a.element.val(f.value)},selected:function(c,f){var h=f.item.data("item.autocomplete"),i=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=i;setTimeout(function(){a.previous=i;a.selectedItem=h},1)}false!==a._trigger("select",c,{item:h})&&a.element.val(h.value);a.term=a.element.val();a.close(c);a.selectedItem=h},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");
+d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();if(a==="appendTo")this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&&
+b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,g;if(d.isArray(this.options.source)){b=this.options.source;this.source=function(c,f){f(d.ui.autocomplete.filter(b,c.term))}}else if(typeof this.options.source==="string"){g=this.options.source;this.source=function(c,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:g,data:c,dataType:"json",autocompleteRequest:++e,success:function(h){this.autocompleteRequest===e&&f(h)},error:function(){this.autocompleteRequest===e&&f([])}})}}else this.source=
+this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length").data("item.autocomplete",b).append(d(" ").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,
+"\\$&")},filter:function(a,b){var g=new RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(c){return g.test(c.label||c.value||c)})}})})(jQuery);
+(function(d){d.widget("ui.menu",{_create:function(){var e=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){if(d(a.target).closest(".ui-menu-item a").length){a.preventDefault();e.select(a)}});this.refresh()},refresh:function(){var e=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
+-1).mouseenter(function(a){e.activate(a,d(this).parent())}).mouseleave(function(){e.deactivate()})},activate:function(e,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,g=this.element.scrollTop(),c=this.element.height();if(b<0)this.element.scrollTop(g+b);else b>=c&&this.element.scrollTop(g+b-c+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",e,{item:a})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");
+this._trigger("blur");this.active=null}},next:function(e){this.move("next",".ui-menu-item:first",e)},previous:function(e){this.move("prev",".ui-menu-item:last",e)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(e,a,b){if(this.active){e=this.active[e+"All"](".ui-menu-item").eq(0);e.length?this.activate(b,e):this.activate(b,this.element.children(a))}else this.activate(b,
+this.element.children(a))},nextPage:function(e){if(this.hasScroll())if(!this.active||this.last())this.activate(e,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return c<10&&c>-10});g.length||(g=this.element.children(".ui-menu-item:last"));this.activate(e,g)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
+this.last()?":first":":last"))},previousPage:function(e){if(this.hasScroll())if(!this.active||this.first())this.activate(e,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var g=d(this).offset().top-a+b-d(this).height();return g<10&&g>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(e,result)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
+this.first()?":last":":first"))},hasScroll:function(){return this.element.height()").addClass("ui-button-text").html(this.options.label).appendTo(a.empty()).text(),e=this.options.icons,f=e.primary&&e.secondary,d=[];if(e.primary||e.secondary){if(this.options.text)d.push("ui-button-text-icon"+(f?"s":e.primary?"-primary":"-secondary"));e.primary&&a.prepend(" ");e.secondary&&a.append(" ");if(!this.options.text){d.push(f?"ui-button-icons-only":
+"ui-button-icon-only");this.hasTitle||a.attr("title",c)}}else d.push("ui-button-text-only");a.addClass(d.join(" "))}}});b.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(a,c){a==="disabled"&&this.buttons.button("option",a,c);b.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var a=this.element.css("direction")===
+"ltr";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(a?"ui-corner-left":"ui-corner-right").end().filter(":last").addClass(a?"ui-corner-right":"ui-corner-left").end().end()},destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy");
+b.Widget.prototype.destroy.call(this)}})})(jQuery);
+;/*
+ * jQuery UI Dialog 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Dialog
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.widget.js
+ * jquery.ui.button.js
+ * jquery.ui.draggable.js
+ * jquery.ui.mouse.js
+ * jquery.ui.position.js
+ * jquery.ui.resizable.js
+ */
+(function(c,l){var m={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},n={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true},o=c.attrFn||{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true,click:true};c.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,
+position:{my:"center",at:"center",collision:"fit",using:function(a){var b=c(this).css(a).offset().top;b<0&&c(this).css("top",a.top-b)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var a=this,b=a.options,d=b.title||" ",e=c.ui.dialog.getTitleId(a.element),g=(a.uiDialog=c("
")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+
+b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(i){if(b.closeOnEscape&&!i.isDefaultPrevented()&&i.keyCode&&i.keyCode===c.ui.keyCode.ESCAPE){a.close(i);i.preventDefault()}}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(i){a.moveToTop(false,i)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g);var f=(a.uiDialogTitlebar=c("
")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g),
+h=c(' ').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(i){a.close(i);return false}).appendTo(f);(a.uiDialogTitlebarCloseText=c(" ")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(h);c(" ").addClass("ui-dialog-title").attr("id",
+e).html(d).prependTo(f);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose=b.beforeclose;f.find("*").add(f).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=false;c.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;a.overlay&&a.overlay.destroy();a.uiDialog.hide();a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");
+a.uiDialog.remove();a.originalTitle&&a.element.attr("title",a.originalTitle);return a},widget:function(){return this.uiDialog},close:function(a){var b=this,d,e;if(false!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=false;if(b.options.hide)b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)});else{b.uiDialog.hide();b._trigger("close",a)}c.ui.dialog.overlay.resize();if(b.options.modal){d=0;c(".ui-dialog").each(function(){if(this!==
+b.uiDialog[0]){e=c(this).css("z-index");isNaN(e)||(d=Math.max(d,e))}});c.ui.dialog.maxZ=d}return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this,e=d.options;if(e.modal&&!a||!e.stack&&!e.modal)return d._trigger("focus",b);if(e.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=e.zIndex;if(d.overlay){c.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ)}a={scrollTop:d.element.scrollTop(),scrollLeft:d.element.scrollLeft()};c.ui.dialog.maxZ+=1;
+d.uiDialog.css("z-index",c.ui.dialog.maxZ);d.element.attr(a);d._trigger("focus",b);return d},open:function(){if(!this._isOpen){var a=this,b=a.options,d=a.uiDialog;a.overlay=b.modal?new c.ui.dialog.overlay(a):null;a._size();a._position(b.position);d.show(b.show);a.moveToTop(true);b.modal&&d.bind("keypress.ui-dialog",function(e){if(e.keyCode===c.ui.keyCode.TAB){var g=c(":tabbable",this),f=g.filter(":first");g=g.filter(":last");if(e.target===g[0]&&!e.shiftKey){f.focus(1);return false}else if(e.target===
+f[0]&&e.shiftKey){g.focus(1);return false}}});c(a.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus();a._isOpen=true;a._trigger("open");return a}},_createButtons:function(a){var b=this,d=false,e=c("
").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),g=c("
").addClass("ui-dialog-buttonset").appendTo(e);b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&a!==null&&c.each(a,
+function(){return!(d=true)});if(d){c.each(a,function(f,h){h=c.isFunction(h)?{click:h,text:f}:h;var i=c(' ').click(function(){h.click.apply(b.element[0],arguments)}).appendTo(g);c.each(h,function(j,k){if(j!=="click")j in o?i[j](k):i.attr(j,k)});c.fn.button&&i.button()});e.appendTo(b.uiDialog)}},_makeDraggable:function(){function a(f){return{position:f.position,offset:f.offset}}var b=this,d=b.options,e=c(document),g;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",
+handle:".ui-dialog-titlebar",containment:"document",start:function(f,h){g=d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging");b._trigger("dragStart",f,a(h))},drag:function(f,h){b._trigger("drag",f,a(h))},stop:function(f,h){d.position=[h.position.left-e.scrollLeft(),h.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(g);b._trigger("dragStop",f,a(h));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(f){return{originalPosition:f.originalPosition,
+originalSize:f.originalSize,position:f.position,size:f.size}}a=a===l?this.options.resizable:a;var d=this,e=d.options,g=d.uiDialog.css("position");a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(f,h){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",f,b(h))},resize:function(f,h){d._trigger("resize",
+f,b(h))},stop:function(f,h){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop",f,b(h));c.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0],e;if(a){if(typeof a==="string"||typeof a==="object"&&"0"in a){b=a.split?a.split(" "):
+[a[0],a[1]];if(b.length===1)b[1]=b[0];c.each(["left","top"],function(g,f){if(+b[g]===b[g]){d[g]=b[g];b[g]=f}});a={my:b.join(" "),at:b.join(" "),offset:d.join(" ")}}a=c.extend({},c.ui.dialog.prototype.options.position,a)}else a=c.ui.dialog.prototype.options.position;(e=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(c.extend({of:window},a));e||this.uiDialog.hide()},_setOptions:function(a){var b=this,d={},e=false;c.each(a,function(g,f){b._setOption(g,f);
+if(g in m)e=true;if(g in n)d[g]=f});e&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(a,b){var d=this,e=d.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":d._createButtons(b);break;case "closeText":d.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":e.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?e.addClass("ui-dialog-disabled"):
+e.removeClass("ui-dialog-disabled");break;case "draggable":var g=e.is(":data(draggable)");g&&!b&&e.draggable("destroy");!g&&b&&d._makeDraggable();break;case "position":d._position(b);break;case "resizable":(g=e.is(":data(resizable)"))&&!b&&e.resizable("destroy");g&&typeof b==="string"&&e.resizable("option","handles",b);!g&&b!==false&&d._makeResizable(b);break;case "title":c(".ui-dialog-title",d.uiDialogTitlebar).html(""+(b||" "));break}c.Widget.prototype._setOption.apply(d,arguments)},_size:function(){var a=
+this.options,b,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(a.minWidth>a.width)a.width=a.minWidth;b=this.uiDialog.css({height:"auto",width:a.width}).height();d=Math.max(0,a.minHeight-b);if(a.height==="auto")if(c.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();a=this.element.css("height","auto").height();e||this.uiDialog.hide();this.element.height(Math.max(a,d))}else this.element.height(Math.max(a.height-
+b,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.16",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a){this.uuid+=1;a=this.uuid}return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),
+create:function(a){if(this.instances.length===0){setTimeout(function(){c.ui.dialog.overlay.instances.length&&c(document).bind(c.ui.dialog.overlay.events,function(d){if(c(d.target).zIndex()").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});c.fn.bgiframe&&b.bgiframe();this.instances.push(b);return b},destroy:function(a){var b=c.inArray(a,this.instances);b!=-1&&this.oldInstances.push(this.instances.splice(b,1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var d=0;c.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){var a,b;if(c.browser.msie&&
+c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);b=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return a",remove:null,select:null,show:null,spinner:"Loading… ",tabTemplate:"#{label} "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&&
+e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b=
+d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]||
+(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
+this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected=
+this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");
+if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));
+this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+
+g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal",
+function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")};
+this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected=
+-1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier.";
+d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=
+d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b,
+e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]);
+j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove();
+if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null,
+this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this},
+load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c,
+"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},
+url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.16"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k'))}function N(a){return a.bind("mouseout",
+function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");b.length&&b.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!(d.datepicker._isDisabledDatepicker(J.inline?a.parent()[0]:J.input[0])||!b.length)){b.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
+b.addClass("ui-state-hover");b.hasClass("ui-datepicker-prev")&&b.addClass("ui-datepicker-prev-hover");b.hasClass("ui-datepicker-next")&&b.addClass("ui-datepicker-next-hover")}})}function H(a,b){d.extend(a,b);for(var c in b)if(b[c]==null||b[c]==C)a[c]=b[c];return a}d.extend(d.ui,{datepicker:{version:"1.8.16"}});var B=(new Date).getTime(),J;d.extend(M.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},
+setDefaults:function(a){H(this._defaults,a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();f=e=="div"||e=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input")this._connectDatepicker(a,i);else f&&this._inlineDatepicker(a,i)},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g,
+"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:N(d('
'))}},_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",
+function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b);b.settings.disabled&&this._disableDatepicker(a)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&b.append.remove();if(c){b.append=d(''+c+" ");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c==
+"focus"||c=="both")a.focus(this._showDatepicker);if(c=="button"||c=="both"){c=this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d(" ").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d(' ').addClass(this._triggerClass).html(f==""?c:d(" ").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker():
+d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;gh){h=f[g].length;i=g}return i};b.setMonth(e(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,
+b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),true);this._updateDatepicker(b);this._updateAlternate(b);b.settings.disabled&&this._disableDatepicker(a);b.dpDiv.css("display","block")}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){this.uuid+=
+1;this._dialogInput=d(' ');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}H(a.settings,e||{});b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos)this._pos=[document.documentElement.clientWidth/
+2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)];this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b=
+d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else if(e=="div"||e=="span")b.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=
+a.nodeName.toLowerCase();if(e=="input"){a.disabled=false;c.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().removeClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f})}},_disableDatepicker:function(a){var b=d(a),c=d.data(a,
+"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=true;c.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",cursor:"default"})}else if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().addClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==
+a?null:f});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(a){if(!a)return false;for(var b=0;b-1}},_doKeyUp:function(a){a=d.datepicker._getInst(a.target);if(a.input.val()!=a.lastVal)try{if(d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),a.input?a.input.val():null,d.datepicker._getFormatConfig(a))){d.datepicker._setDateFromField(a);d.datepicker._updateAlternate(a);d.datepicker._updateDatepicker(a)}}catch(b){d.datepicker.log(b)}return true},_showDatepicker:function(a){a=a.target||a;if(a.nodeName.toLowerCase()!="input")a=d("input",
+a.parentNode)[0];if(!(d.datepicker._isDisabledDatepicker(a)||d.datepicker._lastInput==a)){var b=d.datepicker._getInst(a);if(d.datepicker._curInst&&d.datepicker._curInst!=b){d.datepicker._datepickerShowing&&d.datepicker._triggerOnClose(d.datepicker._curInst);d.datepicker._curInst.dpDiv.stop(true,true)}var c=d.datepicker._get(b,"beforeShow");c=c?c.apply(a,[a,b]):{};if(c!==false){H(b.settings,c);b.lastVal=null;d.datepicker._lastInput=a;d.datepicker._setDateFromField(b);if(d.datepicker._inDialog)a.value=
+"";if(!d.datepicker._pos){d.datepicker._pos=d.datepicker._findPos(a);d.datepicker._pos[1]+=a.offsetHeight}var e=false;d(a).parents().each(function(){e|=d(this).css("position")=="fixed";return!e});if(e&&d.browser.opera){d.datepicker._pos[0]-=document.documentElement.scrollLeft;d.datepicker._pos[1]-=document.documentElement.scrollTop}c={left:d.datepicker._pos[0],top:d.datepicker._pos[1]};d.datepicker._pos=null;b.dpDiv.empty();b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});d.datepicker._updateDatepicker(b);
+c=d.datepicker._checkOffset(b,c,e);b.dpDiv.css({position:d.datepicker._inDialog&&d.blockUI?"static":e?"fixed":"absolute",display:"none",left:c.left+"px",top:c.top+"px"});if(!b.inline){c=d.datepicker._get(b,"showAnim");var f=d.datepicker._get(b,"duration"),h=function(){var i=b.dpDiv.find("iframe.ui-datepicker-cover");if(i.length){var g=d.datepicker._getBorders(b.dpDiv);i.css({left:-g[0],top:-g[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex(d(a).zIndex()+1);d.datepicker._datepickerShowing=
+true;d.effects&&d.effects[c]?b.dpDiv.show(c,d.datepicker._get(b,"showOptions"),f,h):b.dpDiv[c||"show"](c?f:null,h);if(!c||!f)h();b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus();d.datepicker._curInst=b}}}},_updateDatepicker:function(a){this.maxRows=4;var b=d.datepicker._getBorders(a.dpDiv);J=a;a.dpDiv.empty().append(this._generateHTML(a));var c=a.dpDiv.find("iframe.ui-datepicker-cover");c.length&&c.css({left:-b[0],top:-b[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()});
+a.dpDiv.find("."+this._dayOverClass+" a").mouseover();b=this._getNumberOfMonths(a);c=b[1];a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");c>1&&a.dpDiv.addClass("ui-datepicker-multi-"+c).css("width",17*c+"em");a.dpDiv[(b[0]!=1||b[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");a==d.datepicker._curInst&&d.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&
+!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var e=a.yearshtml;setTimeout(function(){e===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml);e=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(c){return{thin:1,medium:2,thick:3}[c]||c};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var e=a.dpDiv.outerWidth(),f=a.dpDiv.outerHeight(),
+h=a.input?a.input.outerWidth():0,i=a.input?a.input.outerHeight():0,g=document.documentElement.clientWidth+d(document).scrollLeft(),j=document.documentElement.clientHeight+d(document).scrollTop();b.left-=this._get(a,"isRTL")?e-h:0;b.left-=c&&b.left==a.input.offset().left?d(document).scrollLeft():0;b.top-=c&&b.top==a.input.offset().top+i?d(document).scrollTop():0;b.left-=Math.min(b.left,b.left+e>g&&g>e?Math.abs(b.left+e-g):0);b.top-=Math.min(b.top,b.top+f>j&&j>f?Math.abs(f+i):0);return b},_findPos:function(a){for(var b=
+this._get(this._getInst(a),"isRTL");a&&(a.type=="hidden"||a.nodeType!=1||d.expr.filters.hidden(a));)a=a[b?"previousSibling":"nextSibling"];a=d(a).offset();return[a.left,a.top]},_triggerOnClose:function(a){var b=this._get(a,"onClose");if(b)b.apply(a.input?a.input[0]:null,[a.input?a.input.val():"",a])},_hideDatepicker:function(a){var b=this._curInst;if(!(!b||a&&b!=d.data(a,"datepicker")))if(this._datepickerShowing){a=this._get(b,"showAnim");var c=this._get(b,"duration"),e=function(){d.datepicker._tidyDialog(b);
+this._curInst=null};d.effects&&d.effects[a]?b.dpDiv.hide(a,d.datepicker._get(b,"showOptions"),c,e):b.dpDiv[a=="slideDown"?"slideUp":a=="fadeIn"?"fadeOut":"hide"](a?c:null,e);a||e();d.datepicker._triggerOnClose(b);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",left:"0",top:"-100px"});if(d.blockUI){d.unblockUI();d("body").append(this.dpDiv)}}this._inDialog=false}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},
+_checkExternalClick:function(a){if(d.datepicker._curInst){a=d(a.target);a[0].id!=d.datepicker._mainDivId&&a.parents("#"+d.datepicker._mainDivId).length==0&&!a.hasClass(d.datepicker.markerClassName)&&!a.hasClass(d.datepicker._triggerClass)&&d.datepicker._datepickerShowing&&!(d.datepicker._inDialog&&d.blockUI)&&d.datepicker._hideDatepicker()}},_adjustDate:function(a,b,c){a=d(a);var e=this._getInst(a[0]);if(!this._isDisabledDatepicker(a[0])){this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):
+0),c);this._updateDatepicker(e)}},_gotoToday:function(a){a=d(a);var b=this._getInst(a[0]);if(this._get(b,"gotoCurrent")&&b.currentDay){b.selectedDay=b.currentDay;b.drawMonth=b.selectedMonth=b.currentMonth;b.drawYear=b.selectedYear=b.currentYear}else{var c=new Date;b.selectedDay=c.getDate();b.drawMonth=b.selectedMonth=c.getMonth();b.drawYear=b.selectedYear=c.getFullYear()}this._notifyChange(b);this._adjustDate(a)},_selectMonthYear:function(a,b,c){a=d(a);var e=this._getInst(a[0]);e["selected"+(c=="M"?
+"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_selectDay:function(a,b,c,e){var f=d(a);if(!(d(e).hasClass(this._unselectableClass)||this._isDisabledDatepicker(f[0]))){f=this._getInst(f[0]);f.selectedDay=f.currentDay=d("a",e).html();f.selectedMonth=f.currentMonth=b;f.selectedYear=f.currentYear=c;this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))}},_clearDate:function(a){a=d(a);
+this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,b){a=this._getInst(d(a)[0]);b=b!=null?b:this._formatDate(a);a.input&&a.input.val(b);this._updateAlternate(a);var c=this._get(a,"onSelect");if(c)c.apply(a.input?a.input[0]:null,[b,a]);else a.input&&a.input.trigger("change");if(a.inline)this._updateDatepicker(a);else{this._hideDatepicker();this._lastInput=a.input[0];typeof a.input[0]!="object"&&a.input.focus();this._lastInput=null}},_updateAlternate:function(a){var b=this._get(a,"altField");
+if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),f=this.formatDate(c,e,this._getFormatConfig(a));d(b).each(function(){d(this).val(f)})}},noWeekends:function(a){a=a.getDay();return[a>0&&a<6,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b=a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((b-a)/864E5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"?
+b.toString():b+"";if(b=="")return null;var e=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;e=typeof e!="string"?e:(new Date).getFullYear()%100+parseInt(e,10);for(var f=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,h=(c?c.dayNames:null)||this._defaults.dayNames,i=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,j=c=-1,l=-1,u=-1,k=false,o=function(p){(p=A+1-1){j=1;l=u;do{e=this._getDaysInMonth(c,j-1);if(l<=e)break;j++;l-=e}while(1)}v=this._daylightSavingAdjust(new Date(c,j-1,l));if(v.getFullYear()!=c||v.getMonth()+1!=j||v.getDate()!=l)throw"Invalid date";return v},ATOM:"yy-mm-dd",
+COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1E7,formatDate:function(a,b,c){if(!b)return"";var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,h=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort;c=(c?c.monthNames:
+null)||this._defaults.monthNames;var i=function(o){(o=k+1
+12?a.getHours()+2:0);return a},_setDate:function(a,b,c){var e=!b,f=a.selectedMonth,h=a.selectedYear;b=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=b.getDate();a.drawMonth=a.selectedMonth=a.currentMonth=b.getMonth();a.drawYear=a.selectedYear=a.currentYear=b.getFullYear();if((f!=a.selectedMonth||h!=a.selectedYear)&&!c)this._notifyChange(a);this._adjustInstDate(a);if(a.input)a.input.val(e?"":this._formatDate(a))},_getDate:function(a){return!a.currentYear||a.input&&
+a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay))},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),e=this._get(a,"showButtonPanel"),f=this._get(a,"hideIfNoPrevNext"),h=this._get(a,"navigationAsDateFormat"),i=this._getNumberOfMonths(a),g=this._get(a,"showCurrentAtPos"),j=this._get(a,"stepMonths"),l=i[0]!=1||i[1]!=1,u=this._daylightSavingAdjust(!a.currentDay?
+new Date(9999,9,9):new Date(a.currentYear,a.currentMonth,a.currentDay)),k=this._getMinMaxDate(a,"min"),o=this._getMinMaxDate(a,"max");g=a.drawMonth-g;var m=a.drawYear;if(g<0){g+=12;m--}if(o){var n=this._daylightSavingAdjust(new Date(o.getFullYear(),o.getMonth()-i[0]*i[1]+1,o.getDate()));for(n=k&&nn;){g--;if(g<0){g=11;m--}}}a.drawMonth=g;a.drawYear=m;n=this._get(a,"prevText");n=!h?n:this.formatDate(n,this._daylightSavingAdjust(new Date(m,g-j,1)),this._getFormatConfig(a));
+n=this._canAdjustMonth(a,-1,m,g)?''+n+" ":f?"":''+n+" ";var s=this._get(a,"nextText");s=!h?s:this.formatDate(s,this._daylightSavingAdjust(new Date(m,
+g+j,1)),this._getFormatConfig(a));f=this._canAdjustMonth(a,+1,m,g)?''+s+" ":f?"":''+s+" ";j=this._get(a,"currentText");s=this._get(a,"gotoCurrent")&&
+a.currentDay?u:b;j=!h?j:this.formatDate(j,s,this._getFormatConfig(a));h=!a.inline?''+this._get(a,"closeText")+" ":"";e=e?''+(c?h:"")+(this._isInRange(a,s)?'"+j+" ":"")+(c?"":h)+"
":"";h=parseInt(this._get(a,"firstDay"),10);h=isNaN(h)?0:h;j=this._get(a,"showWeek");s=this._get(a,"dayNames");this._get(a,"dayNamesShort");var q=this._get(a,"dayNamesMin"),A=this._get(a,"monthNames"),v=this._get(a,"monthNamesShort"),p=this._get(a,"beforeShowDay"),D=this._get(a,"showOtherMonths"),K=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var E=this._getDefaultDate(a),w="",x=0;x'}y+='';var z=j?''+this._get(a,"weekHeader")+" ":"";for(t=0;t<7;t++){var r=(t+h)%7;z+="=5?' class="ui-datepicker-week-end"':"")+'>'+q[r]+" "}y+=z+" ";z=this._getDaysInMonth(m,g);if(m==a.selectedYear&&g==a.selectedMonth)a.selectedDay=Math.min(a.selectedDay,
+z);t=(this._getFirstDayOfMonth(m,g)-h+7)%7;z=Math.ceil((t+z)/7);this.maxRows=z=l?this.maxRows>z?this.maxRows:z:z;r=this._daylightSavingAdjust(new Date(m,g,1-t));for(var Q=0;Q";var R=!j?"":''+this._get(a,"calculateWeek")(r)+" ";for(t=0;t<7;t++){var I=p?p.apply(a.input?a.input[0]:null,[r]):[true,""],F=r.getMonth()!=g,L=F&&!K||!I[0]||k&&ro;R+='"+(F&&!D?" ":L?''+
+r.getDate()+" ":''+r.getDate()+" ")+" ";r.setDate(r.getDate()+1);r=this._daylightSavingAdjust(r)}y+=R+""}g++;if(g>11){g=0;m++}y+="
"+(l?""+(i[0]>0&&G==i[1]-1?'
':""):"");O+=y}w+=O}w+=e+(d.browser.msie&&parseInt(d.browser.version,10)<7&&!a.inline?'':
+"");a._keyEvent=false;return w},_generateMonthYearHeader:function(a,b,c,e,f,h,i,g){var j=this._get(a,"changeMonth"),l=this._get(a,"changeYear"),u=this._get(a,"showMonthAfterYear"),k='',o="";if(h||!j)o+=''+i[b]+" ";else{i=e&&e.getFullYear()==c;var m=f&&f.getFullYear()==c;o+='";for(var n=0;n<12;n++)if((!i||n>=e.getMonth())&&
+(!m||n<=f.getMonth()))o+='"+g[n]+" ";o+=" "}u||(k+=o+(h||!(j&&l)?" ":""));if(!a.yearshtml){a.yearshtml="";if(h||!l)k+=''+c+" ";else{g=this._get(a,"yearRange").split(":");var s=(new Date).getFullYear();i=function(q){q=q.match(/c[+-].*/)?c+parseInt(q.substring(1),10):q.match(/[+-].*/)?s+parseInt(q,10):parseInt(q,10);return isNaN(q)?s:q};b=i(g[0]);g=Math.max(b,i(g[1]||""));b=e?Math.max(b,
+e.getFullYear()):b;g=f?Math.min(g,f.getFullYear()):g;for(a.yearshtml+='";b<=g;b++)a.yearshtml+='"+b+" ";a.yearshtml+=" ";k+=a.yearshtml;a.yearshtml=null}}k+=this._get(a,"yearSuffix");if(u)k+=(h||!(j&&l)?" ":"")+o;k+="
";return k},_adjustInstDate:function(a,b,c){var e=a.drawYear+(c=="Y"?b:0),f=a.drawMonth+
+(c=="M"?b:0);b=Math.min(a.selectedDay,this._getDaysInMonth(e,f))+(c=="D"?b:0);e=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(e,f,b)));a.selectedDay=e.getDate();a.drawMonth=a.selectedMonth=e.getMonth();a.drawYear=a.selectedYear=e.getFullYear();if(c=="M"||c=="Y")this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");b=c&&ba?a:b},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");if(b)b.apply(a.input?
+a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return a==null?[1,1]:typeof a=="number"?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,e){var f=this._getNumberOfMonths(a);c=this._daylightSavingAdjust(new Date(c,
+e+(b<0?b:f[0]*f[1]),1));b<0&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!a||b.getTime()<=a.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,
+"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,e){if(!b){a.currentDay=a.selectedDay;a.currentMonth=a.selectedMonth;a.currentYear=a.selectedYear}b=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(e,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});d.fn.datepicker=function(a){if(!this.length)return this;
+if(!d.datepicker.initialized){d(document).mousedown(d.datepicker._checkExternalClick).find("body").append(d.datepicker.dpDiv);d.datepicker.initialized=true}var b=Array.prototype.slice.call(arguments,1);if(typeof a=="string"&&(a=="isDisabled"||a=="getDate"||a=="widget"))return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b));if(a=="option"&&arguments.length==2&&typeof arguments[1]=="string")return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b));return this.each(function(){typeof a==
+"string"?d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this].concat(b)):d.datepicker._attachDatepicker(this,a)})};d.datepicker=new M;d.datepicker.initialized=false;d.datepicker.uuid=(new Date).getTime();d.datepicker.version="1.8.16";window["DP_jQuery_"+B]=d})(jQuery);
+;/*
+ * jQuery UI Progressbar 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Progressbar
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.widget.js
+ */
+(function(b,d){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow");
+this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(a){if(a===d)return this._value();this._setOption("value",a);return this},_setOption:function(a,c){if(a==="value"){this.options.value=c;this._refreshValue();this._value()===this.options.max&&this._trigger("complete")}b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;if(typeof a!=="number")a=0;return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*
+this._value()/this.options.max},_refreshValue:function(){var a=this.value(),c=this._percentage();if(this.oldValue!==a){this.oldValue=a;this._trigger("change")}this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(c.toFixed(0)+"%");this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.16"})})(jQuery);
+;/*
+ * jQuery UI Effects 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Effects/
+ */
+jQuery.effects||function(f,j){function m(c){var a;if(c&&c.constructor==Array&&c.length==3)return c;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt(a[1],
+16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(c))return n.transparent;return n[f.trim(c).toLowerCase()]}function s(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body"))break;a="backgroundColor"}while(c=c.parentNode);return m(b)}function o(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,
+a={},b,d;if(c&&c.length&&c[0]&&c[c[0]])for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}else for(b in c)if(typeof c[b]==="string")a[b]=c[b];return a}function p(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in t||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b)))delete c[a]}return c}function u(c,a){var b={_:0},d;for(d in a)if(c[d]!=a[d])b[d]=a[d];return b}function k(c,a,b,d){if(typeof c=="object"){d=
+a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}if(f.isFunction(b)){d=b;b=null}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:b in f.fx.speeds?f.fx.speeds[b]:f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}function l(c){if(!c||typeof c==="number"||f.fx.speeds[c])return true;if(typeof c==="string"&&!f.effects[c])return true;return false}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor",
+"borderTopColor","borderColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=s(b.elem,a);b.end=m(b.end);b.colorInit=true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var n={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,
+0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,
+211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},q=["add","remove","toggle"],t={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b,
+d){if(f.isFunction(b)){d=b;b=null}return this.queue(function(){var e=f(this),g=e.attr("style")||" ",h=p(o.call(this)),r,v=e.attr("class");f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});r=p(o.call(this));e.attr("class",v);e.animate(u(h,r),{queue:false,duration:a,easing:b,complete:function(){f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else e.attr("style",g);d&&d.apply(this,arguments);f.dequeue(this)}})})};
+f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===j?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this,
+[{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.16",save:function(c,a){for(var b=0;b").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),
+d=document.activeElement;c.wrap(b);if(c[0]===d||f.contains(c[0],d))f(d).focus();b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(e,g){a[g]=c.css(g);if(isNaN(parseInt(a[g],10)))a[g]="auto"});c.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}return b.css(a).show()},removeWrapper:function(c){var a,b=document.activeElement;
+if(c.parent().is(".ui-effects-wrapper")){a=c.parent().replaceWith(c);if(c[0]===b||f.contains(c[0],b))f(b).focus();return a}return c},setTransition:function(c,a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=k.apply(this,arguments),b={options:a[1],duration:a[2],callback:a[3]};a=b.options.mode;var d=f.effects[c];if(f.fx.off||!d)return a?this[a](b.duration,b.callback):this.each(function(){b.callback&&b.callback.call(this)});
+return d.call(this,b)},_show:f.fn.show,show:function(c){if(l(c))return this._show.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(l(c))return this._hide.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(l(c)||typeof c==="boolean"||f.isFunction(c))return this.__toggle.apply(this,arguments);else{var a=k.apply(this,
+arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%","pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,a,b,d,e){if((a/=e/2)<1)return d/
+2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(c,a,b,
+d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,10*(a/e-1))+b},easeOutExpo:function(c,
+a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(c,a,b,
+d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h').appendTo(document.body).addClass(a.options.className).css({top:d.top,left:d.left,height:b.innerHeight(),width:b.innerWidth(),position:"absolute"}).animate(c,a.duration,a.options.easing,function(){f.remove();a.callback&&a.callback.apply(b[0],arguments);
+b.dequeue()})})}})(jQuery);
+;
\ No newline at end of file
diff --git a/install/js/jquery.min.js b/install/js/jquery.min.js
new file mode 100644
index 000000000..8cdc80eb8
--- /dev/null
+++ b/install/js/jquery.min.js
@@ -0,0 +1,18 @@
+/*!
+ * jQuery JavaScript Library v1.6.2
+ * http://jquery.com/
+ *
+ * Copyright 2011, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2011, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Thu Jun 30 14:16:56 2011 -0400
+ */
+(function(a,b){function cv(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cs(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cr(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cq(){cn=b}function cp(){setTimeout(cq,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bx(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bm(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(be,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bl(a){f.nodeName(a,"input")?bk(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bk)}function bk(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bj(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bi(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bh(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z])/ig,x=function(a,b){return b.toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!A){A=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||D.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;ca ",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0},m&&f.extend(p,{position:"absolute",left:-1e3,top:-1e3});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]||i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=w:v&&c!=="className"&&(f.nodeName(a,"form")||u.test(c))&&(i=v)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}},value:{get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return f.prop(a,c)?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.attrHooks.title=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j =0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.
+shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},J=function(c){var d=c.target,e,g;if(!!y.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=I(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:J,beforedeactivate:J,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&J.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&J.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",I(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in H)f.event.add(this,c+".specialChange",H[c]);return y.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return y.test(this.nodeName)}},H=f.event.special.change.filters,H.focus=H.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c ",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML=" ",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="
";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=T.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var X=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,Z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,$=/<([\w:]+)/,_=/",""],legend:[1,""," "],thead:[1,""],tr:[2,""],td:[3,""],col:[2,""],area:[1,""," "],_default:[0,"",""]};bf.optgroup=bf.option,bf.tbody=bf.tfoot=bf.colgroup=bf.caption=bf.thead,bf.th=bf.td,f.support.htmlSerialize||(bf._default=[1,"div","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!bf[($.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Z,"<$1>$2>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j
+)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bi(a,d),e=bj(a),g=bj(d);for(h=0;e[h];++h)bi(e[h],g[h])}if(b){bh(a,d);if(c){e=bj(a),g=bj(d);for(h=0;e[h];++h)bh(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!ba.test(k))k=b.createTextNode(k);else{k=k.replace(Z,"<$1>$2>");var l=($.exec(k)||["",""])[1].toLowerCase(),m=bf[l]||bf._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=_.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Y.test(k)&&o.insertBefore(b.createTextNode(Y.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bo.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bn.test(g)?g.replace(bn,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bx=by||bz,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bB=/%20/g,bC=/\[\]$/,bD=/\r?\n/g,bE=/#.*$/,bF=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bG=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bH=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bI=/^(?:GET|HEAD)$/,bJ=/^\/\//,bK=/\?/,bL=/
+
+
+
+
+
+
+
+
+
+
+ ';
+
+// HEADER
+echo '
+
+ ';
+//FOOTER
+// DON'T MODIFY THE FOOTER
+echo '
+ ';
+?>
+
+
diff --git a/install/upgrade_ajax.php b/install/upgrade_ajax.php
new file mode 100644
index 000000000..6130734ef
--- /dev/null
+++ b/install/upgrade_ajax.php
@@ -0,0 +1,957 @@
+put("CPM", 1, "SESSION");
+$superGlobal->put("db_encoding", "utf8", "SESSION");
+$_SESSION['settings']['loaded'] = "";
+if (empty($post_fullurl) === false) {
+ $superGlobal->put("fullurl", $post_fullurl, "SESSION");
+}
+if (empty($abspath) === false) {
+ $superGlobal->put("abspath", $abspath, "SESSION");
+}
+
+// Get Sessions
+$session_url_path = $superGlobal->get("url_path", "SESSION");
+
+################
+## Function permits to get the value from a line
+################
+/**
+ * @param string $val
+ */
+function getSettingValue($val)
+{
+ $val = trim(strstr($val, "="));
+ return trim(str_replace('"', '', substr($val, 1, strpos($val, ";") - 1)));
+}
+
+################
+## Function permits to check if a column exists, and if not to add it
+################
+function addColumnIfNotExist($dbname, $column, $columnAttr = "VARCHAR(255) NULL")
+{
+ global $db_link;
+ $exists = false;
+ $columns = mysqli_query($db_link, "show columns from $dbname");
+ while ($col = mysqli_fetch_assoc($columns)) {
+ if ($col['Field'] == $column) {
+ $exists = true;
+ break;
+ }
+ }
+ if (!$exists) {
+ return mysqli_query($db_link, "ALTER TABLE `$dbname` ADD `$column` $columnAttr");
+ }
+}
+
+function addIndexIfNotExist($table, $index, $sql)
+{
+ global $db_link;
+
+ $mysqli_result = mysqli_query($db_link, "SHOW INDEX FROM $table WHERE key_name LIKE \"$index\"");
+ $res = mysqli_fetch_row($mysqli_result);
+
+ // if index does not exist, then add it
+ if (!$res) {
+ $res = mysqli_query($db_link, "ALTER TABLE `$table` ".$sql);
+ }
+
+ return $res;
+}
+
+function tableExists($tablename)
+{
+ global $db_link, $database;
+
+ $res = mysqli_query(
+ $db_link,
+ "SELECT COUNT(*) as count
+ FROM information_schema.tables
+ WHERE table_schema = '".$database."'
+ AND table_name = '$tablename'"
+ );
+
+ if ($res > 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+if (isset($post_type)) {
+ switch ($post_type) {
+ case "step0":
+ // erase session table
+ $_SESSION = array();
+ setcookie('pma_end_session');
+ session_destroy();
+
+ echo 'document.getElementById("res_step0").innerHTML = "";';
+ require_once 'libs/aesctr.php';
+
+ // check if path in settings.php are consistent
+ if (!is_dir(SECUREPATH)) {
+ echo 'document.getElementById("but_next").disabled = "disabled";';
+ echo 'document.getElementById("res_step0").innerHTML = "Error in settings.php file! Check correctness of path indicated in file `includes/config/settings.php`. Reload this page and retry.";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+ }
+ if (!file_exists(SECUREPATH."/sk.php")) {
+ echo 'document.getElementById("but_next").disabled = "disabled";';
+ echo 'document.getElementById("res_step0").innerHTML = "Error in settings.php file! Check that file `sk.php` exists as defined in `includes/config/settings.php`. Reload this page and retry.";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+ }
+
+ $_SESSION['settings']['cpassman_dir'] = "..";
+ require_once '../includes/libraries/PasswordLib/Random/Generator.php';
+ require_once '../includes/libraries/PasswordLib/Random/Source.php';
+ require_once '../includes/libraries/PasswordLib/Random/Source/MTRand.php';
+ require_once '../includes/libraries/PasswordLib/Random/Source/Rand.php';
+ require_once '../includes/libraries/PasswordLib/Random/Source/UniqID.php';
+ require_once '../includes/libraries/PasswordLib/Random/Source/URandom.php';
+ require_once '../includes/libraries/PasswordLib/Random/Source/MicroTime.php';
+ require_once '../includes/libraries/PasswordLib/Random/Source/CAPICOM.php';
+ require_once '../includes/libraries/PasswordLib/Random/Mixer.php';
+ require_once '../includes/libraries/PasswordLib/Random/AbstractMixer.php';
+ require_once '../includes/libraries/PasswordLib/Random/Mixer/Hash.php';
+ require_once '../includes/libraries/PasswordLib/Password/AbstractPassword.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/Hash.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/Crypt.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/SHA256.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/SHA512.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/PHPASS.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/PHPBB.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/PBKDF.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/MediaWiki.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/MD5.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/Joomla.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/Drupal.php';
+ require_once '../includes/libraries/PasswordLib/Password/Implementation/APR1.php';
+ require_once '../includes/libraries/PasswordLib/PasswordLib.php';
+ $pwdlib = new PasswordLib\PasswordLib();
+
+ // Connect to db and check user is granted
+ $user_info = mysqli_fetch_array(
+ mysqli_query(
+ $db_link,
+ "SELECT pw, admin FROM ".$pre."users
+ WHERE login='".mysqli_escape_string($db_link, stripslashes($post_login))."'"
+ )
+ );
+
+ if (empty($user_info['pw']) || $user_info['pw'] === null) {
+ echo 'document.getElementById("but_next").disabled = "disabled";';
+ echo 'document.getElementById("res_step0").innerHTML = "This user is not allowed!";';
+ echo 'document.getElementById("user_granted").value = "0";';
+ $superGlobal->put("user_granted", false, "SESSION");
+ } else {
+ if ($pwdlib->verifyPasswordHash(Encryption\Crypt\aesctr::decrypt(base64_decode($post_pwd), "cpm", 128), $user_info['pw']) === true && $user_info['admin'] === "1") {
+ echo 'document.getElementById("but_next").disabled = "";';
+ echo 'document.getElementById("res_step0").innerHTML = "User is granted.";';
+ echo 'document.getElementById("step").value = "1";';
+ echo 'document.getElementById("user_granted").value = "1";';
+ $superGlobal->put("user_granted", true, "SESSION");
+ } else {
+ echo 'document.getElementById("but_next").disabled = "disabled";';
+ echo 'document.getElementById("res_step0").innerHTML = "This user is not allowed!";';
+ echo 'document.getElementById("user_granted").value = "0";';
+ $superGlobal->put("user_granted", false, "SESSION");
+ }
+ }
+
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+
+ case "step1":
+ $session_user_granted = $superGlobal->get("user_granted", "SESSION");
+
+ if (intval($session_user_granted) !== 1) {
+ echo 'document.getElementById("res_step1").innerHTML = "User not connected anymore!";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+ }
+
+ $abspath = str_replace('\\', '/', $post_abspath);
+ if (substr($abspath, strlen($abspath) - 1) == "/") {
+ $abspath = substr($abspath, 0, strlen($abspath) - 1);
+ }
+ $okWritable = true;
+ $okExtensions = true;
+ $txt = "";
+ $var_x = 1;
+ $tab = array(
+ $abspath."/includes/config/settings.php",
+ $abspath."/includes/libraries/csrfp/libs/",
+ $abspath."/install/",
+ $abspath."/includes/",
+ $abspath."/includes/config/",
+ $abspath."/includes/avatars/",
+ $abspath."/files/",
+ $abspath."/upload/"
+ );
+ foreach ($tab as $elem) {
+ // try to create it if not existing
+ if (substr($elem, -1) === '/' && !is_dir($elem)) {
+ mkdir($elem);
+ }
+ // check if writable
+ if (is_writable($elem)) {
+ $txt .= ''.
+ $elem.' ';
+ } else {
+ $txt .= ''.
+ $elem.' ';
+ $okWritable = false;
+ }
+ $var_x++;
+ }
+
+ if (!extension_loaded('mcrypt')) {
+ $okExtensions = false;
+ $txt .= 'PHP extension \"mcrypt\"'.
+ ' ';
+ } else {
+ $txt .= 'PHP extension \"mcrypt\"'.
+ ' ';
+ }
+ if (!extension_loaded('openssl')) {
+ //$okExtensions = false;
+ $txt .= 'PHP extension \"openssl\"'.
+ ' ';
+ } else {
+ $txt .= 'PHP extension \"openssl\"'.
+ ' ';
+ }
+ if (!extension_loaded('gd')) {
+ //$okExtensions = false;
+ $txt .= 'PHP extension \"gd\"'.
+ ' ';
+ } else {
+ $txt .= 'PHP extension \"gd\"'.
+ ' ';
+ }
+ if (!extension_loaded('mbstring')) {
+ //$okExtensions = false;
+ $txt .= 'PHP extension \"mbstring\"'.
+ ' ';
+ } else {
+ $txt .= 'PHP extension \"mbstring\"'.
+ ' ';
+ }
+ if (!extension_loaded('bcmath')) {
+ //$okExtensions = false;
+ $txt .= 'PHP extension \"bcmath\"'.
+ ' ';
+ } else {
+ $txt .= 'PHP extension \"bcmath\"'.
+ ' ';
+ }
+ if (!extension_loaded('iconv')) {
+ //$okExtensions = false;
+ $txt .= 'PHP extension \"iconv\"'.
+ ' ';
+ } else {
+ $txt .= 'PHP extension \"iconv\"'.
+ ' ';
+ }
+ if (!extension_loaded('xml')) {
+ //$okExtensions = false;
+ $txt .= 'PHP extension \"xml\"'.
+ ' ';
+ } else {
+ $txt .= 'PHP extension \"xml\"'.
+ ' ';
+ }
+ if (!extension_loaded('curl')) {
+ $txt .= 'PHP extension \"curl\"'.
+ ' ';
+ } else {
+ $txt .= 'PHP extension \"curl\"'.
+ ' ';
+ }
+ if (ini_get('max_execution_time') < 60) {
+ $txt .= 'PHP \"Maximum '.
+ 'execution time\" is set to '.ini_get('max_execution_time').' seconds.'.
+ ' Please try to set to 60s at least until Upgrade is finished. '.
+ ' ';
+ } else {
+ $txt .= 'PHP \"Maximum '.
+ 'execution time\" is set to '.ini_get('max_execution_time').' seconds'.
+ ' ';
+ }
+ if (version_compare(phpversion(), '5.5.0', '<')) {
+ $okVersion = false;
+ $txt .= 'PHP version '.
+ phpversion().' is not OK (minimum is 5.5.0) '.
+ ' ';
+ } else {
+ $txt .= 'PHP version '.
+ phpversion().' is OK '.
+ ' ';
+ }
+
+ //get infos from SETTINGS.PHP file
+ $filename = "../includes/config/settings.php";
+ $events = "";
+ if (file_exists($filename)) {
+ //copy some constants from this existing file
+ $settingsFile = file($filename);
+ while (list($key, $val) = each($settingsFile)) {
+ if (substr_count($val, 'charset') > 0) {
+ $superGlobal->put("charset", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '@define(') > 0 && substr_count($val, 'SALT') > 0) {
+ $superGlobal->put("encrypt_key", substr($val, 17, strpos($val, "')") - 17), "SESSION");
+ } elseif (substr_count($val, '$smtp_server') > 0) {
+ $superGlobal->put("smtp_server", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$smtp_auth') > 0) {
+ $superGlobal->put("smtp_auth", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$smtp_auth_username') > 0) {
+ $superGlobal->put("smtp_auth_username", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$smtp_auth_password') > 0) {
+ $superGlobal->put("smtp_auth_password", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$smtp_port') > 0) {
+ $superGlobal->put("smtp_port", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$smtp_security') > 0) {
+ $superGlobal->put("smtp_security", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$email_from') > 0) {
+ $superGlobal->put("email_from", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$email_from_name') > 0) {
+ $superGlobal->put("email_from_name", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$server') > 0) {
+ $superGlobal->put("server", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$user') > 0) {
+ $superGlobal->put("user", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$pass') > 0) {
+ $superGlobal->put("pass", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$port') > 0) {
+ $superGlobal->put("port", getSettingValue($val), "SESSION");
+ } elseif (substr_count($val, '$database') > 0) {
+ $database = getSettingValue($val);
+ } elseif (substr_count($val, '$pre') > 0) {
+ $pre = getSettingValue($val);
+ } elseif (substr_count($val, "define('SECUREPATH',") > 0) {
+ $superGlobal->put("sk_file", substr($val, 23, strpos($val, ');')-24)."/sk.php", "SESSION");
+ }
+ }
+ }
+ $session_sk_file = $superGlobal->get("sk_file", "SESSION");
+ if (isset($session_sk_file) && !empty($session_sk_file)
+ && file_exists($session_sk_file)
+ ) {
+ $txt .= 'sk.php file'.
+ ' found in \"'.addslashes($session_sk_file).'\" '.
+ ' ';
+ //copy some constants from this existing file
+ $skFile = file($session_sk_file);
+ while (list($key, $val) = each($skFile)) {
+ if (substr_count($val, "@define('SALT'") > 0) {
+ $superGlobal->put("encrypt_key", substr($val, 17, strpos($val, "')") - 17), "SESSION");
+ $session_encrypt_key = $superGlobal->get("encrypt_key", "SESSION");
+ echo '$("#session_salt").val("'.$session_encrypt_key.'");';
+ }
+ }
+ }
+
+ // check if 2.1.27 already installed
+ $okEncryptKey = false;
+ $defuse_file = substr($session_sk_file, 0, strrpos($session_sk_file, "/"))."/teampass-seckey.txt";
+ if (file_exists($defuse_file)) {
+ $okEncryptKey = true;
+ $superGlobal->put("tp_defuse_installed", true, "SESSION");
+ $txt .= 'Defuse encryption key is defined '.
+ ' ';
+ }
+
+ if ($okEncryptKey === false) {
+ if (!isset($session_encrypt_key) || empty($session_encrypt_key)) {
+ $superGlobal->put("tp_defuse_installed", false, "SESSION");
+ $txt .= 'Encryption Key (SALT) '.
+ ' could not be recovered '.
+ ' ';
+ } else {
+ $okEncryptKey = true;
+ $txt .= 'Encryption Key (SALT) is available '.
+ ' ';
+ }
+ }
+
+ if ($okWritable === true && $okExtensions === true && $okEncryptKey === true) {
+ echo 'document.getElementById("but_next").disabled = "";';
+ echo 'document.getElementById("res_step1").innerHTML = "Elements are OK.";';
+ } else {
+ echo 'document.getElementById("but_next").disabled = "disabled";';
+ echo 'document.getElementById("res_step1").innerHTML = "Correct the shown '.
+ 'errors and click on button Launch to refresh";';
+ }
+
+ echo 'document.getElementById("res_step1").innerHTML = "'.$txt.'";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+
+ #==========================
+ case "step2":
+ $res = "";
+ $session_user_granted = $superGlobal->get("user_granted", "SESSION");
+
+ if ($session_user_granted !== "1") {
+ echo 'document.getElementById("res_step2").innerHTML = "User not connected anymore!";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+ }
+ //decrypt the password
+ // AES Counter Mode implementation
+ require_once 'libs/aesctr.php';
+
+ // check in db if previous saltk exists
+ if ($post_no_previous_sk === "false" || $post_no_previous_sk === "previous_sk_sel") {
+ $db_sk = mysqli_fetch_row(mysqli_query($db_link, "SELECT count(*) FROM ".$pre."misc
+ WHERE type='admin' AND intitule = 'saltkey_ante_2127'"));
+ if (!empty($post_previous_sk) || !empty($post_session_salt)) {
+ // get sk
+ if (!empty($post_session_salt)) {
+ $sk_val = filter_var($post_session_salt, FILTER_SANITIZE_STRING);
+ } else {
+ $sk_val = filter_var($post_previous_sk, FILTER_SANITIZE_STRING);
+ }
+
+ // Update
+ if (!empty($db_sk[0])) {
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."misc`
+ SET `valeur` = '".$sk_val."'
+ WHERE type = 'admin' AND intitule = 'saltkey_ante_2127'"
+ );
+ } else {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc`
+ (`valeur`, `type`, `intitule`)
+ VALUES ('".$sk_val."', 'admin', 'saltkey_ante_2127')"
+ );
+ }
+ } elseif (empty($db_sk[0])) {
+ $res = "Please provide Teampass instance history.";
+ echo 'document.getElementById("but_next").disabled = "disabled";';
+ echo 'document.getElementById("res_step2").innerHTML = "'.$res.'";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ echo 'document.getElementById("no_encrypt_key").style.display = "";';
+ }
+ } else {
+ // user said that database has not being used for an older version
+ // no old sk is available
+ $tmp = mysqli_num_rows(mysqli_query(
+ $db_link,
+ "SELECT * FROM `".$pre."misc`
+ WHERE type = 'admin' AND intitule = 'saltkey_ante_2127'"
+ ));
+ if ($tmp == 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc`
+ (`valeur`, `type`, `intitule`)
+ VALUES ('none', 'admin', 'saltkey_ante_2127')"
+ );
+ } else {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc`
+ (`valeur`, `type`, `intitule`)
+ VALUES ('none', 'admin', 'saltkey_ante_2127')"
+ );
+ }
+ $superGlobal->put("tp_defuse_installed", true, "SESSION");
+ }
+
+ //What CPM version
+ if (mysqli_query(
+ $db_link,
+ "SELECT valeur FROM ".$pre."misc
+ WHERE type='admin' AND intitule = 'cpassman_version'"
+ )) {
+ $tmpResult = mysqli_query(
+ $db_link,
+ "SELECT valeur FROM ".$pre."misc
+ WHERE type='admin' AND intitule = 'cpassman_version'"
+ );
+ $cpmVersion = mysqli_fetch_row($tmpResult);
+ echo 'document.getElementById("actual_cpm_version").value = "'.
+ $cpmVersion[0].'";';
+ } else {
+ echo 'document.getElementById("actual_cpm_version").value = "0";';
+ }
+
+ //Get some infos from DB
+ if (@mysqli_fetch_row(
+ mysqli_query(
+ $db_link,
+ "SELECT valeur FROM ".$pre."misc
+ WHERE type='admin' AND intitule = 'utf8_enabled'"
+ )
+ )
+ ) {
+ $cpmIsUTF8 = mysqli_fetch_row(
+ mysqli_query(
+ $db_link,
+ "SELECT valeur FROM ".$pre."misc
+ WHERE type='admin' AND intitule = 'utf8_enabled'"
+ )
+ );
+ echo 'document.getElementById("cpm_isUTF8").value = "'.$cpmIsUTF8[0].'";';
+ $superGlobal->put("utf8_enabled", $cpmIsUTF8[0], "SESSION");
+ } else {
+ echo 'document.getElementById("cpm_isUTF8").value = "0";';
+ $superGlobal->put("utf8_enabled", 0, "SESSION");
+ }
+
+ // put TP in maintenance mode or not
+ @mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."misc`
+ SET `valeur` = 'maintenance_mode'
+ WHERE type = 'admin' AND intitule = '".$post_no_maintenance_mode."'"
+ );
+
+ echo 'document.getElementById("dump").style.display = "";';
+
+
+ echo 'document.getElementById("res_step2").innerHTML = "'.$res.'";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+
+ #==========================
+ case "step3":
+ $session_user_granted = $superGlobal->get("user_granted", "SESSION");
+
+ if ($session_user_granted !== "1") {
+ echo 'document.getElementById("res_step3").innerHTML = "User not connected anymore!";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+ }
+
+ //rename tables
+ if (isset($post_prefix_before_convert) && $post_prefix_before_convert == "true") {
+ $tables = mysqli_query($db_link, 'SHOW TABLES');
+ while ($table = mysqli_fetch_row($tables)) {
+ if (tableExists("old_".$table[0]) != 1 && substr($table[0], 0, 4) != "old_") {
+ mysqli_query($db_link, "CREATE TABLE old_".$table[0]." LIKE ".$table[0]);
+ mysqli_query($db_link, "INSERT INTO old_".$table[0]." SELECT * FROM ".$table[0]);
+ }
+ }
+ }
+
+ //convert database
+ mysqli_query(
+ $db_link,
+ "ALTER DATABASE `".$database."`
+ DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"
+ );
+
+ //convert tables
+ $res = mysqli_query($db_link, "SHOW TABLES FROM `".$database."`");
+ while ($table = mysqli_fetch_row($res)) {
+ if (substr($table[0], 0, 4) != "old_") {
+ mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$database.".`{$table[0]}`
+ CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"
+ );
+ mysqli_query(
+ $db_link,
+ "ALTER TABLE".$database.".`{$table[0]}`
+ DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"
+ );
+ }
+ }
+
+ echo 'document.getElementById("res_step3").innerHTML = "Done!";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ echo 'document.getElementById("but_next").disabled = "";';
+ echo 'document.getElementById("but_launch").disabled = "disabled";';
+
+ mysqli_close($db_link);
+ break;
+
+ #==========================
+
+
+ //=============================
+ case "step5":
+ $session_user_granted = $superGlobal->get("user_granted", "SESSION");
+
+ if ($session_user_granted !== "1") {
+ echo 'document.getElementById("res_step5").innerHTML = "User not connected anymore!";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+ }
+
+ $filename = "../includes/config/settings.php";
+ $events = "";
+ if (file_exists($filename)) {
+ //Do a copy of the existing file
+ if (!copy(
+ $filename,
+ $filename.'.'.date(
+ "Y_m_d",
+ mktime(0, 0, 0, date('m'), date('d'), date('y'))
+ )
+ )) {
+ echo 'document.getElementById("res_step5").innerHTML = '.
+ '"Setting.php file already exists and cannot be renamed. '.
+ 'Please do it by yourself and click on button Launch.";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ break;
+ } else {
+ $events .= "The file $filename already exist. A copy has been created. ";
+ unlink($filename);
+ }
+
+ //manage SK path
+ if (isset($post_sk_path) && !empty($post_sk_path)) {
+ $skFile = str_replace('\\', '/', $post_sk_path.'/sk.php');
+ $securePath = str_replace('\\', '/', $post_sk_path);
+ } else {
+ echo 'document.getElementById("res_step5").innerHTML = '.
+ '" The SK path must be indicated.";
+ document.getElementById("loader").style.display = "none";';
+ break;
+ }
+
+ //Check if path is ok
+ if (is_dir($securePath)) {
+ if (is_writable($securePath)) {
+ //Do nothing
+ } else {
+ echo 'document.getElementById("res_step5").innerHTML = '.
+ '" The SK path must be writable!";
+ document.getElementById("loader").style.display = "none";';
+ break;
+ }
+ } else {
+ echo 'document.getElementById("res_step5").innerHTML = '.
+ '" '.
+ 'Path for SK is not a Directory!";
+ document.getElementById("loader").style.display = "none";';
+ break;
+ }
+
+ $file_handled = fopen($filename, 'w');
+
+ //prepare smtp_auth variable
+ if (empty($superGlobal->get("smtp_auth", "SESSION"))) {
+ $superGlobal->put("smtp_auth", "false", "SESSION");
+ }
+ if (empty($superGlobal->get("smtp_auth_username", "SESSION"))) {
+ $superGlobal->put("smtp_auth_username", "false", "SESSION");
+ }
+ if (empty($superGlobal->get("smtp_auth_password", "SESSION"))) {
+ $superGlobal->put("smtp_auth_password", "false", "SESSION");
+ }
+ if (empty($superGlobal->get("email_from_name", "SESSION"))) {
+ $superGlobal->put("email_from_name", "false", "SESSION");
+ }
+
+ $result1 = fwrite(
+ $file_handled,
+ utf8_encode(
+ "";';
+ }
+
+ //Create sk.php file
+ if (file_exists($skFile) === false) {
+ $file_handled = fopen($skFile, 'w');
+
+ $result2 = fwrite(
+ $file_handled,
+ utf8_encode(
+ ""
+ )
+ );
+ fclose($file_handled);
+ }
+
+ // update CSRFP TOKEN
+ $csrfp_file_sample = "../includes/libraries/csrfp/libs/csrfp.config.sample.php";
+ $csrfp_file = "../includes/libraries/csrfp/libs/csrfp.config.php";
+ if (file_exists($csrfp_file) === true) {
+ if (!copy($filename, $filename.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
+ echo '[{"error" : "csrfp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ break;
+ } else {
+ $events .= "The file $csrfp_file already exist. A copy has been created. ";
+ }
+ }
+ unlink($csrfp_file); // delete existing csrfp.config file
+ copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file
+ $data = file_get_contents("../includes/libraries/csrfp/libs/csrfp.config.php");
+ $newdata = str_replace('"CSRFP_TOKEN" => ""', '"CSRFP_TOKEN" => "'.bin2hex(openssl_random_pseudo_bytes(25)).'"', $data);
+ $newdata = str_replace('"tokenLength" => "25"', '"tokenLength" => "50"', $newdata);
+ $jsUrl = $post_url_path.'/includes/libraries/csrfp/js/csrfprotector.js';
+ $newdata = str_replace('"jsUrl" => ""', '"jsUrl" => "'.$jsUrl.'"', $newdata);
+ $newdata = str_replace('"verifyGetFor" => array()', '"verifyGetFor" => array("*page=items&type=duo_check*")', $newdata);
+ file_put_contents("../includes/libraries/csrfp/libs/csrfp.config.php", $newdata);
+
+
+ // finalize
+ if (isset($result2) && $result2 === false) {
+ echo 'document.getElementById("res_step5").innerHTML = '.
+ '"$skFile could not be created. Please check the path and the rights.";';
+ } else {
+ echo 'document.getElementById("step5_skFile").innerHTML = '.
+ '" ";';
+ }
+
+ // Mark a tag to force Install stuff (folders, files and table) to be cleanup while first login
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('install', 'clear_install_folder', 'true')"
+ );
+
+
+ //Finished
+ if ($result1 !== false
+ && (!isset($result2) || (isset($result2) && $result2 !== false))
+ ) {
+ echo 'document.getElementById("but_next").disabled = "";';
+ echo 'document.getElementById("res_step5").innerHTML = '.
+ '"Operations are successfully completed.";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ echo 'document.getElementById("but_launch").disabled = "disabled";';
+ }
+ } else {
+ //settings.php file doesn't exit => ERROR !!!!
+ echo 'document.getElementById("res_step5").innerHTML = '.
+ '" Setting.php '.
+ 'file doesn\'t exist! Upgrade can\'t continue without this file. '.
+ 'Please copy your existing settings.php into the \"includes\" '.
+ 'folder of your TeamPass installation ";';
+ echo 'document.getElementById("loader").style.display = "none";';
+ }
+
+ break;
+
+ case "perform_database_dump":
+ $filename = "../includes/config/settings.php";
+
+ require_once "../sources/main.functions.php";
+ $pass = defuse_return_decrypted($pass);
+
+ $mtables = array();
+
+ $mysqli = new mysqli($server, $user, $pass, $database, $port);
+ if ($mysqli->connect_error) {
+ die('Error : ('.$mysqli->connect_errno.') '.$mysqli->connect_error);
+ }
+
+ $results = $mysqli->query("SHOW TABLES");
+
+ while ($row = $results->fetch_array()) {
+ $mtables[] = $row[0];
+ }
+
+ foreach ($mtables as $table) {
+ $contents .= "-- Table `".$table."` --\n";
+
+ $results = $mysqli->query("SHOW CREATE TABLE ".$table);
+ while ($row = $results->fetch_array()) {
+ $contents .= $row[1].";\n\n";
+ }
+
+ $results = $mysqli->query("SELECT * FROM ".$table);
+ $row_count = $results->num_rows;
+ $fields = $results->fetch_fields();
+ $fields_count = count($fields);
+
+ $insert_head = "INSERT INTO `".$table."` (";
+ for ($i = 0; $i < $fields_count; $i++) {
+ $insert_head .= "`".$fields[$i]->name."`";
+ if ($i < $fields_count - 1) {
+ $insert_head .= ', ';
+ }
+ }
+ $insert_head .= ")";
+ $insert_head .= " VALUES\n";
+
+ if ($row_count > 0) {
+ $r = 0;
+ while ($row = $results->fetch_array()) {
+ if (($r % 400) == 0) {
+ $contents .= $insert_head;
+ }
+ $contents .= "(";
+ for ($i = 0; $i < $fields_count; $i++) {
+ $row_content = str_replace("\n", "\\n", $mysqli->real_escape_string($row[$i]));
+
+ switch ($fields[$i]->type) {
+ case 8:
+ case 3:
+ $contents .= $row_content;
+ break;
+ default:
+ $contents .= "'".$row_content."'";
+ }
+ if ($i < $fields_count - 1) {
+ $contents .= ', ';
+ }
+ }
+ if (($r + 1) == $row_count || ($r % 400) == 399) {
+ $contents .= ");\n\n";
+ } else {
+ $contents .= "),\n";
+ }
+ $r++;
+ }
+ }
+ }
+
+ $backup_file_name = "sql-backup-".date("d-m-Y--h-i-s").".sql";
+
+ $fp = fopen("../files/".$backup_file_name, 'w+');
+ if (($result = fwrite($fp, $contents))) {
+ echo '[{ "error" : "" , "file" : "files/'.$backup_file_name.'"}]';
+ } else {
+ echo '[{ "error" : "Backup fails - please do it manually."}]';
+ }
+ fclose($fp);
+ return false;
+
+ break;
+ }
+}
+echo 'document.getElementById("but_next").disabled = "";';
diff --git a/install/upgrade_db_1.08.php b/install/upgrade_db_1.08.php
new file mode 100644
index 000000000..f992f9bac
--- /dev/null
+++ b/install/upgrade_db_1.08.php
@@ -0,0 +1,123 @@
+";
+ }
+ }
+ unlink($csrfp_file); // delete existing csrfp.config file
+ copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file
+ $data = file_get_contents("../includes/libraries/csrfp/libs/csrfp.config.php");
+ $newdata = str_replace('"CSRFP_TOKEN" => ""', '"CSRFP_TOKEN" => "'.bin2hex(openssl_random_pseudo_bytes(25)).'"', $data);
+ $newdata = str_replace('"tokenLength" => "25"', '"tokenLength" => "50"', $newdata);
+ $jsUrl = $_SESSION['fullurl'].'/includes/libraries/csrfp/js/csrfprotector.js';
+ $newdata = str_replace('"jsUrl" => ""', '"jsUrl" => "'.$jsUrl.'"', $newdata);
+ file_put_contents("../includes/libraries/csrfp/libs/csrfp.config.php", $newdata);
+
+ $_SESSION['upgrade']['csrfp_config_file'] = 1;
+}
+
+
+// clean duplicate ldap_object_class from bad update script version
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'ldap_object_class'"));
+if ($tmp[0] > 1) {
+ mysqli_query($db_link, "DELETE FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'ldap_object_class' AND `valeur` = 0");
+}
+// add new setting - ldap_object_class
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'ldap_object_class'"));
+if (intval($tmp) === 0) {
+ mysqli_query($db_link, "INSERT INTO `".$pre."misc` VALUES ('admin', 'ldap_object_class', '0')");
+}
+
+// convert 2factors_ to google_ due to illegal id, and for clarification of purpose
+$tmp_googlecount = mysqli_fetch_row(mysqli_query($db_link, "SELECT COUNT(*) FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'google_authentication'"));
+$tmp_twocount = mysqli_fetch_row(mysqli_query($db_link, "SELECT COUNT(*) FROM `".$pre."misc` WHERE type = 'admin' AND intitule = '2factors_authentication'"));
+
+if ($tmp_googlecount[0] > 0) {
+ mysqli_query($db_link, "DELETE FROM `".$pre."misc` WHERE type = 'admin' AND intitule = '2factors_authentication'");
+} else {
+ if ($tmp_twocount[0] > 0) {
+ mysqli_query($db_link, "UPDATE `".$pre."misc` SET intitule = 'google_authentication' WHERE intitule = '2factors_authentication' ");
+ } else {
+ mysqli_query($db_link, "INSERT INTO `".$pre."misc` VALUES ('admin', 'google_authentication', '0')");
+ }
+}
+
+
+// Fix for #1510
+// change the "personal_folder" field on all named folders back to "0" in nested_tree
+$result = mysqli_query(
+ $db_link,
+ "SELECT title, id
+ FROM `".$pre."nested_tree`
+ WHERE personal_folder = '1' AND nlevel = '1' AND parent_id = '0'"
+);
+while ($row = mysqli_fetch_assoc($result)) {
+ // only change non numeric folder title
+ if (!is_numeric($row['title'])) {
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."nested_tree`
+ SET personal_folder = '0'
+ WHERE id = '".$row['id']."'"
+ );
+ }
+}
+mysqli_free_result($result);
+
+
+// Finished
+echo '[{"finish":"1" , "next":"", "error":""}]';
diff --git a/install/upgrade_run_2.1.27.php b/install/upgrade_run_2.1.27.php
new file mode 100644
index 000000000..977582d39
--- /dev/null
+++ b/install/upgrade_run_2.1.27.php
@@ -0,0 +1,772 @@
+put("db_encoding", "utf8", "SESSION");
+$_SESSION['settings']['loaded'] = "";
+$superGlobal->put("fullurl", $post_fullurl, "SESSION");
+$superGlobal->put("abspath", $abspath, "SESSION");
+
+// Get Sessions
+$session_tp_defuse_installed = $superGlobal->get("tp_defuse_installed", "SESSION");
+
+/**
+ * Function permits to get the value from a line
+ * @param string $val [description]
+ * @return string [description]
+ */
+function getSettingValue($val)
+{
+ $val = trim(strstr($val, "="));
+ return trim(str_replace('"', '', substr($val, 1, strpos($val, ";") - 1)));
+}
+
+/**
+ * Function permits to check if a column exists, and if not to add it
+ * @param string $dbname [description]
+ * @param string $column [description]
+ * @param string $columnAttr [description]
+ */
+function addColumnIfNotExist($dbname, $column, $columnAttr = "VARCHAR(255) NULL")
+{
+ global $db_link;
+ $exists = false;
+ $columns = mysqli_query($db_link, "show columns from $dbname");
+ while ($col = mysqli_fetch_assoc($columns)) {
+ if ($col['Field'] == $column) {
+ $exists = true;
+ return true;
+ }
+ }
+ if (!$exists) {
+ return mysqli_query($db_link, "ALTER TABLE `$dbname` ADD `$column` $columnAttr");
+ }
+
+ return false;
+}
+
+/**
+ * [cleanFields description]
+ * @param [type] $txt [description]
+ * @return [type] [description]
+ */
+function cleanFields($txt)
+{
+ $tmp = str_replace(",", ";", trim($txt));
+ if (empty($tmp)) {
+ return $tmp;
+ }
+ if ($tmp === ";") {
+ return "";
+ }
+ if (strpos($tmp, ';') === 0) {
+ $tmp = substr($tmp, 1);
+ }
+ if (substr($tmp, -1) !== ";") {
+ $tmp = $tmp.";";
+ }
+ return $tmp;
+}
+
+/*
+** Checks if the column exists in the table
+*/
+function columnExists($tablename, $column)
+{
+ global $db_link;
+ $checkcolumn = mysqli_query($db_link, "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='{$tablename}' AND COLUMN_NAME = '{$column}';");
+ if (mysqli_num_rows($checkcolumn) > 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// 2.1.27 introduce new encryption protocol with DEFUSE library.
+// Now evaluate if current instance has already this version
+$tmp = mysqli_fetch_row(mysqli_query($db_link, "SELECT valeur FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'teampass_version'"));
+if (count($tmp[0]) === 0 || empty($tmp[0])) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'teampass_version', '".$SETTINGS_EXT['version']."')"
+ );
+} else {
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."misc`
+ SET `valeur` = '".$SETTINGS_EXT['version']."'
+ WHERE intitule = 'teampass_version' AND type = 'admin'"
+ );
+}
+
+// add new admin setting "migration_to_2127"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'migration_to_2127'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'migration_to_2127', '0')"
+ );
+}
+
+
+// check if library defuse already on-going here
+// if yes, then don't execute re-encryption
+if (isset($session_tp_defuse_installed) === false) {
+ $superGlobal->put("tp_defuse_installed", false, "SESSION");
+ if (columnExists($pre."items", "encryption_type") === true) {
+ $superGlobal->put("tp_defuse_installed", true, "SESSION");
+ }
+}
+
+// alter table Items
+mysqli_query($db_link, "ALTER TABLE `".$pre."items` MODIFY pw_len INT(5) NOT NULL DEFAULT '0'");
+
+// alter table MISC - rename ID is exists
+if (columnExists($pre."misc", "id") === true) {
+ // Change name of field
+ mysqli_query($db_link, "ALTER TABLE `".$pre."misc` CHANGE `id` `increment_id` INT(12) NOT NULL AUTO_INCREMENT");
+} else {
+ // alter table misc to add an index
+ $res = addColumnIfNotExist(
+ $pre."misc",
+ "increment_id",
+ "INT(12) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`increment_id`)"
+ );
+}
+
+// alter table misc to add an index
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."log_items` ADD `increment_id` INT(12) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`increment_id`)"
+);
+
+// add field agses-usercardid to Users table
+$res = addColumnIfNotExist(
+ $pre."users",
+ "agses-usercardid",
+ "VARCHAR(12) NOT NULL DEFAULT '0'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field agses-usercardid to table Users! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+
+// add field encrypted_data to Categories table
+$res = addColumnIfNotExist(
+ $pre."categories",
+ "encrypted_data",
+ "TINYINT(1) NOT NULL DEFAULT '1'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encrypted_data to table categories! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+
+// alter table USERS - user_language
+mysqli_query($db_link, "ALTER TABLE `".$pre."users` MODIFY user_language VARCHAR(50) NOT NULL DEFAULT '0'");
+
+// alter table USERS - just ensure correct naming of IsAdministratedByRole
+mysqli_query($db_link, "ALTER TABLE `".$pre."users` CHANGE IsAdministratedByRole isAdministratedByRole tinyint(5) NOT NULL DEFAULT '0'");
+
+// alter table OTV
+mysqli_query($db_link, "ALTER TABLE `".$pre."otv` CHANGE originator originator int(12) NOT NULL DEFAULT '0'");
+
+// do clean of users table
+$fieldsToUpdate = ['groupes_visibles', 'fonction_id', 'groupes_interdits'];
+$result = mysqli_query($db_link, "SELECT id, groupes_visibles, fonction_id, groupes_interdits FROM `".$pre."users`");
+while ($row = mysqli_fetch_assoc($result)) {
+ // check if field contains , instead of ;
+ foreach ($fieldsToUpdate as $field) {
+ $tmp = cleanFields($row[$field]);
+ if ($tmp !== $row[$field]) {
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."users`
+ SET `".$field."` = '".$tmp."'
+ WHERE id = '".$row['id']."'"
+ );
+ }
+ }
+}
+mysqli_free_result($result);
+
+
+// alter table KB_ITEMS
+mysqli_query($db_link, "ALTER TABLE `".$pre."kb_items` CHANGE `kb_id` `kb_id` INT(12) NOT NULL");
+mysqli_query($db_link, "ALTER TABLE `".$pre."kb_items` CHANGE `item_id` `item_id` INT(12) NOT NULL");
+
+
+// Alter table EXPORT - adapt field Label
+mysqli_query($db_link, "ALTER TABLE `".$pre."export` CHANGE `label` `label` VARCHAR(500) NOT NULL");
+
+// add field encrypted_data to CATEGORIES table
+$res = addColumnIfNotExist(
+ $pre."categories",
+ "encrypted_data",
+ "TINYINT(1) NOT NULL DEFAULT '1'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encrypted_data to table CATEGORIES! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."misc`
+ SET `valeur` = 'maintenance_mode'
+ WHERE type = 'admin' AND intitule = '".$post_no_maintenance_mode."'"
+);
+
+
+// add field encryption_type to ITEMS table
+$res = addColumnIfNotExist(
+ $pre."items",
+ "encryption_type",
+ "VARCHAR(20) NOT NULL DEFAULT 'not_set'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encryption_type to table ITEMS! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+
+// add field encryption_type to categories_items table
+$res = addColumnIfNotExist(
+ $pre."categories_items",
+ "encryption_type",
+ "VARCHAR(20) NOT NULL DEFAULT 'not_set'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encryption_type to table categories_items! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+
+// add field encryption_type to LOG_ITEMS table
+$res = addColumnIfNotExist(
+ $pre."log_items",
+ "encryption_type",
+ "VARCHAR(20) NOT NULL DEFAULT 'not_set'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encryption_type to table LOG_ITEMS! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+
+// add field URL to CACHE table
+$res = addColumnIfNotExist(
+ $pre."cache",
+ "encryption_type",
+ "VARCHAR(500) NOT NULL DEFAULT '0'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field URL to table CACHE! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+
+// add field timestamp to CACHE table
+$res = addColumnIfNotExist(
+ $pre."cache",
+ "timestamp",
+ "VARCHAR(50) DEFAULT NULL DEFAULT '0'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field url to table CACHE! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+
+// add field url to CACHE table
+$res = addColumnIfNotExist(
+ $pre."cache",
+ "url",
+ "VARCHAR(500) DEFAULT NULL"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field timestamp to table CACHE! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+//-- generate new DEFUSE key
+if (isset($session_tp_defuse_installed) === false || $session_tp_defuse_installed === false) {
+ $filename = "../includes/config/settings.php";
+ $settingsFile = file($filename);
+ while (list($key, $val) = each($settingsFile)) {
+ if (substr_count($val, 'require_once "') > 0 && substr_count($val, 'sk.php') > 0) {
+ $superGlobal->put("sk_file", substr($val, 14, strpos($val, '";') - 14), "SESSION");
+ $session_sk_file = $superGlobal->get("sk_file", "SESSION");
+ }
+ }
+
+ copy(
+ SECUREPATH."/teampass-seckey.txt",
+ SECUREPATH."/teampass-seckey.txt".'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))).".".time()
+ );
+ $superGlobal->put("tp_defuse_new_key", true, "SESSION");
+ $new_salt = defuse_generate_key();
+ file_put_contents(
+ SECUREPATH."/teampass-seckey.txt",
+ $new_salt
+ );
+ $superGlobal->put("new_salt", $new_salt, "SESSION");
+
+ // update sk.php file
+ copy(
+ $session_sk_file,
+ $session_sk_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))).".".time()
+ );
+ $data = file($session_sk_file); // reads an array of lines
+ function replace_a_line($data)
+ {
+ if (stristr($data, "@define('SALT'")) {
+ return "";
+ }
+ return $data;
+ }
+ $data = array_map('replace_a_line', $data);
+ file_put_contents($session_sk_file, implode('', $data));
+
+ //
+ //
+ //-- users need to perform re-encryption of their personal pwds
+ $result = mysqli_query(
+ $db_link,
+ "SELECT valeur FROM `".$pre."misc` WHERE type='admin' AND intitule='encryption_type'"
+ );
+ $row = mysqli_fetch_assoc($result);
+ if ($row['valeur'] !== "defuse") {
+ $result = mysqli_query(
+ $db_link,
+ "SELECT id FROM `".$pre."users`"
+ );
+ while ($row_user = mysqli_fetch_assoc($result)) {
+ $result_items = mysqli_query(
+ $db_link,
+ "SELECT i.id AS item_id
+ FROM `".$pre."nested_tree` AS n
+ INNER JOIN `".$pre."items` AS i ON (i.id_tree = n.id)
+ WHERE n.title = ".$row_user['id']
+ );
+ if (mysqli_num_rows($result_items) > 0) {
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."users`
+ SET `upgrade_needed` = '1'
+ WHERE id = ".$row_user['id']
+ );
+ } else {
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."users`
+ SET `upgrade_needed` = '0'
+ WHERE id = ".$row_user['id']
+ );
+ }
+ }
+
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."misc`
+ SET `valeur` = 'defuse'
+ WHERE `type`='admin' AND `initule`='encryption_type'"
+ );
+ }
+} else {
+ $_SESSION['tp_defuse_new_key'] = false;
+}
+//--
+
+
+// add field encrypted_psk to Users table
+$res = addColumnIfNotExist(
+ $pre."users",
+ "encrypted_psk",
+ "TEXT NOT NULL"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encrypted_psk to table Users! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+
+// add new admin setting "manager_move_item"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'manager_move_item'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'manager_move_item', '0')"
+ );
+}
+
+// add new admin setting "create_item_without_password"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'create_item_without_password'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'create_item_without_password', '0')"
+ );
+}
+
+// add new admin setting "send_statistics_items"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'send_statistics_items'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'send_statistics_items', 'stat_country;stat_users;stat_items;stat_items_shared;stat_folders;stat_folders_shared;stat_admins;stat_managers;stat_ro;stat_mysqlversion;stat_phpversion;stat_teampassversion;stat_languages;stat_kb;stat_suggestion;stat_customfields;stat_api;stat_2fa;stat_agses;stat_duo;stat_ldap;stat_syslog;stat_stricthttps;stat_fav;stat_pf;')"
+ );
+}
+
+// add new admin setting "send_stats_time"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'send_stats_time'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'send_stats_time', '".(time() - 2592000)."')"
+ );
+}
+
+// add new admin setting "agses_authentication_enabled"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'agses_authentication_enabled'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'agses_authentication_enabled', '0')"
+ );
+}
+
+// add new admin setting "timezone"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'timezone'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'timezone', 'UTC')"
+ );
+}
+
+// add new admin setting "personal_saltkey_security_level"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'personal_saltkey_security_level'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'personal_saltkey_security_level', '0')"
+ );
+}
+
+// add new admin setting "item_extra_fields"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'item_extra_fields'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'item_extra_fields', '0')"
+ );
+}
+
+// add new admin setting "ldap_new_user_is_administrated_by"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'ldap_new_user_is_administrated_by'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'ldap_new_user_is_administrated_by', '0')"
+ );
+}
+
+
+// add new language "portuges_br"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."languages` WHERE name = 'portuguese_br'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."languages` (`name`, `label`, `code`, `flag`) VALUES ('portuguese_br', 'Portuguese_br', 'pr-bt', 'pr-bt.png')"
+ );
+}
+
+
+// alter table USERS to add a new field "ga_temporary_code"
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."users` ADD `ga_temporary_code` VARCHAR(20) NOT NULL DEFAULT 'none' AFTER `ga`;"
+);
+// alter table USERS to add a new field "user_ip"
+if (columnExists($pre."users", "user_ip") === true) {
+ // Change name of field
+ mysqli_query($db_link, "ALTER TABLE `".$pre."users` CHANGE `user_ip` `user_ip` VARCHAR(400) NOT NULL DEFAULT 'none'");
+} else {
+ // alter table misc to add an index
+ $res = addColumnIfNotExist(
+ $pre."users",
+ "user_ip",
+ "VARCHAR(400) NOT NULL DEFAULT 'none'"
+ );
+}
+
+// alter table USERS to allow NULL on field "email"
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."users` CHANGE `email` `email` VARCHAR(300) NOT NULL DEFAULT 'none';"
+);
+
+
+// alter table EXPORT to add a new fields
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."export` ADD `email` VARCHAR(500) NOT NULL DEFAULT 'none';"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."export` ADD `url` VARCHAR(500) NOT NULL DEFAULT 'none';"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."export` ADD `kbs` VARCHAR(500) NOT NULL DEFAULT 'none';"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."export` ADD `tags` VARCHAR(500) NOT NULL DEFAULT 'none';"
+);
+
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."misc` CHANGE valeur valeur VARCHAR(500) NOT NULL DEFAULT 'none'"
+);
+
+// alter table ITEMS_CHANGE
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."items_change` CHANGE user_id user_id INT(12) NOT NULL;"
+);
+
+// alter table ITEMS
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."items` CHANGE auto_update_pwd_next_date auto_update_pwd_next_date VARCHAR(100) NOT NULL DEFAULT '0';"
+);
+
+
+// add new admin setting "otv_is_enabled"
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'otv_is_enabled'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'otv_is_enabled', '0')"
+ );
+}
+
+
+// add new field for items_change
+mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."items_change` (
+ `id` int(12) NOT NULL AUTO_INCREMENT,
+ `item_id` int(12) NOT NULL,
+ `label` varchar(255) NOT NULL DEFAULT 'none',
+ `pw` text NOT NULL,
+ `login` varchar(255) NOT NULL DEFAULT 'none',
+ `email` varchar(255) NOT NULL DEFAULT 'none',
+ `url` varchar(255) NOT NULL DEFAULT 'none',
+ `description` text NOT NULL,
+ `comment` text NOT NULL,
+ `folder_id` tinyint(12) NOT NULL,
+ `user_id` tinyint(12) NOT NULL,
+ `timestamp` varchar(50) NOT NULL DEFAULT 'none',
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+);
+
+
+
+// File encryption
+// add field status to FILE table
+$res = addColumnIfNotExist(
+ $pre."files",
+ "status",
+ "VARCHAR(50) NOT NULL DEFAULT '0'"
+);
+if ($res === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field agses-usercardid to table Users! '.mysqli_error($db_link).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+// fill in this new field with the current "encryption-file" status
+$tmp = mysqli_fetch_row(mysqli_query($db_link, "SELECT valeur FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'enable_attachment_encryption'"));
+if (!empty($tmp[0])) {
+ if ($tmp[0] === "1") {
+ $status = "encrypted";
+ } else {
+ $status = "clear";
+ }
+ mysqli_query($db_link, "update `".$pre."files` set status = '".$status."' where 1 = 1");
+}
+
+
+// add 2 generic users
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."users` WHERE id = '9999991' AND login = 'OTV'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."users` (`id`, `login`, `pw`, `groupes_visibles`, `derniers`, `key_tempo`, `last_pw_change`, `last_pw`, `admin`, `fonction_id`, `groupes_interdits`, `last_connexion`, `gestionnaire`, `email`, `favourites`, `latest_items`, `personal_folder`) VALUES ('9999991', 'OTV', '', '', '', '', '', '', '1', '', '', '', '0', '', '', '', '0')"
+ );
+}
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."users` WHERE id = '9999991' AND login = 'OTV'"));
+if (intval($tmp) === 0) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."users` (`id`, `login`, `pw`, `groupes_visibles`, `derniers`, `key_tempo`, `last_pw_change`, `last_pw`, `admin`, `fonction_id`, `groupes_interdits`, `last_connexion`, `gestionnaire`, `email`, `favourites`, `latest_items`, `personal_folder`) VALUES ('9999999', 'API', '', '', '', '', '', '', '1', '', '', '', '0', '', '', '', '0')"
+ );
+}
+
+
+// Update favico to favicon
+$result = mysqli_query($db_link, "SELECT valeur FROM `".$pre."misc` WHERE intitule = 'cpassman_url' AND type = 'admin'");
+$rows = mysqli_fetch_assoc($result);
+mysqli_free_result($result);
+mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."misc`
+ SET `valeur` = '".$rows['valeur']."/favicon.ico'
+ WHERE intitule = 'favicon' AND type = 'admin'"
+);
+
+
+// Remove some indexes
+mysqli_query($db_link, "ALTER TABLE ".$pre."nested_tree` DROP INDEX `id`;");
+mysqli_query($db_link, "ALTER TABLE ".$pre."tags` DROP INDEX `id`;");
+
+
+/*
+* Introduce new CONFIG file
+*/
+$tp_config_file = "../includes/config/tp.config.php";
+if (file_exists($tp_config_file)) {
+ if (!copy($tp_config_file, $tp_config_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
+ echo '[{"error" : "includes/config/tp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ return false;
+ } else {
+ unlink($tp_config_file);
+ }
+}
+$file_handler = fopen($tp_config_file, 'w');
+$config_text = "";
+$any_settings = false;
+
+$result = mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin'");
+while ($row = mysqli_fetch_assoc($result)) {
+ // append new setting in config file
+ $config_text .= "
+ '".$row['intitule']."' => '".$row['valeur']."',";
+ if ($any_settings === false) {
+ $any_settings = true;
+ }
+}
+mysqli_free_result($result);
+
+// write to config file
+if ($any_settings === true) {
+ $result = fwrite(
+ $file_handler,
+ utf8_encode(
+ " 0) {
+ return true;
+ }
+
+ return false;
+}
+
+//define pbkdf2 iteration count
+@define('ITCOUNT', '2072');
+
+$return_error = "";
+
+// do initial upgrade
+
+//include librairies
+require_once '../includes/libraries/Tree/NestedTree/NestedTree.php';
+
+//Build tree
+$tree = new Tree\NestedTree\NestedTree(
+ $pre.'nested_tree',
+ 'id',
+ 'parent_id',
+ 'title'
+);
+
+// dataBase
+$res = "";
+
+// Test DB connexion
+$pass = defuse_return_decrypted($pass);
+if (mysqli_connect(
+ $server,
+ $user,
+ $pass,
+ $database,
+ $port
+)
+) {
+ $db_link = mysqli_connect(
+ $server,
+ $user,
+ $pass,
+ $database,
+ $port
+ );
+} else {
+ $res = "Impossible to get connected to server. Error is: ".addslashes(mysqli_connect_error());
+ echo '[{"finish":"1", "msg":"", "error":"Impossible to get connected to server. Error is: '.addslashes(mysqli_connect_error()).'!"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+// 2.1.27 check with DEFUSE
+// check if library defuse already on-going here
+// if yes, then don't execute re-encryption
+if (isset($_SESSION['tp_defuse_installed']) !== true) {
+ $_SESSION['tp_defuse_installed'] = false;
+ $columns = mysqli_query(
+ $db_link,
+ "show columns from ".$pre."items"
+ );
+ while ($c = mysqli_fetch_assoc($columns)) {
+ if ($c['Field'] === "encryption_type") {
+ $_SESSION['tp_defuse_installed'] = true;
+ }
+ }
+}
+
+## Populate table MISC
+$val = array(
+ array('admin', 'max_latest_items', '10', 0),
+ array('admin', 'enable_favourites', '1', 0),
+ array('admin', 'show_last_items', '1', 0),
+ array('admin', 'enable_pf_feature', '0', 0),
+ array('admin', 'menu_type', 'context', 0),
+ array('admin', 'log_connections', '0', 0),
+ array('admin', 'time_format', 'H:i:s', 0),
+ array('admin', 'date_format', 'd/m/Y', 0),
+ array('admin', 'duplicate_folder', '0', 0),
+ array('admin', 'duplicate_item', '0', 0),
+ array('admin', 'item_duplicate_in_same_folder', '0', 0),
+ array('admin', 'number_of_used_pw', '3', 0),
+ array('admin', 'manager_edit', '1', 0),
+ array('admin', 'cpassman_dir', '', 0),
+ array('admin', 'cpassman_url', '', 0),
+ array('admin', 'favicon', '', 0),
+ array('admin', 'activate_expiration', '0', 0),
+ array('admin', 'pw_life_duration', '30', 0),
+ //array('admin', 'maintenance_mode','1',1),
+ array('admin', 'cpassman_version', $SETTINGS_EXT['version'], 1),
+ array('admin', 'ldap_mode', '0', 0),
+ array('admin', 'ldap_type', '0', 0),
+ array('admin', 'ldap_suffix', '0', 0),
+ array('admin', 'ldap_domain_dn', '0', 0),
+ array('admin', 'ldap_domain_controler', '0', 0),
+ array('admin', 'ldap_user_attribute', '0', 0),
+ array('admin', 'ldap_ssl', '0', 0),
+ array('admin', 'ldap_tls', '0', 0),
+ array('admin', 'ldap_elusers', '0', 0),
+ array('admin', 'richtext', 0, 0),
+ array('admin', 'allow_print', 0, 0),
+ array('admin', 'roles_allowed_to_print', 0, 0),
+ array('admin', 'show_description', 1, 0),
+ array('admin', 'anyone_can_modify', 0, 0),
+ array('admin', 'anyone_can_modify_bydefault', 0, 0),
+ array('admin', 'nb_bad_authentication', 0, 0),
+ array('admin', 'restricted_to', 0, 0),
+ array('admin', 'restricted_to_roles', 0, 0),
+ array('admin', 'utf8_enabled', 1, 0),
+ array('admin', 'custom_logo', '', 0),
+ array('admin', 'custom_login_text', '', 0),
+ array('admin', 'log_accessed', '1', 1),
+ array('admin', 'default_language', 'english', 0),
+ array(
+ 'admin',
+ 'send_stats',
+ empty($_SESSION['send_stats']) ? '0' : $_SESSION['send_stats'],
+ 1
+ ),
+ array('admin', 'get_tp_info', '1', 0),
+ array('admin', 'send_mail_on_user_login', '0', 0),
+ array('cron', 'sending_emails', '0', 0),
+ array('admin', 'nb_items_by_query', 'auto', 0),
+ array('admin', 'enable_delete_after_consultation', '0', 0),
+ array(
+ 'admin',
+ 'path_to_upload_folder',
+ strrpos($_SERVER['DOCUMENT_ROOT'], "/") == 1 ?
+ (strlen($_SERVER['DOCUMENT_ROOT']) - 1).substr(
+ $_SERVER['PHP_SELF'],
+ 0,
+ strlen($_SERVER['PHP_SELF']) - 25
+ ).'/upload'
+ :
+ $_SERVER['DOCUMENT_ROOT'].substr(
+ $_SERVER['PHP_SELF'],
+ 0,
+ strlen($_SERVER['PHP_SELF']) - 25
+ ).'/upload',
+ 0
+ ),
+ array(
+ 'admin',
+ 'url_to_upload_folder',
+ 'http://'.$_SERVER['HTTP_HOST'].substr(
+ $_SERVER['PHP_SELF'],
+ 0,
+ strrpos($_SERVER['PHP_SELF'], '/') - 8
+ ).'/upload',
+ 0
+ ),
+ array('admin', 'enable_personal_saltkey_cookie', '0', 0),
+ array('admin', 'personal_saltkey_cookie_duration', '31', 0),
+ array(
+ 'admin',
+ 'path_to_files_folder',
+ strrpos($_SERVER['DOCUMENT_ROOT'], "/") == 1 ?
+ (strlen($_SERVER['DOCUMENT_ROOT']) - 1).substr(
+ $_SERVER['PHP_SELF'],
+ 0,
+ strlen($_SERVER['PHP_SELF']) - 25
+ ).'/files'
+ :
+ $_SERVER['DOCUMENT_ROOT'].substr(
+ $_SERVER['PHP_SELF'],
+ 0,
+ strlen($_SERVER['PHP_SELF']) - 25
+ ).'/files',
+ 0
+ ),
+ array(
+ 'admin',
+ 'url_to_files_folder',
+ 'http://'.$_SERVER['HTTP_HOST'].substr(
+ $_SERVER['PHP_SELF'],
+ 0,
+ strrpos($_SERVER['PHP_SELF'], '/') - 8
+ ).'/files',
+ 0
+ ),
+ array('admin', 'pwd_maximum_length', '40', 0),
+ array('admin', 'ga_website_name', 'TeamPass for ChangeMe', 0),
+ array('admin', 'email_smtp_server', @$_SESSION['smtp_server'], 0),
+ array('admin', 'email_smtp_auth', @$_SESSION['smtp_auth'], 0),
+ array('admin', 'email_auth_username', @$_SESSION['smtp_auth_username'], 0),
+ array('admin', 'email_auth_pwd', @$_SESSION['smtp_auth_password'], 0),
+ array('admin', 'email_port', @$_SESSION['smtp_port'], 0),
+ array('admin', 'email_security', @$_SESSION['smtp_security'], 0),
+ array('admin', 'email_from', @$_SESSION['email_from'], 0),
+ array('admin', 'email_from_name', @$_SESSION['email_from_name'], 0),
+ array('admin', 'google_authentication', 0, 0),
+ array('admin', 'delay_item_edition', 0, 0),
+ array('admin', 'allow_import', 0, 0),
+ array('admin', 'proxy_port', 0, 0),
+ array('admin', 'proxy_port', 0, 0),
+ array('admin', 'upload_maxfilesize', '10mb', 0),
+ array(
+ 'admin',
+ 'upload_docext',
+ 'doc,docx,dotx,xls,xlsx,xltx,rtf,csv,txt,pdf,ppt,pptx,pot,dotx,xltx',
+ 0
+ ),
+ array('admin', 'upload_imagesext', 'jpg,jpeg,gif,png', 0),
+ array('admin', 'upload_pkgext', '7z,rar,tar,zip', 0),
+ array('admin', 'upload_otherext', 'sql,xml', 0),
+ array('admin', 'upload_imageresize_options', '1', 0),
+ array('admin', 'upload_imageresize_width', '800', 0),
+ array('admin', 'upload_imageresize_height', '600', 0),
+ array('admin', 'upload_imageresize_quality', '90', 0),
+ array('admin', 'enable_send_email_on_user_login', '0', 0),
+ array('admin', 'enable_user_can_create_folders', '0', 0),
+ array('admin', 'insert_manual_entry_item_history', '0', 0),
+ array('admin', 'enable_kb', '0', 0),
+ array('admin', 'enable_email_notification_on_item_shown', '0', 0),
+ array('admin', 'enable_email_notification_on_user_pw_change', '0', 0),
+ array('admin', 'enable_sts', '0', 0),
+ array('admin', 'encryptClientServer', '1', 0),
+ array('admin', 'use_md5_password_as_salt', '0', 0),
+ array('admin', 'api', '0', 0),
+ array('admin', 'subfolder_rights_as_parent', '0', 0),
+ array('admin', 'show_only_accessible_folders', '0', 0),
+ array('admin', 'enable_suggestion', '0', 0),
+ array('admin', 'email_server_url', '', 0),
+ array('admin', 'otv_expiration_period', '7', 0),
+ array('admin', 'default_session_expiration_time', '60', 0),
+ array('admin', 'duo', '0', 0),
+ array('admin', 'enable_server_password_change', '0', 0),
+ array('admin', 'bck_script_path', $_SESSION['abspath']."/backups", 0),
+ array('admin', 'bck_script_filename', 'bck_cpassman', 0)
+);
+$res1 = "na";
+foreach ($val as $elem) {
+ //Check if exists before inserting
+ $queryRes = mysqli_query(
+ $db_link,
+ "SELECT COUNT(*) FROM ".$pre."misc
+ WHERE type='".$elem[0]."' AND intitule='".$elem[1]."'"
+ );
+ if (mysqli_error($db_link)) {
+ echo '[{"finish":"1", "msg":"", "error":"MySQL Error! Last input is "'.$elem[1].' - '.
+ addslashes($queryRes).'"}]';
+ exit();
+ } else {
+ $resTmp = mysqli_fetch_row($queryRes);
+ if ($resTmp[0] === 0) {
+ $queryRes = mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc`
+ (`type`, `intitule`, `valeur`) VALUES
+ ('".$elem[0]."', '".$elem[1]."', '".
+ str_replace("'", "", $elem[2])."');"
+ );
+ if (mysqli_error($db_link)) {
+ echo '[{"finish":"1", "msg":"", "error":"MySQL Error1! '.addslashes(mysqli_error($db_link)).'"}]';
+ exit();
+ }
+ } else {
+ // Force update for some settings
+ if ($elem[3] === 1) {
+ $queryRes = mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."misc`
+ SET `valeur` = '".$elem[2]."'
+ WHERE `type` = '".$elem[0]."' AND `intitule` = '".$elem[1]."'"
+ );
+ if (mysqli_error($db_link)) {
+ echo '[{"finish":"1", "msg":"", "error":"MySQL Error2! '.addslashes(mysqli_error($db_link)).'"}]';
+ exit();
+ }
+ }
+ }
+ }
+}
+
+
+## Alter ITEMS table
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "anyone_can_modify",
+ "TINYINT(1) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "email",
+ "VARCHAR(100) DEFAULT NULL"
+);
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "notification",
+ "VARCHAR(250) DEFAULT NULL"
+);
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "viewed_no",
+ "INT(12) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "complexity_level",
+ "varchar(2) NOT null DEFAULT '-1'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."roles_values",
+ "type",
+ "VARCHAR(5) NOT NULL DEFAULT 'R'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "upgrade_needed",
+ "BOOLEAN NOT NULL DEFAULT FALSE"
+);
+
+$res2 = addIndexIfNotExist($pre.'items', 'restricted_inactif_idx', 'ADD INDEX `restricted_inactif_idx` (`restricted_to`,`inactif`)');
+
+# Alter tables
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."log_items MODIFY id_user INT(8)"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."restriction_to_roles MODIFY role_id INT(12)"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."restriction_to_roles MODIFY item_id INT(12)"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."items MODIFY pw TEXT"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users MODIFY pw VARCHAR(400)"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."cache CHANGE `login` `login` VARCHAR( 200 ) CHARACTER NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."log_system CHANGE `field_1` `field_1` VARCHAR( 250 ) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."keys CHANGE `table` `sql_table` VARCHAR( 25 ) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users MODIFY `key_tempo` varchar(100) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."categories CHANGE `type` `type` varchar(50) NULL default ''"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."categories CHANGE `order` `order` int(12) NOT NULL default '0'"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `derniers` `derniers` text NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `key_tempo` `key_tempo` varchar(100) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `last_pw_change` `last_pw_change` varchar(30) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `last_pw` `last_pw` text NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `fonction_id` `fonction_id` varchar(255) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `groupes_interdits` `groupes_interdits` varchar(255) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `last_connexion` `last_connexion` varchar(30) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `favourites` `favourites` varchar(300) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `latest_items` `latest_items` varchar(300) NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `avatar` `avatar` varchar(255) NOT null DEFAULT ''"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."users CHANGE `avatar_thumb` `avatar_thumb` varchar(255) NOT null DEFAULT ''"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."log_items CHANGE `raison` `raison` text NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."log_items CHANGE `raison_iv` `raison_iv` text NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."roles_values CHANGE `type` `type` VARCHAR( 5 ) NOT NULL DEFAULT 'R'"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."suggestion CHANGE `suggestion_key` `pw_iv` TEXT NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."suggestion CHANGE `key` `pw_iv` TEXT NULL"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."suggestion CHANGE `password` `pw` TEXT NULL"
+);
+
+## Alter USERS table
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "favourites",
+ "VARCHAR(300)"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "latest_items",
+ "VARCHAR(300)"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "personal_folder",
+ "INT(1) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "disabled",
+ "TINYINT(1) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "no_bad_attempts",
+ "TINYINT(1) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "can_create_root_folder",
+ "TINYINT(1) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "read_only",
+ "TINYINT(1) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "timestamp",
+ "VARCHAR(30) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "user_language",
+ "VARCHAR(30) NOT null DEFAULT 'english'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "name",
+ "VARCHAR(100) DEFAULT NULL"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "lastname",
+ "VARCHAR(100) DEFAULT NULL"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "session_end",
+ "VARCHAR(30) DEFAULT NULL"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "isAdministratedByRole",
+ "TINYINT(5) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "psk",
+ "VARCHAR(400) DEFAULT NULL"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "ga",
+ "VARCHAR(50) DEFAULT NULL"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "avatar",
+ "VARCHAR(255) NOT null DEFAULT ''"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "avatar_thumb",
+ "VARCHAR(255) NOT null DEFAULT ''"
+);
+$res2 = addColumnIfNotExist(
+ $pre."users",
+ "treeloadstrategy",
+ "VARCHAR(30) NOT null DEFAULT 'full'"
+);
+
+$res2 = addColumnIfNotExist(
+ $pre."log_items",
+ "raison_iv",
+ "TEXT null"
+);
+$res2 = addColumnIfNotExist(
+ $pre."categories_items",
+ "data_iv",
+ "TEXT NOT null"
+);
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "pw_iv",
+ "TEXT NOT null"
+);
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "pw_len",
+ "INT(5) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "auto_update_pwd_frequency",
+ "TINYINT(2) NOT NULL DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."items",
+ "auto_update_pwd_next_date",
+ "INT(15) NOT NULL DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."cache",
+ "renewal_period",
+ "TINYINT(4) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."suggestion",
+ "pw_len",
+ "int(5) NOT null DEFAULT '0'"
+);
+
+// Clean timestamp for users table
+mysqli_query($db_link, "UPDATE ".$pre."users SET timestamp = ''");
+
+## Alter nested_tree table
+$res2 = addColumnIfNotExist(
+ $pre."nested_tree",
+ "personal_folder",
+ "TINYINT(1) NOT null DEFAULT '0'"
+);
+$res2 = addColumnIfNotExist(
+ $pre."nested_tree",
+ "renewal_period",
+ "TINYINT(4) NOT null DEFAULT '0'"
+);
+
+addIndexIfNotExist(
+ $pre.'nested_tree',
+ 'personal_folder_idx',
+ 'ADD INDEX `personal_folder_idx` (`personal_folder`)'
+);
+
+
+#to 1.08
+//include('upgrade_db_1.08.php');
+
+## TABLE TAGS
+$res8 = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."tags` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `tag` varchar(30) NOT NULL,
+ `item_id` int(12) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id` (`id`)
+ );"
+);
+if (mysqli_error($db_link)) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table TAGS! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE LOG_SYSTEM
+$res8 = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."log_system` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `type` varchar(20) NOT NULL,
+ `date` varchar(30) NOT NULL,
+ `label` text NOT NULL,
+ `qui` varchar(30) NOT NULL,
+ PRIMARY KEY (`id`)
+ );"
+);
+if (empty(mysqli_error($db_link)) === true) {
+ mysqli_query(
+ $db_link,
+ "ALTER TABLE ".$pre."log_system
+ ADD `field_1` VARCHAR(250) NOT NULL"
+ );
+} else {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table LOG_SYSTEM! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE 10 - FILES
+$res9 = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."files` (
+ `id` int(11) NOT null AUTO_INCREMENT,
+ `id_item` int(11) NOT NULL,
+ `name` varchar(100) NOT NULL,
+ `size` int(10) NOT NULL,
+ `extension` varchar(10) NOT NULL,
+ `type` varchar(50) NOT NULL,
+ `file` varchar(50) NOT NULL,
+ PRIMARY KEY (`id`)
+ );"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table FILES! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."files`
+ CHANGE id id INT(11) AUTO_INCREMENT PRIMARY KEY;"
+);
+mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."files`
+ CHANGE name name VARCHAR(100) NOT NULL;"
+);
+
+## TABLE CACHE
+mysqli_query($db_link, "DROP TABLE IF EXISTS `".$pre."cache`");
+$res8 = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."cache` (
+ `id` int(12) NOT NULL,
+ `label` varchar(50) NOT NULL,
+ `description` text NOT NULL,
+ `tags` text NOT NULL,
+ `id_tree` int(12) NOT NULL,
+ `perso` tinyint(1) NOT NULL,
+ `restricted_to` varchar(200) NOT NULL,
+ `login` varchar(200) NOT NULL,
+ `folder` varchar(300) NOT NULL,
+ `author` varchar(50) NOT NULL,
+ `renewal_period` TINYINT(4) NOT null DEFAULT '0'
+ );"
+);
+if (empty(mysqli_error($db_link)) === true) {
+ //ADD VALUES
+ $sql = "SELECT *
+ FROM ".$pre."items as i
+ INNER JOIN ".$pre."log_items as l ON (l.id_item = i.id)
+ AND l.action = 'at_creation'
+ WHERE i.inactif=0";
+ $rows = mysqli_query($db_link, $sql);
+ while ($reccord = mysqli_fetch_array($rows)) {
+ //Get all TAGS
+ $tags = "";
+ $itemsRes = mysqli_query(
+ $db_link,
+ "SELECT tag FROM ".$pre."tags
+ WHERE item_id=".$reccord['id']
+ ) or die(mysqli_error($db_link));
+ $itemTags = mysqli_fetch_array($itemsRes);
+ if (!empty($itemTags)) {
+ foreach ($itemTags as $itemTag) {
+ if (!empty($itemTag['tag'])) {
+ $tags .= $itemTag['tag']." ";
+ }
+ }
+ }
+ //form id_tree to full foldername
+ $folder = "";
+ $arbo = $tree->getPath($reccord['id_tree'], true);
+ foreach ($arbo as $elem) {
+ $folder .= htmlspecialchars(stripslashes($elem->title), ENT_QUOTES)." > ";
+ }
+
+ //store data
+ mysqli_query(
+ $db_link,
+ "INSERT INTO ".$pre."cache
+ VALUES (
+ '".$reccord['id']."',
+ '".$reccord['label']."',
+ '".$reccord['description']."',
+ '".$tags."',
+ '".$reccord['id_tree']."',
+ '".$reccord['perso']."',
+ '".$reccord['restricted_to']."',
+ '".$reccord['login']."',
+ '".$folder."',
+ '".$reccord['id_user']."',
+ 0
+ )"
+ );
+ }
+} else {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table CACHE! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+/*
+ * Change table FUNCTIONS
+ * By 2 tables ROLES
+*/
+$res9 = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."roles_title` (
+ `id` int(12) NOT NULL,
+ `title` varchar(50) NOT NULL,
+ `allow_pw_change` TINYINT(1) NOT null DEFAULT '0',
+ `complexity` INT(5) NOT null DEFAULT '0',
+ `creator_id` int(11) NOT null DEFAULT '0'
+ );"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table roles_title! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+addColumnIfNotExist(
+ $pre."roles_title",
+ "allow_pw_change",
+ "TINYINT(1) NOT null DEFAULT '0'"
+);
+addColumnIfNotExist(
+ $pre."roles_title",
+ "complexity",
+ "INT(5) NOT null DEFAULT '0'"
+);
+addColumnIfNotExist(
+ $pre."roles_title",
+ "creator_id",
+ "INT(11) NOT null DEFAULT '0'"
+);
+
+$res10 = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."roles_values` (
+ `role_id` int(12) NOT NULL,
+ `folder_id` int(12) NOT NULL
+ );"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table roles_values! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+if (tableExists($pre."functions")) {
+ $tableFunctionExists = true;
+} else {
+ $tableFunctionExists = false;
+}
+if ($tableFunctionExists === true) {
+ //Get data from tables FUNCTIONS and populate new ROLES tables
+ $rows = mysqli_query(
+ $db_link,
+ "SELECT * FROM ".$pre."functions"
+ );
+ while ($reccord = mysqli_fetch_array($rows)) {
+ //Add new role title
+ mysqli_query(
+ $db_link,
+ "INSERT INTO ".$pre."roles_title
+ VALUES (
+ '".$reccord['id']."',
+ '".$reccord['title']."'
+ )"
+ );
+
+ //Add each folder in roles_values
+ foreach (explode(';', $reccord['groupes_visibles']) as $folderId) {
+ if (!empty($folderId)) {
+ mysqli_query(
+ $db_link,
+ "INSERT INTO ".$pre."roles_values
+ VALUES (
+ '".$reccord['id']."',
+ '".$folderId."'
+ )"
+ );
+ }
+ }
+ }
+
+ //Now alter table roles_title in order to create a primary index
+ mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."roles_title`
+ ADD PRIMARY KEY(`id`)"
+ );
+ mysqli_query(
+ $db_link,
+ "ALTER TABLE `".$pre."roles_title`
+ CHANGE `id` `id` INT(12) NOT null AUTO_INCREMENT "
+ );
+ addColumnIfNotExist(
+ $pre."roles_title",
+ "allow_pw_change",
+ "TINYINT(1) NOT null DEFAULT '0'"
+ );
+
+ //Drop old table
+ mysqli_query($db_link, "DROP TABLE ".$pre."functions");
+}
+
+## TABLE KB
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."kb` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `category_id` int(12) NOT NULL,
+ `label` varchar(200) NOT NULL,
+ `description` text NOT NULL,
+ `author_id` int(12) NOT NULL,
+ `anyone_can_modify` tinyint(1) NOT null DEFAULT '0',
+ PRIMARY KEY (`id`)
+ );"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table KB! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE KB_CATEGORIES
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."kb_categories` (
+ `id` int(12) NOT null AUTO_INCREMENT,
+ `category` varchar(50) NOT NULL,
+ PRIMARY KEY (`id`)
+ );"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table KB_CATEGORIES! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE KB_ITEMS
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."kb_items` (
+ `kb_id` tinyint(12) NOT NULL,
+ `item_id` tinyint(12) NOT NULL
+ );"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table KB_ITEMS! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE restriction_to_roles
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."restriction_to_roles` (
+ `role_id` tinyint(12) NOT NULL,
+ `item_id` tinyint(12) NOT NULL
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table RESTRICTION_TO_ROLES! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+} else {
+ $res = addIndexIfNotExist($pre.'restriction_to_roles', 'role_id_idx', 'ADD INDEX `role_id_idx` (`role_id`)');
+}
+
+## TABLE Languages
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."languages` (
+ `id` INT(10) NOT null AUTO_INCREMENT PRIMARY KEY ,
+ `name` VARCHAR(50) NOT null ,
+ `label` VARCHAR(50) NOT null ,
+ `code` VARCHAR(10) NOT null ,
+ `flag` VARCHAR(30) NOT NULL
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table LANGUAGES! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+$resTmp = mysqli_fetch_row(
+ mysqli_query($db_link, "SELECT COUNT(*) FROM ".$pre."languages")
+);
+mysqli_query($db_link, "TRUNCATE TABLE ".$pre."languages");
+mysqli_query(
+ $db_link,
+ "INSERT IGNORE INTO `".$pre."languages`
+ (`id`, `name`, `label`, `code`, `flag`) VALUES
+ ('', 'french', 'French' , 'fr', 'fr.png'),
+ ('', 'english', 'English' , 'us', 'us.png'),
+ ('', 'spanish', 'Spanish' , 'es', 'es.png'),
+ ('', 'german', 'German' , 'de', 'de.png'),
+ ('', 'czech', 'Czech' , 'cz', 'cz.png'),
+ ('', 'italian', 'Italian' , 'it', 'it.png'),
+ ('', 'russian', 'Russian' , 'ru', 'ru.png'),
+ ('', 'turkish', 'Turkish' , 'tr', 'tr.png'),
+ ('', 'norwegian', 'Norwegian' , 'no', 'no.png'),
+ ('', 'japanese', 'Japanese' , 'ja', 'ja.png'),
+ ('', 'portuguese', 'Portuguese' , 'pr', 'pr.png'),
+ ('', 'chinese', 'Chinese' , 'cn', 'cn.png'),
+ ('', 'swedish', 'Swedish' , 'se', 'se.png'),
+ ('', 'dutch', 'Dutch' , 'nl', 'nl.png'),
+ ('', 'catalan', 'Catalan' , 'ct', 'ct.png'),
+ ('', 'vietnamese', 'Vietnamese' , 'vi', 'vi.png'),
+ ('', 'estonian', 'Estonian' , 'ee', 'ee.png');"
+);
+
+## TABLE EMAILS
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."emails` (
+ `timestamp` INT(30) NOT null ,
+ `subject` VARCHAR(255) NOT null ,
+ `body` TEXT NOT null ,
+ `receivers` VARCHAR(255) NOT null ,
+ `status` VARCHAR(30) NOT NULL
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table EMAILS! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE AUTOMATIC DELETION
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."automatic_del` (
+ `item_id` int(11) NOT NULL,
+ `del_enabled` tinyint(1) NOT NULL,
+ `del_type` tinyint(1) NOT NULL,
+ `del_value` varchar(35) NOT NULL
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table AUTOMATIC_DEL! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE items_edition
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."items_edition` (
+ `item_id` int(11) NOT NULL,
+ `user_id` int(11) NOT NULL,
+ `timestamp` varchar(50) NOT NULL
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table items_edition! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE categories
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."categories` (
+ `id` int(12) NOT NULL AUTO_INCREMENT,
+ `parent_id` int(12) NOT NULL,
+ `title` varchar(255) NOT NULL,
+ `level` int(2) NOT NULL,
+ `description` text NOT NULL,
+ `type` varchar(50) NOT NULL,
+ `order` int(12) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table CATEGORIES! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE categories_items
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."categories_items` (
+ `id` int(12) NOT NULL AUTO_INCREMENT,
+ `field_id` int(11) NOT NULL,
+ `item_id` int(11) NOT NULL,
+ `data` text NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table categories_items! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE categories_folders
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."categories_folders` (
+ `id_category` int(12) NOT NULL,
+ `id_folder` int(12) NOT NULL
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table categories_folders! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE api
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."api` (
+ `id` int(20) NOT NULL AUTO_INCREMENT,
+ `type` varchar(15) NOT NULL,
+ `label` varchar(255) NOT NULL,
+ `value` varchar(255) NOT NULL,
+ `timestamp` varchar(50) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table API! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE otv
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."otv` (
+ `id` int(10) NOT NULL AUTO_INCREMENT,
+ `timestamp` text NOT NULL,
+ `code` varchar(100) NOT NULL,
+ `item_id` int(12) NOT NULL,
+ `originator` tinyint(12) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table OTV! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+## TABLE suggestion
+$res = mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."suggestion` (
+ `id` tinyint(12) NOT NULL AUTO_INCREMENT,
+ `label` varchar(255) NOT NULL,
+ `pw` text NOT NULL,
+ `pw_iv` text NOT NULL,
+ `pw_len` int(5) NOT NULL,
+ `description` text NOT NULL,
+ `author_id` int(12) NOT NULL,
+ `folder_id` int(12) NOT NULL,
+ `comment` text NOT NULL,
+ PRIMARY KEY (`id`)
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table SUGGESTIONS! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+# TABLE EXPORT
+mysqli_query(
+ $db_link,
+ "CREATE TABLE IF NOT EXISTS `".$pre."export` (
+ `id` int(12) NOT NULL,
+ `label` varchar(255) NOT NULL,
+ `login` varchar(100) NOT NULL,
+ `description` text NOT NULL,
+ `pw` text NOT NULL,
+ `path` varchar(255) NOT NULL
+ ) CHARSET=utf8;"
+);
+if (empty(mysqli_error($db_link)) === false) {
+ echo '[{"finish":"1", "msg":"", "error":"An error appears on table export! '.addslashes(mysqli_error($db_link)).'"}]';
+ mysqli_close($db_link);
+ exit();
+}
+
+//CLEAN UP ITEMS TABLE
+$allowedTags = ''.
+ '';
+$cleanRes = mysqli_query(
+ $db_link,
+ "SELECT id,description FROM `".$pre."items`"
+);
+while ($cleanData = mysqli_fetch_array($cleanRes)) {
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."items`
+ SET description = '".strip_tags($cleanData['description'], $allowedTags).
+ "' WHERE id = ".$cleanData['id']
+ );
+}
+
+// 2.1.23 - check if personal need to be upgraded
+$tmpResult = mysqli_query(
+ $db_link,
+ "SELECT `pw`, `pw_iv` FROM ".$pre."items WHERE perso='1'"
+);
+$tmp = mysqli_fetch_row($tmpResult);
+if ($tmp[1] === "" && substr($tmp[0], 0, 3) !== "def") {
+ mysqli_query($db_link, "UPDATE ".$pre."users SET upgrade_needed = true WHERE 1 = 1");
+}
+
+/*// Since 2.1.17, encrypt process is changed.
+// Previous PW need to be re-encrypted
+if (@mysqli_query(
+ $db_link,
+ "SELECT valeur FROM ".$pre."misc
+ WHERE type='admin' AND intitule = 'encryption_protocol'"
+)) {
+ $tmpResult = mysqli_query(
+ $db_link,
+ "SELECT valeur FROM ".$pre."misc
+ WHERE type='admin' AND intitule = 'encryption_protocol'"
+ );
+ $tmp = mysqli_fetch_row($tmpResult);
+ if ($tmp[0] != "ctr") {
+ //count elem
+ $res = mysqli_query(
+ $db_link,
+ "SELECT COUNT(*) FROM ".$pre."items
+ WHERE perso = '0'"
+ );
+ $data = mysqli_fetch_row($res);
+ if ($data[0] > 0) {
+ echo '$("#change_pw_encryption, #change_pw_encryption_progress").show();';
+ echo '$("#change_pw_encryption_progress").html('.
+ '"Number of Passwords to re-encrypt: '.$data[0].'");';
+ echo '$("#change_pw_encryption_total").val("'.$data[0].'")';
+ exit();
+ }
+
+ }
+}*/
+
+mysqli_close($db_link);
+
+echo '[{"finish":"1", "msg":"Database has been populated with Original Data.", "error":""}]';
diff --git a/install/upgrade_run_defuse_for_categories.php b/install/upgrade_run_defuse_for_categories.php
new file mode 100644
index 000000000..1161aa0e2
--- /dev/null
+++ b/install/upgrade_run_defuse_for_categories.php
@@ -0,0 +1,145 @@
+= $total) {
+ $finish = 1;
+}
+
+
+echo '[{"finish":"'.$finish.'" , "next":"'.$next.'", "error":""}]';
diff --git a/install/upgrade_run_defuse_for_custfields.php b/install/upgrade_run_defuse_for_custfields.php
new file mode 100644
index 000000000..0896f4598
--- /dev/null
+++ b/install/upgrade_run_defuse_for_custfields.php
@@ -0,0 +1,149 @@
+= $total) {
+ $finish = 1;
+}
+
+
+echo '[{"finish":"'.$finish.'" , "next":"'.$next.'", "error":""}]';
diff --git a/install/upgrade_run_defuse_for_files.php b/install/upgrade_run_defuse_for_files.php
new file mode 100644
index 000000000..b82687c97
--- /dev/null
+++ b/install/upgrade_run_defuse_for_files.php
@@ -0,0 +1,210 @@
+$iv, 'key'=>$key);
+
+ // Prepare encryption options - with old KEY
+ if ($SETTINGS['saltkey_ante_2127'] !== "none" && empty($SETTINGS['saltkey_ante_2127']) === false) {
+ // Encoding option were set as this in Teampass version < 2.1.27
+ $iv = substr(md5("\x1B\x3C\x58".$SETTINGS['saltkey_ante_2127'], true), 0, 8);
+ $key = substr(
+ md5("\x2D\xFC\xD8".$SETTINGS['saltkey_ante_2127'], true).
+ md5("\x2D\xFC\xD9".$SETTINGS['saltkey_ante_2127'], true),
+ 0,
+ 24
+ );
+ } else {
+ // Encoding option were set as this in Teampass version = 2.1.27.0
+ $iv = substr(md5("\x1B\x3C\x58".$ascii_key, true), 0, 8);
+ $key = substr(
+ md5("\x2D\xFC\xD8".$ascii_key, true).
+ md5("\x2D\xFC\xD9".$ascii_key, true),
+ 0,
+ 24
+ );
+ }
+ $opts_decrypt = array('iv'=>$iv, 'key'=>$key);
+
+ while ($data = mysqli_fetch_array($rows)) {
+ if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$data['file'])) {
+ // Make a copy of file
+ if (!copy(
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'],
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'].".copy"
+ )) {
+ $error = "Copy not possible";
+ exit;
+ } else {
+ // do a bck
+ copy(
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'],
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'].".bck"
+ );
+ }
+
+ // Open the file
+ unlink($SETTINGS['path_to_upload_folder'].'/'.$data['file']);
+ $file_primary = fopen($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".copy", "rb");
+ $out = fopen($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".tmp", 'wb');
+
+ // decrypt using old
+ stream_filter_append($file_primary, 'mdecrypt.tripledes', STREAM_FILTER_READ, $opts_decrypt);
+ // copy to file
+ stream_copy_to_stream($file_primary, $out);
+ // clean
+ fclose($file_primary);
+ fclose($out);
+ unlink($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".copy");
+
+
+ // Now encrypt the file with new saltkey
+ $file_primary = fopen($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".tmp", "rb");
+ $out = fopen($SETTINGS['path_to_upload_folder'].'/'.$data['file'], 'wb');
+ // encrypt using new
+ stream_filter_append($out, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts_encrypt);
+ // copy to file
+ while (($line = fgets($file_primary)) !== false) {
+ fputs($out, (string) $line);
+ }
+
+ // clean
+ fclose($file_primary);
+ fclose($out);
+ unlink($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".tmp");
+
+ // update table
+ mysqli_query(
+ $db_link,
+ "UPDATE `".$pre."files`
+ SET `status` = 'encrypted'
+ WHERE id = '".$data['id']."'"
+ );
+ }
+ }
+
+ if ($next >= $total) {
+ $finish = 1;
+ }
+} else {
+ echo '[{"finish":"1" , "error":"'.SECUREPATH.'/teampass-seckey.txt does not exist!"}]';
+ exit();
+}
+
+
+echo '[{"finish":"'.$finish.'" , "next":"'.$next.'", "error":""}]';
diff --git a/install/upgrade_run_defuse_for_files_step2.php b/install/upgrade_run_defuse_for_files_step2.php
new file mode 100644
index 000000000..fbee2d1a1
--- /dev/null
+++ b/install/upgrade_run_defuse_for_files_step2.php
@@ -0,0 +1,205 @@
+$iv, 'key'=>$key);
+
+ while ($data = mysqli_fetch_array($rows)) {
+ if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$data['file']) && $data['status'] === 'encrypted') {
+ // Check if file is already encrypted with Defuse.
+ // If yes, then stop
+ try {
+ \Defuse\Crypto\File::decryptFile(
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'],
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'].".defuse_test",
+ $defuse_key
+ );
+ } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
+ // Make a copy of file
+ if (!copy(
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'],
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'].".copy"
+ )) {
+ $error = "Copy not possible";
+ exit;
+ } else {
+ // do a bck
+ copy(
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'],
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'].".bck"
+ );
+ }
+
+ // Open the file
+ unlink($SETTINGS['path_to_upload_folder'].'/'.$data['file']);
+ $file_primary = fopen($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".copy", "rb");
+ $out = fopen($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".tmp", 'wb');
+
+ // decrypt using old
+ stream_filter_append($file_primary, 'mdecrypt.tripledes', STREAM_FILTER_READ, $opts_decrypt_defuse);
+ // copy to file
+ stream_copy_to_stream($file_primary, $out);
+ // clean
+ fclose($file_primary);
+ fclose($out);
+ unlink($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".copy");
+
+ // Now encrypt the file with new saltkey
+ $err = '';
+ try {
+ \Defuse\Crypto\File::encryptFile(
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'].".tmp",
+ $SETTINGS['path_to_upload_folder'].'/'.$data['file'],
+ $defuse_key
+ );
+ } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
+ $err = "encryption_not_possible";
+ } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
+ $err = $ex;
+ } catch (Defuse\Crypto\Exception\IOException $ex) {
+ $err = $ex;
+ }
+ if (empty($err) === false) {
+ echo $err;
+ }
+
+ // clean
+ unlink($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".tmp");
+ }
+ // Clean if needed
+ if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".defuse_test")) {
+ unlink($SETTINGS['path_to_upload_folder'].'/'.$data['file'].".defuse_test");
+ }
+ }
+ }
+
+ if ($next >= $total) {
+ $finish = 1;
+ }
+} else {
+ echo '[{"finish":"1" , "error":"'.SECUREPATH.'/teampass-seckey.txt does not exist!"}]';
+ exit();
+}
+
+
+echo '[{"finish":"'.$finish.'" , "next":"'.$next.'", "error":""}]';
diff --git a/install/upgrade_run_defuse_for_logs.php b/install/upgrade_run_defuse_for_logs.php
new file mode 100644
index 000000000..31489869a
--- /dev/null
+++ b/install/upgrade_run_defuse_for_logs.php
@@ -0,0 +1,148 @@
+= $total) {
+ $finish = 1;
+}
+
+
+echo '[{"finish":"'.$finish.'" , "next":"'.$next.'", "error":""}]';
diff --git a/install/upgrade_run_defuse_for_pwds.php b/install/upgrade_run_defuse_for_pwds.php
new file mode 100644
index 000000000..f41e70838
--- /dev/null
+++ b/install/upgrade_run_defuse_for_pwds.php
@@ -0,0 +1,145 @@
+= $total) {
+ $finish = 1;
+}
+
+
+echo '[{"finish":"'.$finish.'" , "next":"'.$next.'", "error":""}]';
diff --git a/install/upgrade_run_encryption_pwd.php b/install/upgrade_run_encryption_pwd.php
new file mode 100644
index 000000000..e7c084ec4
--- /dev/null
+++ b/install/upgrade_run_encryption_pwd.php
@@ -0,0 +1,274 @@
+ ".$record['raison']);
+ if (!empty($record['raison_iv']) && $record['raison_iv'] != null) {
+ // nothing to do
+ fputs($dbgDuo, (string) "Item log correct");
+ } else {
+ // only at_modif and at_pw
+ $reason = explode(' : ', $record['raison']);
+ if (trim($reason[0]) == "at_pw") {
+ // check if pw encrypted with protocol #2
+ $pw = decrypt(trim($reason[1]));
+ fputs($dbgDuo, (string) "\n/ step1 : ".$pw);
+ if (empty($pw)) {
+ // used protocol is #1
+ $pw = decryptOld(trim($reason[1])); // decrypt using protocol #1
+ fputs($dbgDuo, (string) " / step2 : ".$pw);
+ }
+
+ // get key for this pw
+ $resData_tmp = mysqli_query(
+ $db_link,
+ "SELECT rand_key FROM ".$pre."keys
+ WHERE `sql_table` = 'items' AND id = ".$data['id']
+ );
+ if (!$resData_tmp) {
+ echo '[{"finish":"1" , "error":"'.mysqli_error($db_link).'"}]';
+ exit();
+ }
+
+ $dataTemp = mysqli_fetch_row($resData_tmp);
+ if (!empty($dataTemp[0])) {
+ // remove key from pw
+ $pw = substr($pw, strlen($dataTemp[0]));
+ }
+ fputs($dbgDuo, (string) " / step3 : ".$pw);
+
+ // store new encryption
+ if (isUTF8($pw) && !empty($pw)) {
+ $encrypt = cryption_phpCrypt($pw, SALT, "", "encrypt");
+ fputs($dbgDuo, (string) " / Final : ".$encrypt['string']);
+ mysqli_query(
+ $db_link,
+ "UPDATE ".$pre."log_items
+ SET raison = 'at_pw : ".$encrypt['string']."', raison_iv = '".$encrypt['iv']."'
+ WHERE id_item =".$data['id']." AND date='".$record['mDate']."'
+ AND id_user=".$record['id_user']." AND action ='".$record['action']."'"
+ );
+ } else {
+ //data is lost ... unknown encryption
+ }
+ fputs($dbgDuo, (string) " / Done.");
+ }
+ }
+ }
+
+ fputs($dbgDuo, (string) "\nLog treatment done.");
+
+ // change category fields encryption
+ $resData = mysqli_query(
+ $db_link,
+ "SELECT i.data AS data, k.rand_key AS rndKey
+ FROM ".$pre."categories_items AS i
+ LEFT JOIN ".$pre."keys AS k ON (k.id = i.item_id)
+ WHERE i.item_id = ".$data['id']." AND k.sql_table='items'"
+ );
+ if (!$resData) {
+ echo '[{"finish":"1" , "error":"'.mysqli_error($db_link).'"}]';
+ exit();
+ }
+
+ while ($record = mysqli_fetch_array($resData)) {
+ $tmpData = substr(decrypt($record['data']), strlen($record['rndKey']));
+ if (isUTF8($tmpData) && !empty($tmpData)) {
+ $encrypt = cryption_phpCrypt($tmpData, SALT, "", "encrypt");
+
+ // store Password
+ $resData_tmp2 = mysqli_query(
+ $db_link,
+ "UPDATE ".$pre."categories_items
+ SET data = '".$encrypt['string']."', data_iv = '".$encrypt['iv']."'
+ WHERE item_id =".$data['id']
+ );
+ if (!$resData_tmp2) {
+ echo '[{"finish":"1" , "error":"'.mysqli_error($db_link).'"}]';
+ exit();
+ }
+ } else {
+ //data is lost ... unknown encryption
+ }
+ }
+ fputs($dbgDuo, (string) "\nCategory treatment done.");
+ }
+}
+if ($next >= $total) {
+ $finish = 1;
+}
+
+
+fputs($dbgDuo, (string) "\n\nAll finished.\n");
+
+echo '[{"finish":"'.$finish.'" , "next":"'.$next.'", "error":""}]';
diff --git a/install/upgrade_run_encryption_suggestions.php b/install/upgrade_run_encryption_suggestions.php
new file mode 100644
index 000000000..92251b56e
--- /dev/null
+++ b/install/upgrade_run_encryption_suggestions.php
@@ -0,0 +1,119 @@
+ this will be the last task during update
+if ($post_type === "reload_cache_table" || empty($post_type)) {
+ //Load Tree
+ $tree = new SplClassLoader('Tree\NestedTree', '../includes/libraries');
+ $tree->register();
+ $tree = new Tree\NestedTree\NestedTree(prefix_table("nested_tree"), 'id', 'parent_id', 'title');
+
+ // truncate table
+ mysqli_query($db_link, "TRUNCATE TABLE ".$pre."cache");
+
+ // reload table
+ $rows = mysqli_query(
+ $db_link,
+ "SELECT *
+ FROM ".$pre."items as i
+ INNER JOIN ".$pre."log_items as l ON (l.id_item = i.id)
+ AND l.action = 'at_creation'
+ AND i.inactif = 0"
+ );
+ foreach ($rows as $record) {
+ // Get all TAGS
+ $tags = "";
+ $itemTags = mysqli_query(
+ $db_link,
+ "SELECT tag FROM ".$pre."tags WHERE item_id=".intval($record['id'])
+ );
+ $itemTags = mysqli_fetch_array($itemTags);
+ foreach ($itemTags as $itemTag) {
+ if (!empty($itemTag['tag'])) {
+ $tags .= $itemTag['tag']." ";
+ }
+ }
+ // Get renewal period
+ $resNT = mysqli_query(
+ $db_link,
+ "SELECT renewal_period FROM ".$pre."nested_tree WHERE id=".intval($record['id_tree'])
+ );
+ $resNT = mysqli_fetch_array($resNT);
+
+ // form id_tree to full foldername
+ $folder = "";
+ $arbo = $tree->getPath($record['id_tree'], true);
+ foreach ($arbo as $elem) {
+ if ($elem->title == $_SESSION['user_id'] && $elem->nlevel == 1) {
+ $elem->title = $_SESSION['login'];
+ }
+ if (empty($folder)) {
+ $folder = stripslashes($elem->title);
+ } else {
+ $folder .= " » ".stripslashes($elem->title);
+ }
+ }
+
+ // temp data
+ if (!isset($record['login'])) {
+ $record['login'] = "";
+ }
+ if (!isset($resNT['renewal_period'])) {
+ $resNT['renewal_period'] = "0";
+ }
+
+ // store data
+ $res = mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."cache`
+ (`id`, `label`, `description`, `tags`, `id_tree`, `perso`, `restricted_to`, `login`, `folder`, `author`, `renewal_period`, `timestamp`) VALUES (
+ '".$record['id']."',
+ '".addslashes($record['label'])."',
+ '".addslashes($record['description'])."',
+ '".$tags."',
+ '".$record['id_tree']."',
+ '".$record['perso']."',
+ '".$record['restricted_to']."',
+ '".$record['login']."',
+ '".$folder."',
+ '".$record['id_user']."',
+ '".$resNT['renewal_period']."',
+ '".$record['date']."'
+ )"
+ );
+ if (mysqli_error($db_link)) {
+ echo $res;
+ }
+ }
+
+ $finish = 1;
+}
+
+
+
+// 2.1.27
+if ($SETTINGS_EXT['version'] === "2.1.27") {
+ $tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'migration_to_2127'"));
+ if (intval($tmp) === 0) {
+ $mysqli_result = mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc`
+ (`increment_id`, `type`, `intitule`, `valeur`)
+ VALUES (NULL, 'admin', 'migration_to_2127', 'done')"
+ );
+ } else {
+ mysqli_query(
+ $db_link,
+ "UPDATE ".$pre."misc
+ SET `valeur` = 'done'
+ WHERE type = 'admin' AND intitule = 'migration_to_2127'"
+ );
+ }
+
+ $tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'files_with_defuse'"));
+ if (intval($tmp) === 0) {
+ $mysqli_result = mysqli_query(
+ $db_link,
+ "INSERT INTO `".$pre."misc`
+ (`increment_id`, `type`, `intitule`, `valeur`)
+ VALUES (NULL, 'admin', 'files_with_defuse', 'done')"
+ );
+ } else {
+ mysqli_query(
+ $db_link,
+ "UPDATE ".$pre."misc
+ SET `valeur` = 'done'
+ WHERE type = 'admin' AND intitule = 'files_with_defuse'"
+ );
+ }
+}
+
+
+// alter ITEMS table by adding default value to encryption_type field
+mysqli_query($db_link, "ALTER TABLE `".$pre."items` CHANGE encryption_type encryption_type varchar(20) NOT NULL DEFAULT 'defuse'");
+
+
+
+/*
+* UPDATE CONFIG file
+*/
+$tp_config_file = "../includes/config/tp.config.php";
+if (file_exists($tp_config_file)) {
+ if (!copy($tp_config_file, $tp_config_file.'.'.date("Y_m_d", mktime(0, 0, 0, date('m'), date('d'), date('y'))))) {
+ echo '[{"error" : "includes/config/tp.config.php file already exists and cannot be renamed. Please do it by yourself and click on button Launch.", "result":"", "index" : "'.$post_index.'", "multiple" : "'.$post_multiple.'"}]';
+ return false;
+ } else {
+ unlink($tp_config_file);
+ }
+}
+$file_handler = fopen($tp_config_file, 'w');
+$config_text = "";
+$any_settings = false;
+
+$result = mysqli_query($db_link, "SELECT * FROM `".$pre."misc` WHERE `type` = 'admin'");
+while ($row = mysqli_fetch_assoc($result)) {
+ // append new setting in config file
+ $config_text .= "
+ '".$row['intitule']."' => '".$row['valeur']."',";
+ if ($any_settings === false) {
+ $any_settings = true;
+ }
+}
+mysqli_free_result($result);
+
+// write to config file
+if ($any_settings === true) {
+ $result = fwrite(
+ $file_handler,
+ utf8_encode(
+ "= count($scripts_list)) {
+ $finished = 1;
+} else {
+ $finished = 0;
+}
+echo '[{"finish":"'.$finished.'", "scriptname":"'.$scripts_list[$post_file_number][0].'", "parameter":"'.$scripts_list[$post_file_number][1].'"}]';