From 5fbee7fdc7f71b126640cb9a9096f64a67be7f50 Mon Sep 17 00:00:00 2001 From: nilsteampassnet Date: Tue, 12 Dec 2017 18:43:16 +0100 Subject: [PATCH] 2.1.27 --- install/css/install.css | 106 ++ .../css/overcast/images/animated-overlay.gif | Bin 0 -> 1738 bytes .../images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 0 -> 212 bytes .../images/ui-bg_flat_0_eeeeee_40x100.png | Bin 0 -> 220 bytes .../images/ui-bg_flat_55_c0402a_40x100.png | Bin 0 -> 205 bytes .../images/ui-bg_flat_55_eeeeee_40x100.png | Bin 0 -> 220 bytes .../images/ui-bg_glass_100_f8f8f8_1x400.png | Bin 0 -> 259 bytes .../images/ui-bg_glass_35_dddddd_1x400.png | Bin 0 -> 254 bytes .../images/ui-bg_glass_60_eeeeee_1x400.png | Bin 0 -> 254 bytes .../ui-bg_inset-hard_75_999999_1x100.png | Bin 0 -> 247 bytes .../ui-bg_inset-soft_50_c9c9c9_1x100.png | Bin 0 -> 254 bytes .../images/ui-icons_3383bb_256x240.png | Bin 0 -> 4430 bytes .../images/ui-icons_454545_256x240.png | Bin 0 -> 4431 bytes .../images/ui-icons_70b2e1_256x240.png | Bin 0 -> 4430 bytes .../images/ui-icons_999999_256x240.png | Bin 0 -> 4431 bytes .../images/ui-icons_fbc856_256x240.png | Bin 0 -> 4430 bytes .../overcast/jquery-ui-1.10.3.custom.min.css | 5 + install/images/76.gif | Bin 0 -> 5440 bytes install/images/ajax-loader.gif | Bin 0 -> 882 bytes install/images/cross.png | Bin 0 -> 655 bytes install/images/error.png | Bin 0 -> 666 bytes install/images/exclamation-red.png | Bin 0 -> 696 bytes install/images/information-white.png | Bin 0 -> 707 bytes install/images/minus-circle.png | Bin 0 -> 655 bytes install/images/tick-circle.png | Bin 0 -> 724 bytes install/images/tick.png | Bin 0 -> 634 bytes install/install.css | 88 ++ install/install.js | 263 ++++ install/install.php | 302 ++++ install/install.queries.php | 1199 ++++++++++++++++ install/js/aes.min.js | 457 ++++++ install/js/crypt/aes.class.php | 207 +++ install/js/crypt/aes.min.js | 457 ++++++ install/js/crypt/aesctr.class.php | 191 +++ install/js/jquery-ui.min.js | 638 +++++++++ install/js/jquery.min.js | 18 + install/libs/aesctr.php | 406 ++++++ install/upgrade.js | 92 ++ install/upgrade.php | 658 +++++++++ install/upgrade_ajax.php | 957 +++++++++++++ install/upgrade_db_1.08.php | 123 ++ install/upgrade_run_2.1.26.php | 346 +++++ install/upgrade_run_2.1.27.php | 772 ++++++++++ install/upgrade_run_db_original.php | 1267 +++++++++++++++++ install/upgrade_run_defuse_for_categories.php | 145 ++ install/upgrade_run_defuse_for_custfields.php | 149 ++ install/upgrade_run_defuse_for_files.php | 210 +++ .../upgrade_run_defuse_for_files_step2.php | 205 +++ install/upgrade_run_defuse_for_logs.php | 148 ++ install/upgrade_run_defuse_for_pwds.php | 145 ++ install/upgrade_run_encryption_pwd.php | 274 ++++ .../upgrade_run_encryption_suggestions.php | 119 ++ install/upgrade_run_final.php | 246 ++++ install/upgrade_scripts_manager.php | 46 + 54 files changed, 10239 insertions(+) create mode 100644 install/css/install.css create mode 100644 install/css/overcast/images/animated-overlay.gif create mode 100644 install/css/overcast/images/ui-bg_flat_0_aaaaaa_40x100.png create mode 100644 install/css/overcast/images/ui-bg_flat_0_eeeeee_40x100.png create mode 100644 install/css/overcast/images/ui-bg_flat_55_c0402a_40x100.png create mode 100644 install/css/overcast/images/ui-bg_flat_55_eeeeee_40x100.png create mode 100644 install/css/overcast/images/ui-bg_glass_100_f8f8f8_1x400.png create mode 100644 install/css/overcast/images/ui-bg_glass_35_dddddd_1x400.png create mode 100644 install/css/overcast/images/ui-bg_glass_60_eeeeee_1x400.png create mode 100644 install/css/overcast/images/ui-bg_inset-hard_75_999999_1x100.png create mode 100644 install/css/overcast/images/ui-bg_inset-soft_50_c9c9c9_1x100.png create mode 100644 install/css/overcast/images/ui-icons_3383bb_256x240.png create mode 100644 install/css/overcast/images/ui-icons_454545_256x240.png create mode 100644 install/css/overcast/images/ui-icons_70b2e1_256x240.png create mode 100644 install/css/overcast/images/ui-icons_999999_256x240.png create mode 100644 install/css/overcast/images/ui-icons_fbc856_256x240.png create mode 100644 install/css/overcast/jquery-ui-1.10.3.custom.min.css create mode 100644 install/images/76.gif create mode 100644 install/images/ajax-loader.gif create mode 100644 install/images/cross.png create mode 100644 install/images/error.png create mode 100644 install/images/exclamation-red.png create mode 100644 install/images/information-white.png create mode 100644 install/images/minus-circle.png create mode 100644 install/images/tick-circle.png create mode 100644 install/images/tick.png create mode 100644 install/install.css create mode 100644 install/install.js create mode 100644 install/install.php create mode 100644 install/install.queries.php create mode 100644 install/js/aes.min.js create mode 100644 install/js/crypt/aes.class.php create mode 100644 install/js/crypt/aes.min.js create mode 100644 install/js/crypt/aesctr.class.php create mode 100644 install/js/jquery-ui.min.js create mode 100644 install/js/jquery.min.js create mode 100644 install/libs/aesctr.php create mode 100644 install/upgrade.js create mode 100644 install/upgrade.php create mode 100644 install/upgrade_ajax.php create mode 100644 install/upgrade_db_1.08.php create mode 100644 install/upgrade_run_2.1.26.php create mode 100644 install/upgrade_run_2.1.27.php create mode 100644 install/upgrade_run_db_original.php create mode 100644 install/upgrade_run_defuse_for_categories.php create mode 100644 install/upgrade_run_defuse_for_custfields.php create mode 100644 install/upgrade_run_defuse_for_files.php create mode 100644 install/upgrade_run_defuse_for_files_step2.php create mode 100644 install/upgrade_run_defuse_for_logs.php create mode 100644 install/upgrade_run_defuse_for_pwds.php create mode 100644 install/upgrade_run_encryption_pwd.php create mode 100644 install/upgrade_run_encryption_suggestions.php create mode 100644 install/upgrade_run_final.php create mode 100644 install/upgrade_scripts_manager.php 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 0000000000000000000000000000000000000000..d441f75ebfbdf26a265dfccd670120d25c0a341c GIT binary patch literal 1738 zcmZ|OX;ji_6b5ixNYt8>l?gOuO)6lU%W(mxn(`>1S(XO;u`D+P%xqBvMr|w-Vyr1s z7R|Cn0b8|Hu<=Zmv1mFqh9Fj!NuZfKB2MP$e75`XJ@>=!y!Ux9xR3x;EW!q1^V>X| znVFuRUN`NqJ2)ybXh%e__h!!pv(M|S3+?9F%(K}zyE40MGyhWF5-IDgL&=%2-9`Nk z!1@8uk4t%_{(K~>N;sK&dzJbwJ=$kYTlL=$%#0Pfh>U{%i@~wWbvYsD_K-D`&+u1( z#Ma`>%q<^UhzGvi(hyE`zCD{-=2|zL5>wnB=DE!U?(CZG%q4@lDnCq_%&3DCla#(X zmBhDD+RN$aMWWHm?ig*>1Onn6~r?Ma~N2JKAxN>H%UtRyRqS)6Um!-Tz%-r=& zQmTb^JFIe3W^-kAm`}`2P|niMh>RYyd)S^f(dbrx965?rzbhP|XeP}o&&DSZ4|oYQ z)I{f!SfycYw?3=9W;o-B%U5xs(pP267X~9-7L|4WzaYexC0GtG8wWygm63rF{llCEraxzkc=IxvFQ-y37=_;e5 zJLq^gsSO0Ayz?a>E_?{dmUc+t#qv$)XN8$<<}rQ#)lsiw+pmL&J>~+hgpo>i$m+;l zZIa_ZRIfSeT$~v5d`EBV&*k`apPgjv&B|+d`Q!nyu{L4rs%ZfoF0*Kq8I%ByOcFpL zK=>wzofZo<+0GZLCnWM3oQ^pb(gRSf02;~cEn@LJ>~XB9IkEX{$N#Z`m%>S!U{uPx zloI%bLdo$Adxlh(Uv^yX7s5G&C zLwNRG>~T?G{kzupp8EcyLGPoPf)@&9Wqfw_l&uU-6cexk%5;uQg%wb=0k_733{i#& z1a2p)gV3S2+QG1-K9tZ}E~I<(P0r2aFFY-c{o?TUOz3Xjod#TLE2A_c?*T7t z=1>~%YW450{Qqno4t`}gvLnuMrcu8+#xEBoY%2_+Mb#Z6S38+r*M4O`-+!zl(@m`D zQsi|GA2l3gEy}LFe<#Hv8?$_L#u8E|3-bP$*La*E>B{X!Sy4i6?TKam!49aXCAW4S*P_O^H4^*DpiA40o}Uqw~Eo&veh1`|8i zD2$x+>_b^bXE4N;AW=5>iYak2%!JAh0j1*k1{p#iRCjbB7!cSws~U{1IA@acLII$t z$>X#A+^s6iJ5~DFG!xa?>z{=lxtdi1rzbM-(nqAu3D8h-&64xo6|E!p?pK0xT;qoK z`6%+SpBk+~M?nO}>2mTw!A{yZ6O>Z@kwSd4;8aWU5z!P~tQl?u==^+R`{OmOS}oZh zOXQ3{6kuz?Is^n^L7;9ieB9C+8B{>t+pDrlq4xGDDn#T#3T5$l1g`FTQkU;b-981j zNm{zC`$wn7etklM#qHI4=3m5gwa6DNS{?Z!vSObi_od{4eUo=_S2BKNpkSdiqe(k9WtkeM79;2-%CFbb)aB=&H1?i1}uwFzoZQ(38Kn1zBP ORn*B%u*Wk|4g3!*Rv{Mv literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..414803b7ec93c3453bdab0fca64e190b4691fee0 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^8bF-F1SA+{?>A)!QcOwS?k)_>#w|r1Kptm-M`SUO z_5fqIli7AahM1>|V~EA+ zRdP`(kYX@0Ff`URFxNFS2{E*^GBvd_G6!<43=E_lCY(pnkei>9nO2EgLzb)t$UzLA Lu6{1-oD!M?t&Hpz19_YU9+AaB z+5?Q;PG;Ky8FHR3jv*e$lPlU;4SKlxP~aja2Dul`ryR1bKLV;$Epd$~Nl7e8wMs5Z z1yT$~28PDE2IjhkCLxBFR;H#_CLperfq`bi-e?pJx%nxXX_dG&MA))E2WnvOboFyt I=akR{0Oad7UjP6A literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..7e06956568d171610705f1a8322f233cff7b3942 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^8bF-F$P6UUt$JVyq?iMILR=3xXvvD}dIGte1s;*b zK-vS0-A-oP0U3OrE{-7*lF1URiyPP&7?>g$7{wlixC3QWOI#yLQW8s2t&)pUffR$0 zfuXUkfw``sNr<7Pm8q$fsR@v4WniF?+w6^^AvZrIGp!Q0hCl=B??4Rzopr E0P@!^761SM literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..f92fcfdff1393c2eeba0f4ee0cb2300db9417bbb GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^8bF-F0wfqj{vTKlq?nSt-CY>?t&Hpz19_YU9+AaB z+5?Q;PG;Ky8FHR3jv*e$lPlU;4SKlxP~aja2Dul`ryR1bKLV;$Epd$~Nl7e8wMs5Z z1yT$~28PDE2IjhkCLxBFR;H#_rY1nHm4SgmZnHOvhTQy=%(P0}8UhWhzXLTec)I$z JtaD0e0sz+yHctQm literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5faa7443d938c7b408ccc97643c566277ba193b4 GIT binary patch literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^j6gI&0LWmFTHNUZq&N#aB8!2v2N=7Z%(eqEn3BBR zUH<4GEgSa(4OA_0jVMV;EJ?LW zE=mPb3`Pcq#<~XPx`rkphL%>Qra%PbS{WF$Np<{3(U6;;l9^VCTf=vE181NH22WQ% Jmvv4FO#lhiO>_VN literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..7f16ad90508916649fea7259235f8f3885efd320 GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^j6gI&0LWmFTHNUZq&N#aB8!2v2N=7Z%(eqEn3BBR zUH<7J-I$S z!ZRe)58Sxw)6=TJ+EeDk6SG*+tgFM3!6cDKb57@PeV|#YC9V-ADTyViR>?)FK#IZ0 zz|dINz+BhRB*f6t%GA`#)C9=2GB8lcZT3ddkei>9nO2EgL!g26cc2CaPgg&ebxsLQ E05bPTF8}}l literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..88a85630e569053a99dbfc9b7b957a4fc6f112a2 GIT binary patch literal 247 zcmeAS@N?(olHy`uVBq!ia0vp^j6j?s03;ZUuHXC*q&N#aB8!2v2N=7Z%(eqEn3BBR zUH<{nVMRengF?01_lbb&E6;)a`RI%(<*Um2sE(%4%EQl>FVdQ&MBb@ E00weKm;e9( literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..af7039ded25ad508127f26e41d5643be33bf93d5 GIT binary patch literal 4430 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 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..d17a9276676d7508db7e72191a8af22999a6d3de GIT binary patch literal 4431 zcmeH~`8(9__s3teF}A3YhA@^IWowXa8e*SV8SjSU2N#drY# z5V%0nHv<6B{t;M#L-u$21;g!q!{bY`_TRUpf7bbrUif{l1E!bE&;39DvjbyZvnKm3 zvJNmaz5;;25GWU%S3n3MA}S^>iIS3*kv%4NQt_0Es@iESoGyWQ&VXci(e&~a3mZpg z7dMX^H_5lcqbM=)2`OnA4<0|wqZU3ZDSh#>{7qGDePdH=duLDIvu;%S83T^W&G)B($D0N0cnk3Tqxi&vJ$X?f))&jHqH( zmrcwW+27vVOXHV1H}iAlkkaG(O5wklaJ(-{koGs|uXqxPLp` zl0^H@Y+i)FCG=CFE39-sJNZ=+;946EMqeGyZ^(hx5S{=ZnR;E@5|!|&goz^+K@W9Q z9fv1h5~*L@OrZjBqJZ=3xBNdVzjE~|(O=0lHCM+&mn&|9qIuWJARjYu4aTFnSE39r zbv=f?33?(43qdfVgh{EU#D8gN$2AM=oE^M7LOHXnN)-YGS6qw3DOo~h?#o$+3}A}j zGKsC9r)?jMz_dWBNZfBRe(R0kQ7zLSoh6;LX_@=rxVykYd33BAY_9yZEgB^i8{R(1 z{X{U~xUD;$(4I3@9p73LA-rGvKhUYgRqxfB2DhEw^3n@TObZmChW$${jRGOvyy&4Gn}Y!dWyeD{iI>L?TnjX3lVL5E+Qx@b4>DLr*~fpg{kZvTS0#oVvI*mARoq_PJk0!3D`)w{;)N!0jgwPWr)Q783~P3-hc_3y)O=Dh6er1EY+D0O?;fKAPvQdbBTZAQtaeSkQk`l=)7Z92>xjn9KbJ>IN$69;j}7&%f#rz zMc?X^+IV~|X<>ZX@?7xtzG-D*t=mGZh<*;>B{P7Y^7%Gcmr$8qPv?b>C$`e85JyJ% zBjNzjkKCQUDBx$LdO%uB+w|)X19xU;m1%>m;@%N>0?|e~BmECjSbeIO#GO`%nwIQB z6@xn$y)qgexOjV9!XTHMZLGL+&5-(0pH=R4 zEBLRsSGj0zgq6*siL@P%?KVHwLFwV6$iuW$*yOaA9F<2i0!m7Z>+4-)I==G?5~~-P z{vtX;iVhg+kCcJ#2IDj)z2)@v%LFUnQ%259)47X70jkY+dl%N&seVz2;79r^2Mdp5 z+n7kC=XrxWzd)-C>ecWQ52N7oY4`Ip|0$!wqSI%K@ZI-})M>l6hUpgzO-5Hhy`CbB z2-krzLZ`j~*~I4sta9~Xfm|#cF?DLnr=F#}yTgo%&IU$vF&?fOqr}+bYrw zW8B9EAw~~RNWE0-F5{BDejZNXr)Ug-eEEk*it7<& zJ6tjntOsbpYStbr7OJ$S@^9Ym2Q-Ke*eXmp3u_f{4( z<0xU9KdrlG*{TyXo_>~YJJd82{7jcF?0RB}d-HU?h%eP5VIcY=L^z9G16^1v622CJ z^(PKP^K@E`9F>QZOm!z9cNzZYz?Ga+dAh$5Qe#|I=ei(CM5GoDx4sGTr6NsPF5uGg zhm=x;J`~q)pc~TfO)o#w96^2(EF|?~{^SXe!}RWl>$^m@Vg%GGtt8wWWVf=lg-l7Z z5iu1{InPM&1ZVw_o2qShj_sLl#i5AGJRleY7IiJ6q7hCIRxy4E>r44)te$@d9apUZW}9Onil~2ng07xdxf4dxWZ(!&r^F z6a6vqqVJopY7H*lTm7~q@RV{l+AlZNUgedkEnB!J&{{sNj(9I^q%`V}1h+h#{nqUp z%GF#S#Lmwzv`z~`hFb|-5xmt7>Y!)FE z!bl?rK%=EB_{0oW*^ zj!zB5mgCJ(H5@(@2}JtYtiT&{O)VyjwctwUn95Z{PRhrU`WsEWs8F~^VO@&G!5g~K z_L5w(w@5SR&J&uEZmb#wnG+xqXKFs|ZP?z{b!ik}bhmv@r6DW`Vby6>UyFHD&DNM) zJVq0P4Qs!l-4Du}i>xhK(Yr*c`bs2+>v3nQDo@gA?kRP zh}KuL0O!EM9|uu+bMBFVNtoK$2G^r>+;`TRlj%_M`%AafWmgJ?@qEsmugi!=j*-XpKx1#G*R3{Z!0|aMLs_EIZL}uZ%s5WCxqW2a(lI7g{QRl z`AAa?%VkSkQYU6!Zzf43rub-1xSqnAfb91zDYkpjz?l|8@hE!&@)B#AT4-d-f9aiO zqzA6t!E3jxw(xTXwwccBLkeJ6B^b{8eZqGIDws2=B7vO{j+@pF}}m zdE;{s68tr6uQzvdQf)(&=R`+{TLOacFolqnLgbTFy<9A>I_q@=i;9KUmd`U*V8uCs zC{V`6`fu~A2P%z>6hgaVv#W_&FHuzqO@qm5>2!1zPF3lMMrgU1CtF-A`oC1)`d)c7ff|HITx%Ml1i zmMIp-6bn)^xX?5mM8$dCsX{{|_q=sb)Q3yf-F25X9|Y$NPU_rWuTm~#sEZ6z`%gAF zOTA)ndrR)j&+pJPuY84%v9!5D@(I-s?z{;k4rG3ENyeC!Xxsv3O2cXL8r}_*!3Z%e)CzbygiF zu7P-p_eHm7evN~(E2_u`b{?hB@r%Ni)s)CH&0PQ^!A)MGR{%6`&sU*TvaY$^8$oCq z5L;f)L#`&(AdWeIQH*TPZ>qKDUr?F~mU@nrgsjb(fN-M4iObvdrinsQ$GRj`L?UaJ)b2QU4Au6O`P@ zRQa7)3R$-^vBRV)m zJ=($6=qnylD?Bq{W;;{-vN%D$@LAue*g38+$i}epY)ZD5$5;4 z9*M3Fs^vufZFq_OJ+$EUoobzQGqT4VgsrkX`T5(8WE@4Q8i>Cb-VxY@ft5yHq{*q< zAeK*%CESLQTIap&%`w=R){F$owNak$K(>2!?L_(KgU3xb$mF=3CX3Dao67%=%?Ee4 zDUW)NTn@~tvnN|{n%I>|| zWNf_h!`C~i?#uY(rHs0+)gO;{G}Bp$MH3<2^@PcJ0?_sCP z7vct!sXe8s=9b#2jdo)ec8jn4{`w>QA zL}aczB*1(l$PYL};L>kP!yS4Q=AOU;`yHpITJVIJDf`*8rZ1v=C7Vs}SmifBn)Z7Z z2B0)f9fKRmCTF1flZ-qY5r?Y9_qe+)+vwSe0A>Fhd_3TsRls$p09UMwpXR52=Q zN*GlojEXr%9jm5>Rlz7>w6GY=Nk`iK{}phPeBIM6^#2a9(g{)C4-oy6;R@L;AlS*z m6*zmH?CdIa;ii+jtC_3Q_0U@%U2*$Pz=d*Y}6-fAD=>=Q{U&&UIebeZB7MT<6^PZ95w?ZVn+1006ix z%#9rY06cPm4R+|!{Kdj@?`Y$got2Xbp@#PV<9{*`lHz%kAop+w8%F?%P-9`YYfpHr zEa@DIxr`IyJ3GKFp(|i$enDK!LrPB7Q8D>kDyi#g@8Ek)6Ong~Z82qU|GZoJsvK1# z&j6plE7I1>Od)Sfv z+cyVH`-0E_aBS7W*uW`rVin8jJ6X@m+G~DwG4DRM=>lI#HN|gdUS_;(xw#@^A~;05 z;m7d^>^hTq4}594iy(YR}1uQE+gbKE;Jm9H1Zn(74>M;F^WI}oi zoyt#1|I`e~VOSG;yb~qL4%dX(?ua5!AT_;=9Y}V(07IQXC?*}K=l0J+{jvw$=(u0B zs-)!swq7^Bul0o8`Ygzi_J1I}Rp$~h@2agI>;md+!B2-LW8lr$DOrBWfW!>}Pdyi| zoikg6jfYLjh&QC7b1|`FNJAF)IZB_nsrYL|l^!|Numw$ZMtF^JVyBKhk}w5WWA?M+JH?!6*$H?)W5!oQ5C)GkudI0@!XtCA9G5F1Baa3W)uGBZKQPhHJmGO^KwjkuF|OF51am%|we$qb*K)7u-`P9&1wG?2!l5Tm22FQ9d7gz3 zm)Zl6Yf$pH%9J(xMoryZ%?U!xSD0ILUSjzmo4L7y^znaSoXQ?v-bIMSu?DcTx-beq zvm8FDJcG4unOPi+N=m9)_#%_oIbTYCu9Eb@wPb4hKo@~Ev`sZy$!)&erF2LV<1~n) zd;q?1u^+}kc_Z~n3IzrWW!=X=S3P%*>woKUR~{(zZbX@SVjQy?1K)Pi$n}hLN#tQ}%24>0>$UXu~?=l1Ndg z)W^kMJG8i1>w5vPdy|KDV80pmuZ((*ac)$v$Tha4;<84Km=lbKE2qg?9}Qb86}5%g zA1^Mh_JzD9o&SDz%P;#mF715;azp^gBX3BtRXNu>Q@z_V`X3%jYeR*|Vw z&}i(}o4f$xb*77K*k92&|FiF^CBDl}%F5z1VQ%}MPYA0Uh;dSvPY5+PTt%Pz%9eBu z&zB$Y-ZBye*rZQZ*sExAXtu;?V=#orZX0v_8h`PmJrnngyBNh;#5_ZnlRmeKB|Km|y(p`2i4IGly2CjiQlpM5OAofb2B3WY!TkxN!1R$}i>o>@!l5f*x zi(>~$sM5GB1iQzLIs;xwRf!ugd77CJnv*0^c#+byLeex6ZBy6sDdLeF+X_Dn;8QdYgqkG*0%9*XHC^|elIB`O9F5XyzO9X}5-v>19xK1%t!BN)>m{GVS zMC?ZqO7H4<5lTMwdBaB?cErvv{s*KiLfj?Yrjoc^G~|t$lb9<;P*+O}^nH;Fn`P^I zPWO3&k=ci9zOMcv&beE7>av}=Atp1rG;SqdsS!dx)| z*(j&p4ynX7-&D+mpM6~sX4tEJ!-Hgvc>||zHuESZn_z4zdk%m|<#{$mEiTG7^0SE5 zwUldBCo;pM`C_7OLFEcB6?&BvJ+eJL>#7e6!{&aNsj!=AeY;eUeT1sH$W3XlX9g;j zSmr`WAf-r@wZNro#PMk;S#>8;BFjCpzM)R>FT7jq2Wn&Si*l)Y3+_obrmhCp-8#W2 z4=($vqEg*9&i8{metOx55Y@tC6r7s%NUeOGLSvoRRF+GkgHD*cPJO_WN!7NJ03g7M zxOz%dnDG|>-L(DFYT9#xSX>!;ztOO%c~EPjV1U~rtDR}{G<|Ajx8Basz|UZ=sDta=f(KH{)UYt{Ny-svsEr5jULatV$09=meA1m2`X|H`DXJ6IWWE^PhTE!k_x>#kO_wHL)Lq2p}b){9Ol4P6v1Nols@GZ{y zsPOkld;77>-t{Rawn!!%C(RD(H|aMsvy=rk!J(IdR?mi70yN^2?{?R!Nd-;ff92ai z-q_paOK~b*S+H0uN$1e-W^r5Qw(7J{kGR=frI>ek6DYW+9yHkQ^lfUle?bW>Wdy{} zD4F!Q$bAs|NwbKXXWOXL$id=C@IJl@eH5!n>#Kf#S2f6QOIodX%Cu~Aw0|m4u#5Tk zqa-8bir*@*$x+bCuS>3HoZ2{-G&t5o|Dl#wRuHCpu3-B0Z5~=#W!s@p8)kHTjP7bj z91!cQ4cH)<>JEEtgd64H1O3~4dPPt#nSq)yCMOrSnu)gxofl5q)xqz?YyEzom9emG zn?XdnhNGS2^4vPOZ`+72+x_sW7&mLmY~r{%FpIY$5c$L=tQCpq%&Sean$ z<73L)pe0dtD}W?|6m)I0wH9glBdnNcQ!J;Ss0WM8IPkcxE0PS?bRvo^RTl5oJ&DmX z6(GMD6I4FtJwUC~qbXophUx57feoxofjuK5q5EB@s@_*b@wFer!@Lrtx;@|I!BIia z4VB+JVC~~;KqFs_x=1GF3%mwRZ81R+E}tdHz|8`h+j{0V_RvoyS+{NDX9mA^~V*OLVs?Ko6f_H5^PvS!p zr;RO8WrWPq7yzLxvORTv{bL{pP0h-a4~lyDo?D127^)v9GXgrVXX+-uckec0;vNXD_zD?F3 zAd91|3Rnk;t*nKWd!(N8&&Of|VvMfbm8>B+_OG+9FRlbr!8Gq^K-92ZLa^k<$(h^L z9!%b9#_>vY{i8LT8aQP=pZ+s*Mdh0~=pWX8K_8R}+5{GmXB7H^YpgM*R>dBHXmQ#( z3Gvh);S&WVLHs*>I8+Yrq+I^=2Z15HoEs9u7_$1aD_Mft83fkD9v;e0HSsKJc+BK~ z50gUwzL{XGxL4S?d1`2Rf4kU}*39}SBT^m`OA27|nhY6#d2uVproVH!;Jkb4R!aBZ zNlFqmgiHLKVEbk-uc*J^fgNs%P>RqN-=T3kaM@vA69!y z{o2B=oG?;1q6FxgpDJV-@ej!_n=Bfc(Lq26P1dAki;JE~ad2{aycXz8_qFd^8tZ+6 zLh(XOJGioJeI*U2ShfPe3%oC>n}|idCc2ixZjXUY zWqp$Yz=Gj{*PXC~y6poule(=vkD^{`U}4+D+$6zxtTqVwN_VKBBe%I>@6xw}*G)#< zEL&IiV|l>Qvf*XvDnWM(L0H!AfKU&%L?ZTYXun`7JzUMOOV?OBd?#=Gcir51CP5#C z$k~%Dt++n6Tzmo7lXvQHZ5^@i^t4*6L5<;v-Z*6*d)`49F;4f8A+ zF|T90`jcaZ+Z4*ZEpPeknAL3LwyV$KTgL9Dhv1{ z6B;An?O{Lfks3nyRcpCO+UiSE|Dnz3xW(r3FPq$4je}jkZ>)>Ij!A6k-7VL?d-LJU z;^aN|(R)j$dxjenT1pkZIotf(ZKWkcfiYRUKDZSU61pdF9PojZ^4u=$Vqr&Uq?4AW zYGHn+2=k~VBWrKrAHnqYX@8P$C#8IFbZ1QUbpo~#~0i_)No}wD^cGsw=bQd z4ijA&KoL`E6RKS;|1rX_Gk1nrN51n!#{OR9Q3os&ZsHd1=M(O)?R(w-$N*I;p5@tEp+Lswk;wYOAQoi)U5q~*6!sog_ kVBm+p2j9na-S@eFIOjUoIrn`%uX87v8XE}kitz#f zAaH@CZw3IM{UfjfhwSf+3x?bKhR2s=?Z0nH|E%*Lz3}^92TU)SpL_iO{ErS)e;?7> zZ;^F?nei0>1cpGl;JgAt2oX^+aY>Yvw2bUAxs!^gR8-YYYvFVW#B&BD!;7YuuUObP zI=i@e+_*`;6&^*2iBCvL%XskkX&$xkSxM=Om*sD&YU&yqTiQChdncCJ$i&uf`$<5~ z7Y+2SbKa~Y0pP&T3;JixL&lcu_*}+m2hWdPQj^en&Ky>@lK> zNh=$lHL}0Gx0l8*b#D6S$|0r4_m#qbG2wV$lpy_Y&|mQ+5{UsOrJs4F>#Yq@urwiB zMJ0*$o!Ptye@p12LRVPnes=P!BEYp)I*hS8lwY3%ttLDHJ~H(>w6j!LzgRVf}(lX$sivya5cuGsYjv= zFLgbJy$O0E2@63iMhTNrO^N@~+=gos*f~3JcbIZ!S(PdT2(Gvmhf}hI%-ol=4jI4{ z!DSL#KTq2}7=~$qRFSyfV*J({!6RCxKRQY}=u74U_4$`U9QF}49JkC}XLKhFxP;a34m zA<40cD@-h|g3rSDwPpwp*eMs&kw2cOhZgoG81p%$oH-!)#ABD&ZZMg4t6fY6o^8<6 z;lr&@Ce4C{eryu-bA0!T=;|mG3XM4Q4?%}toVsY&|0z9nXr6QB{chj9xy9_SzvU|i zVa=;J#mgXb<(1jNL-x5}MZpEhUbl50%E0X>4o>*NWEK(#=L_?!P79A#1u6z*p9RZ! zwfyZS;w;sX4^4cWtso7>iF1j6;!^D3O_1oX+32`qRS5oR797AYlsMPq1mUzOfy=}g zLq*@}l3ICuE$Lx=+45ZQw%#daVvXB;tcZRN;3dsjwQCxtq@0s z`6J>0(U066z9`^lqzfp}^21}yv4++6hhq1#w-=juWAqdu$L z>sIhzZ?AIE-3Tk2M-%BgAlq$ztb@|SN0Eo=sj!JDFF7iYW(1U!7}wjgz;t})6(m+C zGWA7tm=ql_*cT}S-3`WROnA%b>z4^uz$cBIm!@(T1_M-^?)J>Du~Yq`5W$c1R}K~) z$F?$&NYC>IcYc9Z=hbQO6Az={b7}YUGyf^0!lJ`xi}2m|jMQnn*7~Uz^NmJVKs}x! zixIBIV zPJcmoW5xTJ)3juOLJF)@eJnc+QOKOSC$Oq9s-Y6MgqV zhArO51|dcck4wE&>?-4uy?!1};HPNxgM9gr)p_gDM5dvh3#eiHCoAB490d7eIg0BM zWjkCl608Sk!Q?;&afH6oB7wU?Nj%RLNIVmtSFC{)fIV=;ejP-SC*7#ClxT2=Gxk>I zHRC8@n?J3)X4tCZbe=wzZX47z6Z}k;y^@BxfIzXyPp7Vt0W zmwYfQ)`VN81wb1A`!orVXJ+WvRB)(2`->My1N0hA>0;t5ghfEGddW4&WbGqV#Vp2Z z#GUAmi5Gp}bX99$;oj=EC4r}uyU~8RsrD+bOl{f1-GSEfX|=?AX~U&aehQcHi$sv~vBGdBnm(<3X55xXI|G)r z$rVN#-aw^A9FB{BD>yir-uk>VRc!`4ESjwG{tb`g6eiI?Fz-tg$1!esk0k7D4d%f1 z%=4pMU{%cC>*C=hjF5Eyi6f?bZ3^a$4SNllMQ%4=>{ao>W+vKYZOnjPc!VJ0%NrG! zP1!IwSz80!HQH6=IGY)^cY{+O!^GA2keLjX*G1c4#pcm^2sez6iiZ z33Yt3KeilihN|Z9nMfeg&t?VQm~Ct}SzHUQbdIT9HRPmxEUCNE$cqYvdlc5DXdJwu z8*MMiC3}lBeeOJ=3F*eFR**RXB5@|?!rq4MZC#f}0Y-P*W>xCLf)G|6R&_O)H#D}! z#KJMU7;H%U4gG#l-fUz|$%@`3O4V2Tv8U$#?!|mvF$-kw6;bQAzh{pOv5g`_2M$rk zqC~X5nguuq7XCPh%A0kM1WdxzMmM+~rQ^P{)|^ZSliy#ur7pWtD2(TG?jRSwundB) zBndwFqiq$S6klhXT0dX!CI5um@*|1jCVE@pxi9kZvCmoBt$J&sc{w5c4w2id?JGQ` zJmC!hltd?HO3!zEHN;-UsEtDW|=gH?G7+^G_ z&Rz#~ATY!eZpuo|(1px))YLRb+?Zzk{Zy6Br>e7!5I;#*m>s!4<8WUxjK?nfAUO z9r}5GbD=o-l$+F7yrVgPf*z9Sh_u~2;ah-s`yV_m;E6GMq9{3QQ9+HLa`-{9oYr-32Oo&eX~j3?*V zZ$8QG-+O#@)7pQp;ISvz1>*l`2Ev)M@u+Uda$mc<7n;vS75~%*{kngRTjJ8$sLNu8 zWzV@AqPs97E-YLKhp7%kd~(OpcPXpWb^NX)=^nd_7^Ci|53X9Xl4!3F}Pmnr>g~3vQV=!K%)x zL&P-@Pw~F!cF(PGaCSu%`M}Pj6b61l*pfzxJk!((EGD?gOY{hU=Ir?@luFh$w|gQ8 zjs0TF>v_o4q-w-5=a1a2Sq9Pe6Xlwkyd&ybo*xhg=OH-R$uXZUG`p}j&_={QqTwU< zFHOZiO*-~N$Pk`1f}ig(blTP)S-jg2dGp<8&}%{RBQpZLq*Jv{PrGYfkh)uS3R$A( ze#OV&>hZPQi!YF+qHpjsXNjQWRAn!w?cb8mBqySUC|x(fwkE7Gne~f+J%2Y($p9+Z z@M@#m@a|TM5Qfh!BwP$}kcFli@LAoZ{f$5-#(I~g@o-#~HPuIm|_^lM_CT3I{L=6SxvOc!wEQJ|-B))JY*oxEvULQYyr!Sfkg6JbpEILoWMuSzr zu||e9ioDCZWg8Bu04JPMbj1tXUZkRSY}vTmwfj;TS&4~7>kJ9!T| zRlX26m`Lp|O*OaFPHnIowXj=w<@ev;Ek$vlMk92Ghf4NJ?y61);0V(Q5>x_Bpww7H z&G+(@q|{;v>8*n_ei>`RBE;tqs20!r=Na!)cJ$Zx5OBXmx@myJy!_}M_t;|C@!3x3 z%1%V)x%(LHds%e5J#7x=Go;7|E&@_vBmpA1*XZUMng ney+gT>tttFsS7uq++EFFovw%8`sj+=cLFY)GuD4abd32gmXSp( literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..616135553b19c392dc237873756ff63e180620e1 GIT binary patch literal 4430 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

ToE}FyR=IlT)d{`mDBU=!9a_?#TafFEp z6mC8>ZDwPe1cKk*0-v1x3xz0qY{NIT)ps&IS3tk>+U$mnxuAVTq>BcVdq(dH%u-1u zzs)jORkiy@hnZMyUFBJez(IYzW$u^BTf34E!WP7IRpDYR)q9^~tFvcqsVrB}3Bd_1Eu-yhIamN}y@|Ow`Bt2<=>^uJI6n8^V<9BlY z54H?N;L~t$)&hMnN%3(Iu+i8q?>nz+VJ_dj0)am|0uc%lj0qR~J_*4ZkKMf0dFQ1^a~D>( zVS9pm)|ML7m8ZtMPK@B)B9cOqLsKZ3*nF;sw>gp##9~Jla;RAqlpMoEMiLv6SKWl; zd5QJFe5kFYq4IzfFY=-DyCjV*&Ar2M{W5+%8`frV*35Ktbkk;3rxpCll`SB<9kA>F zF)x@vUIGCDU>J}WKv)1t@jfZRwHY7q3WknKN_~89IyZ8iVD3cMLZm8b>3YS;8LPZ^ z*KJ#e6e*6rT@3HF_@q5-!o4yptH2}=LghJ z&Mpe3fAvan%-9e?#L}2P+@MtUdJ2`pD5ww!ol9J)N|uGu^|6)JE?G4Y5hAR;v!&hG z)TGuzxxe3BZBRZm{3Txbtdl=RJ(%J0rB0r}!SnK63Kw4#PW`j!_V>%5*lK%J`Rq3b zcyU0(io8$VOTGV_9e&Zt7jDN42G5+gd?`9J^THSiX=XAb zg+;}t(X(>Hco=R1jZ;=CFhH1a%q);5v3)=42NI z=GoIjnYktTmDLnHS75A;FsauyFl<`iDs3?}Ln?tle?rxDAE^4XQky+HpBcBAnW)+m zrf+1=Z}oVk5WcTX5B9dy7Tz!+}AuQz$-v39| zay#KdLWc00oCi;R=zcMgVJ3;mG%kb3O3iYQ;3No`0hK|yrTjewh4sY}VF^c6tEYu% zZ&R0bbpmx;Y>MdXw@?Eddh|;#{dYL~|HA3;M>vf}06_9#*aSmP>AV9H`cmqIo)Vpe zfUGPy8?~toqF?b5NKT#rrY_VC|N6ClN$EW1KD|Y&nQ#iTu*ejTzgQLF{KI{KMO;HZd?WJ*zukxP>LfZVWmB1g?OR?W>E#b-Ye~d5#Ydwn1>A zVYj?Pe9*IjMq;;y4W$ob@dqUR>?0}dB?Ed_Q>PS>sCdg;x6$xf8|b!e4<|JNI$iiW zVvPMCF_b}#-7@~6j&~UhZeJM8tUUG}Mx0pm6A36Ek5&n(Ex1ET;>xj9mxm)~VOH9W z?jx(*?LB+0cM@NiO%LII(QL;ZnMm*wD-cI@#N@>F5Ss$v6)CcTw1PS>Nhy&fb?6!y%qTuO>;da#^^=v`L#enhVbszx_IToc~M@5cb{b#s^k6!(EXxX=dD)S}(Vs zeuwKIW^%jfrfTLX0N2-SKiO~)b}M<=Jw0@Sy`7LVS54>pw@*t*&lby`hET$?t-9b| zL{i}P;M5G~tV~X5OuR=tf$7h-&EsJdxCMo~srzzD06mg|YDI10i0WwC{+`4pKX`?m zY@kb4@79o=$du*|rpvpEvxo7$%>HCy%~{;x9mb~n&8Kgm;CDAe(dgNUYkH4%Y69kX z_I1?wQ`J!|5sn+I##iMW3C-~DUdD5XVWPTg_ zTox?wOA!`0WyFBMfE-)t<#|G5{4ML`nAx}8nW zJ+qs((wy5$gus|2#Ol?{fyMs7!$pNjV3Dox?(hLy4JoZ-j_5pSb3PcmLKcEXHXr44p2H18o?EZGdkyyl4b9H@}Q;N1?N>Z}ZRu zX6Nje9Pt_8e1>WbA5l#Q9krSLCVXw-+>?q&1)@_IC<>wB&819Y#*Q_~Jk;xQL~juYOD2tMzWzXbd=F~)!TX84QRLE5bcXk1Db zn~<03Pedz|5q=zgV0L*T)~3ivkYAQt>d3V&^cB^m)z))q@nRk+5O)EY_|UbV`I7H literal 0 HcmV?d00001 diff --git a/install/images/ajax-loader.gif b/install/images/ajax-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..0dae0230631291372c2b7024ab6ebd7e30680d62 GIT binary patch literal 882 zcmZ?wbhEHb6krfw_|5a1VngCVCPpTa1PKO)1_lw`q!^CCMTeP~SbS6>5}r6P q3bIeo$^3M`VG1jUKtklCB@K**seWrZCmd*CWRaLQC(}TI!5RR3VJ9d6 literal 0 HcmV?d00001 diff --git a/install/images/cross.png b/install/images/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..1514d51a3cf1b67e1c5b9ada36f1fd474e2d214a GIT binary patch literal 655 zcmV;A0&x9_P)uEoyT++I zn$b9r%cFfhHe2K68PkBu*@^<$y+7xQ$wJ~;c5aBx$R=xq*41Wo zhwQus_VOgm0hughj}MhOvs#{>Vg09Y8WxjWUJY5YW zJ?&8eG!59Cz=|E%Ns@013KLWOLV)CObIIj_5{>{#k%TEAMs_GbdDV`x-iYsGH z#=Z{USAQA>NY(}X7=3{K8#eOSYYtbpBV}~vsBnU!_?2tr-P=|^T zED%wc9ezHgW@NMb!^uT_|SvCpFLJylbx zY%bpaTGI8IYXMN$9w<3j9VkA~NYOKEQXsj?6a9_hcwfU$acAhJhB)zb_w@MVUEy@S zX&I>K-R!bhu3?(6bHWIg$HEl7{9g>>&l_qdd+UYb(1~BCo9LptNq&8>!yoJ3Ui(i5 zRJ|XnYBklL!{@$-7=3mJ>P@1c=7Oc79e-V7yf+%lD2!I;Y&nXBZ>=B!5?CB>LvEx6 znI%n)qqi$#X#wKB(U7XP2P=+4{b@j#r%9-K(8UqtSDk>0UKzf*HM9yqMZ1D!$2MdZ zR=`U>0zhOH1XqN?nY@AQqB7)Fp4{v&dKXvb43hZKvnN8;Po;+jY*}~*Z|W9Q0W%{D z^T}Cc<|r(Su=1K=P5>Z4 zg`et&Va}tdzBS-G-ZcO)zCWpJvGQwrHZ`@wpM420ac@bI5~KkTFfGEM3sPWO8co4^fI6lPnA)Y{ef%@{+SnoUk0+dW+*{8WvF8}}l07*qoM6N<$g7cXs A&j0`b literal 0 HcmV?d00001 diff --git a/install/images/exclamation-red.png b/install/images/exclamation-red.png new file mode 100644 index 0000000000000000000000000000000000000000..517725822ba2859be6811af489efc672fe4117df GIT binary patch literal 696 zcmV;p0!RIcP)uaKl`6H0#EMPSO}g$+@CEq-R{ewSv#FGPK-H!Tc2R3p2_kJF0cu`0*kJtV zjCsgq(?u;Ed+xn+&YijUnDKod{^#N8^`2pX!!LmWNFh!ze2F+%=KVx`#;wi}cP!HRj?vUiNxuPsBu{O~nOELXjlSf5~J5P%I&A zB-h4c)%3h7afr*1RT(5a!ohQN<71Ys0TMXehLPM^z5@17Z^8fgQ$x#zB eD000&0t^5S;vPyKd%pDm0000{nu98p%gZ zLlX-*)e@xGR?sp`+&PGbEO(=6r1mO5Q^j)s zF2>}L+8n!qEq058!usvFl(;B?RoamGrXw80Cw;JVSq?sYaZpfA6YL~B4Z5x;Orw`y z&rV6P5KntB3+U+)jy=O@<=K58CkTgyS z{r+HeWhu-8Y@_x2XA3YKnoz6NaW)w5atW|F>w)KQ2GrySf>l4COhi36YwRRdZ9}iu zhnx4mFwxdV5_sNf7quo5a50T@13~bhhi-C);tn+wPZBMj`K7UMKf=l#9}S9fzFIx( zr7n0h6iNsy5P3F>qB54?sA*}OCc52$?GI(09uY{A>;QR&KRH=eV6S3noCLD$D-_FI ztEo}~H#?D_D1HWePdNS|!)`@vk;X}Y_3mqilG}J?Xx~p{7AOb`ynPa3pfzy~6hD3q z8pV=^v>d&-nfV-WoC^ZcMp_oz99(kC5?Wxe&azLTq!A8npA zcGzoW2{?|k8yX44Z_G~5-Mck0xtQj7@e=F0sn<`xeJmYTo^CY{-hD>u7@_^0fXeYA pJa%dSF#19I^myqh;0oRM3S+oLoE#L?c8~J z&e%5f1q*NT&D_WNzVo_Q3d0coXQ=dfElHr@pCAEb5F0pMM$8TDz98PAt8IkoIpZqIq;wIypRiDmX8r-Oeu&49P5++*(>&D}<`b z9M1#i;$nDa%oYkpI-8xU?(S}Nf9^*j5_xzfNts)^{$_c7eTlm+3xeRU`AV3o8ixE} zZ*N~X&a)R`XhsoWJ{xnzV*a~rGskhREm|xVV>7v2{2%6!w?~Gq z>q4*FjUa>o4^xVAR#ljuoJaL=2Ljul&(A-BEOP@}Wl-b)0cOzWUn z0;LtWZ01tXg<8j;Z_I_HKrTI+R#Ne#91TW8JU`7;ul=m;PH$CyJhs|ao-Hj8WYC4r z1T7}-!!nc)MnE)Beai(YB()laHos380a;w!sv)P1YS!k&(92_2?TrT5v`X%=E_V8$E7MsOQc!no)rgsMpO$rb~ znx$SzTE!+Dt2H= zl6+;~PXSRD8)o5><1;;jHvL`Gj?8DJ7yk74_!t{^`ruUtU*NUq$R?J_nf?quR*&`@ zqAX(S``lm9hd(j+Vh`pr|L6_Q^cyTSck9~%h(SgPu5Ui*zy$`64#J-28dg=`=1kAP zqZLtYd4K$mX5uyr2F@fdffp{&DSHtl4|Bn9=ukpCx`#%PTUr-D(@b7;C zhJXJjrnw{;1KBM=6&|E`fsNrGL!Y6%zUh}QUl`(@V)PmQFtotEKmafTHP0uP}7&%m4pcKQ#X)BiAJ2y+PrtBI>9eEIt2-_c7)?*Lsf z5vX5*Af@m-wBJRV%#Fiz=BdPr0!2^a2d-yv7gSU);Z6{`~Oy?E5qSnHUln4*Y%!){F!Y1~5WXoC44g zb7l_)X~q^V6MmWR7e3wj|L|Wb!|^}Y86N$^h+kv_Kw-fP!~#If$6(B4$)LlK#&G6; zC&ShMSAb$5tA9Xg5dOsg@-z^@3;;QS9f&!gG&3|;{Da~@Q2ZB({s%XJ5&#fj0J|In U+D>(nEdT%j07*qoM6N<$g0@&8X#fBK literal 0 HcmV?d00001 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 ' +'; + +echo ' +'; + +echo ' +'; + + +echo ' +'; + + +echo ' +'; +?> 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?'":"";e=e?'
      '+(c?h:"")+(this._isInRange(a,s)?'":"")+(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;x1)switch(G){case 0:y+=" ui-datepicker-group-first";t=" ui-corner-"+(c?"right":"left");break;case i[1]-1:y+=" ui-datepicker-group-last";t=" ui-corner-"+(c?"left":"right");break;default:y+=" ui-datepicker-group-middle";t="";break}y+='">'}y+='
      '+(/all|left/.test(t)&& +x==0?c?f:n:"")+(/all|right/.test(t)&&x==0?c?n:f:"")+this._generateMonthYearHeader(a,g,m,k,o,x>0||G>0,A,v)+'
      ';var z=j?'":"";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?"":'";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+='";r.setDate(r.getDate()+1);r=this._daylightSavingAdjust(r)}y+=R+""}g++;if(g>11){g=0;m++}y+="
      '+this._get(a,"weekHeader")+"
      '+this._get(a,"calculateWeek")(r)+""+(F&&!D?" ":L?''+ +r.getDate()+"":''+r.getDate()+"")+"
      "+(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+='"}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+='";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(;c
      a",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="
      t
      ",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>");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>");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=/)<[^<]*)*<\/script>/gi,bM=/^(?:select|textarea)/i,bN=/\s+/,bO=/([?&])_=[^&]*/,bP=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bQ=f.fn.load,bR={},bS={},bT,bU;try{bT=e.href}catch(bV){bT=c.createElement("a"),bT.href="",bT=bT.href}bU=bP.exec(bT.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bQ)return bQ.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
      ").append(c.replace(bL,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bM.test(this.nodeName)||bG.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bD,"\r\n")}}):{name:b.name,value:c.replace(bD,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bT,isLocal:bH.test(bU[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bW(bR),ajaxTransport:bW(bS),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?bZ(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=b$(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bF.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bE,"").replace(bJ,bU[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bN),d.crossDomain==null&&(r=bP.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bU[1]&&r[2]==bU[2]&&(r[3]||(r[1]==="http:"?80:443))==(bU[3]||(bU[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bX(bR,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bI.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bK.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bO,"$1_="+x);d.url=y+(y===d.url?(bK.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bX(bS,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bB,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn,co=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cr("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
      ";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cu.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cu.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cv(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cv(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file diff --git a/install/libs/aesctr.php b/install/libs/aesctr.php new file mode 100644 index 000000000..3874fa95f --- /dev/null +++ b/install/libs/aesctr.php @@ -0,0 +1,406 @@ + 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) + ); + +} + +class aesctr extends Aes +{ + + /** + * Encrypt a text using AES encryption in Counter mode of operation + * - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf + * + * Unicode multi-byte character safe + * + * @param plaintext string text to be encrypted + * @param password the password to use to generate a key + * @param nBits integer of bits to be used in the key (128, 192, or 256) + * @return string text + */ + public static function encrypt($plaintext, $password, $nBits) + { + $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES + if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) { + return ''; // standard allows 128/192/256 bit keys + } + // note PHP (5) gives us plaintext and password in UTF8 encoding! + + // use AES itself to encrypt password to get cipher key (using plain password as source for + // key expansion) - gives us well encrypted key + $nBytes = $nBits / 8; // no bytes in key + $pwBytes = array(); + for ($i = 0; $i < $nBytes; $i++) { + $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff; + } + $key = Aes::cipher($pwBytes, Aes::keyExpansion($pwBytes)); + $key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long + + // initialise counter block (NIST SP800-38A §B.2): millisecond time-stamp for nonce in + // 1st 8 bytes, block counter in 2nd 8 bytes + $counterBlock = array(); + $nonce = floor(microtime(true) * 1000); // timestamp: milliseconds since 1-Jan-1970 + $nonceSec = floor($nonce / 1000); + $nonceMs = $nonce % 1000; + // encode nonce with seconds in 1st 4 bytes, and (repeated) ms part filling 2nd 4 bytes + for ($i = 0; $i < 4; $i++) { + $counterBlock[$i] = self::urs($nonceSec, $i * 8) & 0xff; + } + for ($i = 0; $i < 4; $i++) { + $counterBlock[$i + 4] = $nonceMs & 0xff; + } + // and convert it to a string to go on the front of the ciphertext + $ctrTxt = ''; + for ($i = 0; $i < 8; $i++) { + $ctrTxt .= chr($counterBlock[$i]); + } + + // generate key schedule - an expansion of the key into distinct Key Rounds for each round + $keySchedule = Aes::keyExpansion($key); + + $blockCount = ceil(strlen($plaintext) / $blockSize); + $ciphertxt = array(); // ciphertext as array of strings + + for ($b = 0; $b < $blockCount; $b++) { + // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) + // done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB) + for ($c = 0; $c < 4; $c++) { + $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff; + } + for ($c = 0; $c < 4; $c++) { + $counterBlock[15 - $c - 4] = self::urs($b / 0x100000000, $c * 8); + } + + $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // -- encrypt counter block -- + + // block size is reduced on final block + $blockLength = $b < $blockCount - 1 ? $blockSize : (strlen($plaintext) - 1) % $blockSize + 1; + $cipherByte = array(); + + for ($i = 0; $i < $blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte -- + $cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b * $blockSize + $i, 1)); + $cipherByte[$i] = chr($cipherByte[$i]); + } + $ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext + } + + // implode is more efficient than repeated string concatenation + $ciphertext = $ctrTxt.implode('', $ciphertxt); + $ciphertext = base64_encode($ciphertext); + + return $ciphertext; + } + + /** + * Decrypt a text encrypted by AES in counter mode of operation + * + * @param ciphertext source text to be decrypted + * @param password the password to use to generate a key + * @param nBits integer of bits to be used in the key (128, 192, or 256) + * @return string text + */ + public static function decrypt($ciphertext, $password, $nBits) + { + $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES + if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) { + return ''; // standard allows 128/192/256 bit keys + } + $ciphertext = base64_decode($ciphertext); + + // use AES to encrypt password (mirroring encrypt routine) + $nBytes = $nBits / 8; // no bytes in key + $pwBytes = array(); + for ($i = 0; $i < $nBytes; $i++) { + $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff; + } + $key = Aes::cipher($pwBytes, Aes::keyExpansion($pwBytes)); + $key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long + + // recover nonce from 1st element of ciphertext + $counterBlock = array(); + $ctrTxt = substr($ciphertext, 0, 8); + for ($i = 0; $i < 8; $i++) { + $counterBlock[$i] = ord(substr($ctrTxt, $i, 1)); + } + + // generate key schedule + $keySchedule = Aes::keyExpansion($key); + + // separate ciphertext into blocks (skipping past initial 8 bytes) + $nBlocks = ceil((strlen($ciphertext) - 8) / $blockSize); + $ct = array(); + for ($b = 0; $b < $nBlocks; $b++) { + $ct[$b] = substr($ciphertext, 8 + $b * $blockSize, 16); + } + $ciphertext = $ct; // ciphertext is now array of block-length strings + + // plaintext will get generated block-by-block into array of block-length strings + $plaintxt = array(); + + for ($b = 0; $b < $nBlocks; $b++) { + // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) + for ($c = 0; $c < 4; $c++) { + $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff; + } + for ($c = 0; $c < 4; $c++) { + $counterBlock[15 - $c - 4] = self::urs(($b + 1) / 0x100000000 - 1, $c * 8) & 0xff; + } + + $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // encrypt counter block + + $plaintxtByte = array(); + for ($i = 0; $i < strlen($ciphertext[$b]); $i++) { + // -- xor plaintext with ciphered counter byte-by-byte -- + $plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b], $i, 1)); + $plaintxtByte[$i] = chr($plaintxtByte[$i]); + } + $plaintxt[$b] = implode('', $plaintxtByte); + } + + // join array of blocks into single plaintext string + $plaintext = implode('', $plaintxt); + + return $plaintext; + } + + /* + * Unsigned right shift function, since PHP has neither >>> 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/upgrade.js b/install/upgrade.js new file mode 100644 index 000000000..cfa9d5da1 --- /dev/null +++ b/install/upgrade.js @@ -0,0 +1,92 @@ +/** + * @file upgrade.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 - do a pause during javascript execution +function pauseInExecution(millis) +{ + var date = new Date(); + var curDate = null; + + do { + curDate = new Date(); + } while(curDate-date < millis); +} + +/** + * Execute a file + * @param {[type]} file [description] + * @param {[type]} data [description] + * @param {[type]} type [description] + * @return {[type]} [description] + */ +function httpRequest(file, data, type) { + var xhrObject = null; + var isChrome = navigator.userAgent.toLowerCase().indexOf("chrome") > -1; + + if (document.getElementById("menu_action") !== null) { + document.getElementById("menu_action").value = "action"; + } + + if(window.XMLHttpRequest) { + // Firefox + xhrObject = new XMLHttpRequest(); + } else if(window.ActiveXObject) { + // Internet Explorer + xhrObject = new ActiveXObject("Microsoft.XMLHTTP"); + } else { + // XMLHttpRequest not supported by browser + alert("Your browser does not support XMLHTTPRequest objects ..."); + return; + } + + if (type === "GET") { + xhrObject.open("GET", file + "?" + data, true); + xhrObject.send(null); + } else { + xhrObject.open("POST", file, true); + xhrObject.onreadystatechange = function() { + if(xhrObject.readyState === 4) { + eval(xhrObject.responseText); + //Check if query is for user identification. If yes, then reload page. + if (data !== "" && data !== undefined && data.indexOf("ype=identify_user") > 0 ) { + if (isChrome === true ) { + // Needed pause for Chrome + pauseInExecution(100); + } + if (type === "") { + if (document.getElementById("erreur_connexion").style.display === "") { + //rise an error in url. This in order to display the eror after refreshing + window.location.href = encodeURI("index.php?error=rised"); + } else { + window.location.href = encodeURI("index.php"); + } + } else { + if (type === "?error=rised") { + if (document.getElementById("erreur_connexion").style.display === "none") { + // Clean error in url + type = ""; + } else { + // Maintain the ERROR + type = "?error=rised"; + } + } + // Redirection + window.location.href = encodeURI("index.php" + type); + } + } + } + } + xhrObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8"); + xhrObject.send(data); + } +} \ No newline at end of file diff --git a/install/upgrade.php b/install/upgrade.php new file mode 100644 index 000000000..4409c4252 --- /dev/null +++ b/install/upgrade.php @@ -0,0 +1,658 @@ + 0) { + $_SESSION['charset'] = getSettingValue($val); + } elseif (substr_count($val, '@define(') > 0 && substr_count($val, 'SALT') > 0) { + $_SESSION['encrypt_key'] = substr($val, 17, strpos($val, "')") - 17); + } elseif (substr_count($val, '$smtp_server = ') > 0) { + $_SESSION['smtp_server'] = getSettingValue($val); + } elseif (substr_count($val, '$smtp_auth = ') > 0) { + $_SESSION['smtp_auth'] = getSettingValue($val); + } elseif (substr_count($val, '$smtp_port = ') > 0) { + $_SESSION['smtp_port'] = getSettingValue($val); + } elseif (substr_count($val, '$smtp_security = ') > 0) { + $_SESSION['smtp_security'] = getSettingValue($val); + } elseif (substr_count($val, '$smtp_auth_username = ') > 0) { + $_SESSION['smtp_auth_username'] = getSettingValue($val); + } elseif (substr_count($val, '$smtp_auth_password = ') > 0) { + $_SESSION['smtp_auth_password'] = getSettingValue($val); + } elseif (substr_count($val, '$email_from = ') > 0) { + $_SESSION['email_from'] = getSettingValue($val); + } elseif (substr_count($val, '$email_from_name = ') > 0) { + $_SESSION['email_from_name'] = getSettingValue($val); + } elseif (substr_count($val, '$server = ') > 0) { + $_SESSION['server'] = getSettingValue($val); + } elseif (substr_count($val, '$user = ') > 0) { + $_SESSION['user'] = getSettingValue($val); + } elseif (substr_count($val, '$pass = ') > 0) { + $_SESSION['pass'] = getSettingValue($val); + } elseif (substr_count($val, '$port = ') > 0) { + $_SESSION['port'] = getSettingValue($val); + } elseif (substr_count($val, '$database = ') > 0) { + $_SESSION['database'] = getSettingValue($val); + } elseif (substr_count($val, '$pre = ') > 0) { + $_SESSION['pre'] = getSettingValue($val); + } elseif (substr_count($val, "define('SECUREPATH',") > 0) { + $_SESSION['sk_file'] = substr($val, 23, strpos($val, ');')-24)."/sk.php"; + } + } +} +if (isset($_SESSION['sk_file']) && !empty($_SESSION['sk_file']) + && file_exists($_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(') > 0) { + $_SESSION['encrypt_key'] = substr($val, 17, strpos($val, "')") - 17); + } + } +} +?> + + + + TeamPass Installation + + + + + + + + + + + + + + '; + +// HEADER +echo ' +
      + +
      +
      +
      +
      '; + +//HIDDEN THINGS +echo ' + + + + + + + '; + +if (!isset($_GET['step']) && !isset($post_step)) { + //ETAPE O + echo ' +
      +
      + Teampass upgrade + Before starting, take a couple of minutes to perform backup of current Teampass instance: +
        +
      • Create a dump of your database
      • +
      • Perform a zip of the current Teampass folder
      • +
      • Make a copy of teampass-seckey.txt (the upgrade process will perform one too)
      • +
      • Refer to upgrade documentation.
      • +
      + +
      TeamPass is distributed under GNU AFFERO GPL licence.
      + +
      +  ALWAYS BE SURE TO CREATE A DUMP OF YOUR DATABASE BEFORE UPGRADING
      +  ALWAYS KEEP A COPY OF TEAMPASS-KEY.TXT FILE +
      +
      + +
      + Authentication +
      +
      +   + +
      +
      +   + +
      +
      +
      + +
      + + +
      '; +// STEP1 +} elseif ((isset($post_step) && $post_step == 1) + || (isset($_GET['step']) && $_GET['step'] == 1) + && $post_user_granted === "1" +) { + //ETAPE 1 + $_SESSION['user_granted'] = $post_user_granted; + echo ' +

      Step 1 - Check server

      + +
      Please give me +
      +
      +
      + +

      Next elements will be checked.

      +
      + File "settings.php" is writable
      + Directory "/install/" is writable
      + Directory "/includes/" is writable
      + Directory "/includes/config/" is writable
      + Directory "/includes/avatars/" is writable
      + Directory "/files/" is writable
      + Directory "/upload/" is writable
      + PHP extension "mcrypt" is loaded
      + PHP extension "openssl" is loaded
      + PHP extension "gd" is loaded
      + PHP extension "curl" is loaded
      + PHP version is greater or equal to 5.5.0
      +
      +
      +
      + '; +// STEP2 +} elseif ((isset($post_step) && $post_step == 2) + || (isset($_GET['step']) && $_GET['step'] == 2) + && $_SESSION['user_granted'] === "1" +) { + //ETAPE 2 + echo ' +

      Step 2

      +
      DataBase Informations'; + + // check if all database info are available + if (isset($_SESSION['server']) && !empty($_SESSION['server']) + && isset($_SESSION['database']) && !empty($_SESSION['database']) + && isset($_SESSION['user']) && !empty($_SESSION['user']) + && isset($_SESSION['pass']) + && isset($_SESSION['port']) && !empty($_SESSION['port']) + && isset($_SESSION['pre']) + ) { + echo ' +
      + The database information has been retreived from the settings file.
      + If you need to change them, please edit file `/includes/config/settings.php` and relaunch the upgrade process. +
      '; + } else { + echo ' +
      + The database information has not been retreived from the settings file.
      + You need to adapt the file `/includes/config/settings.php` and relaunch the upgrade process. +
      '; + } + + echo ' + Restart upgrade process +
      + +
      Maintenance Mode +

      +  Don\'t activate the Maintenance mode +

      + By default, the maintenance mode is enabled when an Update is performed. This prevents the use of TeamPass while the scripts are running.
      + However, some administrators may prefer to warn the users in another way. Nevertheless, keep in mind that the update process may fail or even be corrupted due to parallel queries.
      +
      + + + +
      +
      Database dump + If you have NOT performed a dump of your database, please considere to create one now. +
      + Launch a new database dump +
      +
      +
      '; + + // teampass_version = 2.1.27 and no encrypt_key in db + echo ' + '; + + echo ' +
      + '; +// STEP3 +} elseif ((isset($post_step) && $post_step == 3 || isset($_GET['step']) && $_GET['step'] == 3) + && isset($post_actual_cpm_version) + && $_SESSION['user_granted'] === "1" +) { + echo ' +

      Step 3 - Converting database to UTF-8

      '; + + if (version_compare($post_actual_cpm_version, "2.1.26", "<")) { + echo ' + Notice that TeamPass is now only using UTF-8 charset. + This step will convert the database to this charset.
      +

      + Save previous tables before converting (prefix "old_" will be used)   +

      + Click on the button when ready. + +
      '; + $conversion_utf8 = true; + } else { + echo ' + The database seems already in UTF-8 charset'; + $conversion_utf8 = false; + } +// STEP4 +} elseif ((isset($post_step) && $post_step == 4) || (isset($_GET['step']) + && $_GET['step'] == 4) + && $_SESSION['user_granted'] === "1" +) { + echo ' +

      Step 4

      + + The upgrader will now update the database by running several scripts. +
      + + + +
      + '; +// STEP5 +} elseif ((isset($post_step) && $post_step == 5) + || (isset($_GET['step']) && $_GET['step'] == 5) + && $_SESSION['user_granted'] === "1" +) { + //ETAPE 5 + echo ' +

      Step 5 - Miscellaneous

      + This step will:
      + - update setting.php file for your server configuration
      + - update sk.php file for data encryption
      + Click on the button when ready.'; + + if (!isset($_SESSION['sk_file']) || !file_exists($_SESSION['sk_file'])) { + echo ' +

      IMPORTANT: Since version 2.1.13, saltkey is stored in an independent file.

      +
      + '; + } else { + echo '

      +
      + '; + } + echo ' +
      '; +} elseif ((isset($post_step) && $post_step == 6) + || (isset($_GET['step']) && $_GET['step'] == 6) + && $_SESSION['user_granted'] === "1" +) { + //ETAPE 5 + echo ' +

      Step 6

      + Upgrade is now completed!
      + You can delete the "Install" directory from your server for increased security.

      + For news, help and information, visit the TeamPass website.

      + IMPORTANT: Due to encryption credentials changed during the update, you need to clean the cache of your Web Browser in order to log in successfully.'; +} + +//buttons +if (!isset($post_step)) { + echo ' +
      + + +
      '; +} elseif ($post_step == 3 && $conversion_utf8 === false && $_SESSION['user_granted'] === "1") { + echo ' +
      +
      +
      + +
      +
      '; +} elseif ($post_step == 3 && $conversion_utf8 === true && $_SESSION['user_granted'] === "1") { + echo ' +
      +
      +
      + + +
      +
      '; +} elseif ($post_step == 6 && $_SESSION['user_granted'] === "1") { + echo ' + '; +} else { + echo ' +
      +
      +
      + + +
      +
      '; +} + +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 = '

        '. + '
        1. '; +$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].'"}]';